/* ============================================
   DRAWER PANIER - BOTTOM SHEET SUR MOBILE
   ============================================ */

/* Desktop - Drawer classique sur le côté */
@media (min-width: 769px) {
    .drawer-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 9999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0s 0.3s;
    }

    .drawer-overlay.active {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.3s ease, visibility 0s 0s;
    }

    .drawer {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 450px;
        max-width: 90vw;
        background: white;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
        z-index: 10000;
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
    }

    .drawer.active {
        transform: translateX(0);
    }

    /* Styles Desktop pour les items */
    .cart-item {
        display: flex;
        gap: 12px;
        padding: 14px;
        background: #ffffff;
        border: 1px solid rgba(0, 0, 0, 0.06);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        transition: all 0.3s ease;
    }

    .cart-item:hover {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.1);
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    }

    .cart-summary {
        padding: 18px;
        background: #f8f9fa;
        border: 1px solid rgba(0, 0, 0, 0.06);
        border-radius: 12px;
        margin-bottom: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }

    .drawer-header {
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .drawer-footer {
        border-top: 1px solid rgba(0, 0, 0, 0.08);
    }

    .drawer-header .modal-close {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(239, 68, 68, 0.08);
        border: none;
        border-radius: 8px;
        color: #ef4444;
        font-size: 20px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .drawer-header .modal-close:hover {
        background: rgba(239, 68, 68, 0.15);
        color: #dc2626;
    }

    .empty-icon {
        color: #B8461F;
        opacity: 0.3;
    }

    /* Bouton Commander sur Desktop - ORANGE/MARRON */
    .drawer-footer .btn {
        width: 100%;
        padding: 14px 20px;
        background: linear-gradient(135deg, #B8461F 0%, #8B2F0F 100%);
        color: white;
        border: none;
        border-radius: 12px;
        font-size: 16px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        box-shadow: 0 4px 12px rgba(184, 70, 31, 0.3);
    }

    .drawer-footer .btn:hover:not(:disabled):not(.disabled) {
        background: linear-gradient(135deg, #9a3819 0%, #7d2e14 100%);
        box-shadow: 0 6px 16px rgba(184, 70, 31, 0.4);
        transform: translateY(-2px);
    }

    .drawer-footer .btn:active:not(:disabled):not(.disabled) {
        background: linear-gradient(135deg, #7d2e14 0%, #6a2511 100%);
        transform: scale(0.98) translateY(0);
        box-shadow: 0 2px 8px rgba(184, 70, 31, 0.3);
    }

    /* Bouton désactivé sur Desktop */
    .drawer-footer .btn.disabled,
    .drawer-footer .btn:disabled {
        background: #d1d5db !important;
        color: #9ca3af !important;
        cursor: not-allowed !important;
        box-shadow: none !important;
        pointer-events: none !important;
        transform: none !important;
    }

    /* Cacher le summary quand vide sur Desktop */
    .cart-summary:empty,
    .cart-summary[style*="display: none"] {
        display: none !important;
    }
}

/* Mobile - Bottom Sheet comme les autres modales */
@media (max-width: 768px) {

    /* Overlay */
    .drawer-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 9999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0s 0.3s;
    }

    .drawer-overlay.active {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.3s ease, visibility 0s 0s;
    }

    /* Drawer en bottom sheet */
    .drawer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 92vh;
        max-height: 92vh;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
        z-index: 10000;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.4s;
        visibility: hidden;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .drawer.active {
        transform: translateY(0);
        visibility: visible;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0s;
    }

    /* Header du drawer */
    .drawer-header {
        padding: 24px 20px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        position: sticky;
        top: 0;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
    }

    .drawer-title {
        font-size: 18px;
        font-weight: 700;
        color: #1a1a1a;
        letter-spacing: -0.3px;
        margin: 0;
    }

    /* Bouton fermer */
    .drawer-header .modal-close {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(239, 68, 68, 0.08);
        border: none;
        border-radius: 8px;
        color: #ef4444;
        font-size: 20px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }

    .drawer-header .modal-close:active {
        background: rgba(239, 68, 68, 0.15);
        color: #dc2626;
        transform: scale(0.95);
    }

    /* Body du drawer - scrollable */
    /* Body du drawer - scrollable */
    /* Body du drawer - scrollable */
    /* Body du drawer - scrollable */
    .drawer-body {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        padding-bottom: 260px;
        /* Fallback increased */
    }

    /* Encadré gris solide en bas - uniquement quand le panier a des items */
    /* Encadré gris solide en bas - uniquement quand le panier a des items */
    /* Encadré gris solide en bas - uniquement quand le panier a des items */
    /* Encadré gris solide en bas - uniquement quand le panier a des items */
    .drawer::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 250px;
        /* Base height for 35px button + summary */
        background: #e8e8e8;
        z-index: 10000;
        pointer-events: none;
        display: none;
    }

    /* Afficher le fond gris seulement quand il y a des items */
    .drawer.has-items::after {
        display: block;
    }

    /* Footer du drawer */
    /* Footer du drawer */
    /* Footer du drawer */
    /* Footer du drawer - Container Fixe */
    .drawer-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        background: #f8f9fa;
        /* Fond solide pour tout le bas */
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        gap: 12px;
        z-index: 10002;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    }

    /* Items du panier */
    .cart-items {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .cart-item {
        display: flex;
        gap: 12px;
        padding: 12px;
        /* Reduced from 14px */
        background: #ffffff;
        border: 1px solid rgba(0, 0, 0, 0.06);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        transition: all 0.3s ease;
    }

    .cart-item:active {
        background: #ffffff;
        border-color: rgba(0, 0, 0, 0.1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    }

    .cart-item-image {
        width: 70px;
        /* Reduced from 80px */
        height: 70px;
        border-radius: 8px;
        object-fit: cover;
        flex-shrink: 0;
    }

    .cart-item-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .cart-item-name {
        font-size: 14px;
        font-weight: 600;
        color: #1a1a1a;
        line-height: 1.3;
    }

    .cart-item-price {
        font-size: 15px;
        /* Reduced from 16px */
        font-weight: 700;
        color: #1a1a1a;
    }

    .cart-item-variant {
        font-size: 12px;
        color: #666;
    }

    .cart-item-quantity {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-top: 4px;
    }

    .qty-btn {
        width: 26px;
        /* Reduced from 28px */
        height: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(184, 70, 31, 0.08);
        border: none;
        border-radius: 6px;
        color: #B8461F;
        font-size: 12px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }

    .qty-btn:active {
        background: rgba(184, 70, 31, 0.15);
        transform: scale(0.95);
    }

    .qty-value {
        font-size: 14px;
        font-weight: 600;
        color: #1a1a1a;
        min-width: 24px;
        text-align: center;
    }

    .cart-item-remove {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(239, 68, 68, 0.08);
        border: none;
        border-radius: 8px;
        color: #ef4444;
        font-size: 14px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
        flex-shrink: 0;
    }

    .cart-item-remove:active {
        background: rgba(239, 68, 68, 0.15);
        transform: scale(0.95);
    }

    /* État vide */
    .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px 20px;
        text-align: center;
    }

    .empty-icon {
        font-size: 64px;
        margin-bottom: 16px;
        color: #B8461F;
        opacity: 0.3;
    }

    .empty-title {
        font-size: 18px;
        font-weight: 700;
        color: #1a1a1a;
        margin-bottom: 8px;
    }

    .empty-text {
        font-size: 14px;
        color: #6b7280;
        line-height: 1.5;
    }

    /* Résumé du panier - caché quand vide */
    /* Résumé du panier - caché quand vide */
    /* Résumé du panier - caché quand vide */
    /* Résumé du panier - Dans le flux (plus de fixed) */
    .cart-summary {
        position: static;
        /* Remis dans le flux */
        width: 100%;
        margin: 0;
        padding: 0;
        background: transparent;
        border: none;
        display: flex;
        flex-direction: column;
        gap: 6px;
        box-shadow: none;
    }

    /* Cacher le summary quand vide */
    .cart-summary:empty {
        display: none !important;
    }

    .summary-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 14px;
        color: #666;
    }

    .summary-row.total {
        margin-top: 6px;
        padding-top: 10px;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        font-size: 18px;
        font-weight: 700;
        color: #1a1a1a;
    }

    .summary-label {
        font-weight: 500;
    }

    .summary-value {
        font-weight: 600;
        color: #1a1a1a;
    }

    /* Bouton commander */
    .drawer-footer .btn {
        width: 100%;
        padding: 16px;
        background: #B8461F;
        color: white;
        border: none;
        border-radius: 12px;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: transform 0.2s;
    }

    .drawer-footer .btn:active {
        transform: scale(0.98);
    }
}

/* Très petits écrans */
@media (max-width: 480px) {
    .drawer {
        height: 90vh;
        /* Un peu plus d'espace en haut */
        max-height: 94vh;
    }

    .drawer-header {
        padding: 16px 16px;
        /* Compact */
    }

    .drawer-title {
        font-size: 17px;
    }

    .drawer-body {
        /* Padding bottom géré par JS, valeur par défaut */
        padding: 12px;
        padding-bottom: 200px;
    }

    .cart-item {
        padding: 10px;
    }

    .cart-item-image {
        width: 64px;
        height: 64px;
    }

    .cart-item-name {
        font-size: 13px;
    }

    .cart-item-price {
        font-size: 14px;
    }

    .cart-summary {
        bottom: 80px;
        bottom: calc(80px + env(safe-area-inset-bottom));
        left: 6px;
        right: 6px;
        width: calc(100% - 12px);
        padding: 10px 14px;
    }
}

/* Empêcher le scroll du body quand le drawer est ouvert */
body.drawer-open {
    overflow: hidden;
}