/* ========================================
   PANIER CLICK & COLLECT - CSS UNIFIÉ
   Système localStorage - Compatible toutes pages
   ======================================== */

/* ===== CONTENEUR PRINCIPAL ===== */
.panier-container {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ===== BOUTON TOGGLE (MOBILE/DESKTOP) ===== */
.panier-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #a67c52;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    z-index: 999;
}

.panier-toggle:hover {
    background: #8b6a47;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.panier-icon {
    font-size: 1.5rem;
}

/* ===== BADGE COMPTEUR ===== */
.panier-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    min-width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid white;
}

.panier-badge:empty,
.panier-badge[style*="display: none"] {
    display: none !important;
}

/* ===== CONTENU DU PANIER ===== */
.panier-content {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -5px 0 20px rgba(0,0,0,0.3);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panier-content.active,
.panier-content.show {
    right: 0;
}

/* ===== HEADER DU PANIER ===== */
.panier-header {
    background: #a67c52;
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #8b6a47;
}

.panier-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.panier-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.panier-close:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== BODY DU PANIER ===== */
.panier-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* ===== PANIER VIDE ===== */
.panier-vide {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.panier-vide-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.panier-vide-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.panier-vide-subtext {
    font-size: 0.9rem;
    color: #999;
    margin: 0;
}

/* ===== ITEMS DU PANIER ===== */
.panier-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panier-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.panier-item:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

/* ===== INFO PRODUIT ===== */
.panier-item-info {
    margin-bottom: 1rem;
}

.panier-item-nom {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.panier-item-prix {
    font-size: 0.9rem;
    color: #a67c52;
    font-weight: 500;
}

.panier-item-options {
    margin-top: 0.5rem;
}

.panier-item-options small {
    display: block;
    color: #666;
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
}

/* ===== ACTIONS PRODUIT ===== */
.panier-item-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* ===== CONTRÔLES QUANTITÉ ===== */
.panier-item-quantite {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    border-radius: 6px;
    padding: 0.2rem;
    border: 1px solid #ddd;
}

.quantite-btn {
    background: #a67c52;
    color: white;
    border: none;
    width: 2rem;
    height: 2rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s ease;
}

.quantite-btn:hover {
    background: #8b6a47;
}

.quantite-value {
    min-width: 2rem;
    text-align: center;
    font-weight: 600;
    color: #333;
}

/* ===== SOUS-TOTAL ET SUPPRESSION ===== */
.panier-item-sous-total {
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

.panier-item-supprimer {
    background: transparent;
    color: #999;
    border: 1px solid #ddd;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.panier-item-supprimer:hover {
    color: #e74c3c;
    border-color: #e74c3c;
    background: #ffeaea;
}

/* ===== FOOTER DU PANIER ===== */
.panier-footer {
    background: #f8f9fa;
    border-top: 2px solid #e9ecef;
    padding: 1.5rem;
}

.panier-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ddd;
}

.panier-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-vider,
.btn-commander {
    flex: 1;
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    display: inline-block;
}

.btn-vider {
    background: #6c757d;
    color: white;
}

.btn-vider:hover {
    background: #5a6268;
}

.btn-commander {
    background: #28a745;
    color: white;
}

.btn-commander:hover {
    background: #218838;
    text-decoration: none;
    color: white;
}

/* ===== NOTIFICATIONS ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    z-index: 2000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background: #28a745;
}

.notification-error {
    background: #e74c3c;
}

.notification-info {
    background: #17a2b8;
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 768px) {
    .panier-content {
        width: 100vw;
        right: -100vw;
        height: 100vh;
        height: 100dvh; /* Hauteur dynamique pour Safari iOS */
        max-height: 100vh;
        max-height: 100dvh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        padding-bottom: env(safe-area-inset-bottom, 20px); /* Espace pour les barres iOS */
    }
    
    .panier-body {
        flex: 1;
        overflow-y: auto;
        padding-bottom: 1rem;
    }
    
    .panier-toggle {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
        bottom: 15px;
        right: 15px;
    }
    
    .panier-icon {
        font-size: 1.2rem;
    }
    
    .panier-badge {
        min-width: 1.2rem;
        height: 1.2rem;
        font-size: 0.7rem;
        top: -3px;
        right: -3px;
    }
    
    .panier-item-actions {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .panier-item-quantite {
        justify-content: center;
    }
    
    /* Assurer la visibilité des boutons d'action sur mobile */
    .panier-actions {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.5rem 0;
        justify-content: space-between;
        align-items: stretch;
    }
    
    .btn-vider,
    .btn-commander {
        flex: 1;
        width: auto;
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
        border-radius: 6px;
        height: 40px;
        min-height: 40px;
        max-height: 40px;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    
    .panier-footer {
        padding: 1rem 1rem 2rem 1rem; /* Padding bas augmenté pour Safari */
        border-top: 2px solid #ddd;
        background: white;
        flex-shrink: 0;
        position: relative;
        z-index: 10;
        margin-bottom: env(safe-area-inset-bottom, 0px); /* Marge pour les barres iOS */
    }
    
    .panier-total {
        margin-bottom: 1rem;
        font-size: 1.1rem;
        text-align: center;
    }
    
    /* S'assurer que les deux boutons sont visibles */
    .btn-vider {
        order: 1;
        margin-bottom: 0.5rem;
    }
    
    .btn-commander {
        order: 2;
        background: #28a745 !important;
        color: white !important;
        text-decoration: none !important;
        display: block !important;
        visibility: visible !important;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panier-item {
    animation: fadeIn 0.3s ease;
}

/* ===== ÉTATS SPÉCIAUX ===== */
.panier-content[style*="display: none"] .panier-footer {
    display: none !important;
}

/* ===== ACCESSIBILITÉ ===== */
.panier-toggle:focus,
.panier-close:focus,
.quantite-btn:focus,
.panier-item-supprimer:focus,
.btn-vider:focus,
.btn-commander:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* ===== SCROLLBAR PERSONNALISÉE ===== */
.panier-body::-webkit-scrollbar {
    width: 6px;
}

.panier-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.panier-body::-webkit-scrollbar-thumb {
    background: #a67c52;
    border-radius: 3px;
}

.panier-body::-webkit-scrollbar-thumb:hover {
    background: #8b6a47;
}
