/* ============================================================
   Hundred Bottle Number — Widget Styles
   Couleurs : doré #af8354, sombre #231f20
   ============================================================ */

/* Masquer le champ quantité PS et son label pour les produits bouteille.
   Ce CSS n'est chargé que sur les pages produit avec numérotation active
   (via hookDisplayHeader → BottleNumberConfig::isEnabled).

   Structure réelle du DOM PS8 :
   .product-add-to-cart.js-product-add-to-cart
     ├── span.control-label         ← "Quantité" label (hors .product-quantity !)
     ├── .product-quantity
     │     ├── .qty                 ← input + touchspin
     │     └── .add                 ← bouton "Ajouter au panier" (à garder)
     └── p.product-minimal-quantity ← message quantité minimale (hors .product-quantity !)
*/
/* Transition douce sur le bouton add-to-cart pour éviter le flash visible
   quand le MutationObserver corrige l'état après un re-render PS. */
.add-to-cart,
[data-button-action="add-to-cart"] {
    transition: opacity 0.2s ease, background-color 0.2s ease !important;
}

.js-product-add-to-cart > .control-label {
    display: none !important;
}
.product-quantity .qty {
    display: none !important;
}
.js-product-minimal-quantity {
    display: none !important;
}

.bn-widget {
    margin: 20px 0;
    padding: 20px;
    border: 2px solid #af8354;
    border-radius: 6px;
    background: #faf8f5;
}

.bn-header {
    margin-bottom: 15px;
}

.bn-title {
    color: #231f20;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bn-edition {
    font-weight: 400;
    font-style: italic;
    text-transform: none;
    color: #af8354;
}

.bn-remaining {
    color: #666;
    font-size: 14px;
    margin: 0;
}

#bn-remaining-count {
    font-weight: 700;
    color: #af8354;
}

/* --- Statut de sélection --- */

.bn-status {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.bn-status-pending {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.bn-status-complete {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* --- Zone de saisie --- */

.bn-input-section {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap;
}

.bn-input-group {
    display: flex;
    flex: 1;
    min-width: 250px;
}

.bn-input-group input {
    flex: 1;
    border: 1px solid #ccc;
    border-right: none;
    border-radius: 4px 0 0 4px;
    padding: 10px 15px;
    font-size: 15px;
    outline: none;
}

.bn-input-group input:focus {
    border-color: #af8354;
    box-shadow: 0 0 0 2px rgba(175, 131, 84, 0.2);
}

.bn-input-group input:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

.bn-btn-check {
    background-color: #af8354 !important;
    color: #fff !important;
    border: 1px solid #af8354 !important;
    border-radius: 0 4px 4px 0 !important;
    padding: 10px 20px !important;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.bn-btn-check:hover {
    background-color: #96703f !important;
    border-color: #96703f !important;
}

.bn-btn-check:disabled {
    background-color: #ccc !important;
    border-color: #ccc !important;
    cursor: not-allowed;
}

.bn-btn-grid {
    background-color: transparent !important;
    color: #af8354 !important;
    border: 1px solid #af8354 !important;
    border-radius: 4px !important;
    padding: 10px 15px !important;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}

.bn-btn-grid:hover {
    background-color: #af8354 !important;
    color: #fff !important;
}

.bn-btn-grid .material-icons {
    font-size: 18px;
}

.bn-btn-random {
    background-color: transparent !important;
    color: #af8354 !important;
    border: 1px solid #af8354 !important;
    border-radius: 4px !important;
    padding: 10px 15px !important;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 15px;
}

.bn-btn-random:hover {
    background-color: #af8354 !important;
    color: #fff !important;
}

.bn-btn-random:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* --- Messages --- */

.bn-message {
    padding: 10px 15px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 14px;
}

.bn-message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.bn-message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* --- Liste des numéros sélectionnés (multi-sélection) --- */

.bn-selected-list {
    margin-top: 12px;
}

.bn-selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background-color: #231f20;
    color: #fff;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 15px;
}

.bn-selected-label {
    font-weight: 600;
    color: #af8354;
}

.bn-remove-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
}

.bn-remove-btn:hover {
    background-color: #c0392b;
    border-color: #c0392b;
}

/* ============================================================
   MODALE GRILLE
   ============================================================ */

.bn-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bn-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
}

.bn-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.bn-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.bn-modal-header h4 {
    margin: 0;
    font-size: 16px;
    color: #231f20;
}

.bn-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0;
    line-height: 1;
}

.bn-modal-close:hover {
    color: #231f20;
}

.bn-modal-body {
    padding: 20px;
}

/* --- Pagination --- */

.bn-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 15px;
}

.bn-page-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
}

.bn-page-btn:hover {
    background: #af8354;
    color: #fff;
    border-color: #af8354;
}

.bn-page-btn.active {
    background: #af8354;
    color: #fff;
    border-color: #af8354;
}

/* --- Grille de numéros --- */

.bn-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
}

.bn-grid-number {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #231f20;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.bn-grid-number:hover:not(.bn-taken):not(.bn-disabled) {
    background: #af8354;
    color: #fff;
    border-color: #af8354;
    transform: scale(1.05);
}

.bn-grid-number.bn-taken {
    background: #e8e8e8;
    color: #bbb;
    cursor: not-allowed;
    text-decoration: line-through;
}

.bn-grid-number.bn-mine {
    background: #af8354;
    color: #fff;
    border-color: #96703f;
    box-shadow: 0 0 0 2px rgba(175, 131, 84, 0.4);
}

.bn-grid-number.bn-mine:hover {
    background: #c0392b;
    border-color: #c0392b;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.4);
}

/* État transitoire : cellule cliquée pour désélection, avant rechargement de la grille.
   pointer-events:none désactive le :hover immédiatement (la case paraît blanche/neutre). */
.bn-grid-number.bn-removing {
    background: #fff;
    color: #ccc;
    border-color: #eee;
    box-shadow: none;
    cursor: wait;
    pointer-events: none;
    opacity: 0.5;
    transform: none;
}

.bn-grid-number.bn-disabled {
    background: #f5f5f5;
    color: #bbb;
    cursor: not-allowed;
}

/* --- Légende --- */

.bn-grid-legend {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    font-size: 13px;
    color: #666;
    flex-wrap: wrap;
}

.bn-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bn-legend-available,
.bn-legend-taken,
.bn-legend-mine {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.bn-legend-available {
    background: #fff;
}

.bn-legend-taken {
    background: #e8e8e8;
}

.bn-legend-mine {
    background: #af8354;
    border-color: #96703f;
}

/* --- Loading --- */

.bn-loading {
    text-align: center;
    padding: 30px;
    color: #af8354;
    font-size: 14px;
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 767px) {
    .bn-input-section {
        flex-direction: column;
    }

    .bn-input-group {
        min-width: 100%;
    }

    .bn-btn-grid {
        justify-content: center;
    }

    .bn-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
    }

    .bn-grid-number {
        font-size: 11px;
    }

    .bn-modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .bn-pagination {
        gap: 3px;
    }

    .bn-page-btn {
        font-size: 11px;
        padding: 4px 6px;
    }

    .bn-grid-legend {
        gap: 10px;
    }
}
