/**
 * STYLES CSS POUR LE SYSTÈME DE PANIER UNIFIÉ
 * Couleurs cohérentes avec le thème jaune (#fbbf24)
 */

/* ===== ANIMATION DU PANIER ===== */
@keyframes cartBounce {
    0%, 100% { 
        transform: scale(1); 
    }
    25% { 
        transform: scale(1.1) rotate(-5deg); 
    }
    50% { 
        transform: scale(1.2); 
    }
    75% { 
        transform: scale(1.1) rotate(5deg); 
    }
}

.cart-bounce {
    animation: cartBounce 0.5s ease-in-out;
}

/* ===== COMPTEUR DU PANIER ===== */
#cartCount {
    background-color: #fbbf24 !important;
    color: #1f2937 !important;
    font-weight: 700;
    font-size: 0.75rem;
    min-width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

#cartCount:not(.hidden) {
    animation: pulse 0.3s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes cartUpdated {
    0% { transform: scale(1); background-color: #fbbf24; }
    50% { transform: scale(1.3); background-color: #f59e0b; }
    100% { transform: scale(1); background-color: #fbbf24; }
}

.cart-updated {
    animation: cartUpdated 0.4s ease-in-out;
}

/* ===== BOUTON PANIER DANS LE HEADER ===== */
#cartToggle {
    position: relative;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    background-color: transparent;
    border: none;
    cursor: pointer;
}

#cartToggle:hover {
    background-color: #f3f4f6;
    transform: translateY(-1px);
}

#cartToggle:active {
    transform: translateY(0);
}

#cartToggle i {
    font-size: 1.125rem;
    color: #374151;
    transition: color 0.2s ease;
}

#cartToggle:hover i {
    color: #fbbf24;
}

/* ===== SIDEBAR DU PANIER ===== */
#cartSidebar {
    width: 24rem;
    max-width: 90vw;
    background: white;
    box-shadow: -10px 0 25px rgba(0, 0, 0, 0.1);
    z-index: 50;
    transition: transform 0.3s ease-in-out;
}

#cartSidebar.translate-x-full {
    transform: translateX(100%);
}

/* Header du panier */
#cartSidebar .cart-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1f2937;
}

#cartSidebar .cart-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

#closeCart {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#closeCart:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

#closeCart i {
    font-size: 1.25rem;
    color: #1f2937;
}

/* ===== CONTENU DU PANIER ===== */
#cartItems {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    max-height: calc(100vh - 200px);
}

/* Scrollbar personnalisée */
#cartItems::-webkit-scrollbar {
    width: 6px;
}

#cartItems::-webkit-scrollbar-track {
    background: #f1f5f9;
}

#cartItems::-webkit-scrollbar-thumb {
    background: #fbbf24;
    border-radius: 3px;
}

#cartItems::-webkit-scrollbar-thumb:hover {
    background: #f59e0b;
}

/* ===== ARTICLES DU PANIER ===== */
.cart-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.2s ease;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item:hover {
    background: #fefce8;
    border-radius: 0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.cart-item img {
    width: 4rem;
    height: 4rem;
    object-fit: cover;
    border-radius: 0.5rem;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    transition: border-color 0.2s ease;
}

.cart-item:hover img {
    border-color: #fbbf24;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-price {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

/* ===== CONTRÔLES DE QUANTITÉ ===== */
.cart-quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.cart-quantity-btn {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.cart-quantity-btn:hover {
    background: #fbbf24;
    border-color: #f59e0b;
    color: #1f2937;
    transform: scale(1.1);
}

.cart-quantity-btn:active {
    transform: scale(0.95);
}

.cart-quantity-display {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1f2937;
    min-width: 1.5rem;
    text-align: center;
}

/* ===== BOUTON SUPPRIMER ===== */
.cart-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    color: #ef4444;
}

.cart-remove-btn:hover {
    background: #fef2f2;
    color: #dc2626;
    transform: scale(1.1);
}

/* ===== TOTAL DU PANIER ===== */
.cart-footer {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}

.cart-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.cart-total-label {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

#cartTotal {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fbbf24 !important;
}

/* ===== BOUTON CHECKOUT ===== */
#checkoutBtn {
    width: 100%;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1f2937;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(251, 191, 36, 0.2);
}

#checkoutBtn:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(251, 191, 36, 0.3);
}

#checkoutBtn:active {
    transform: translateY(0);
}

#checkoutBtn:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== OVERLAY ===== */
#cartOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    transition: opacity 0.3s ease;
}

#cartOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ===== ÉTAT VIDE ===== */
.cart-empty-state {
    text-align: center;
    padding: 2rem 0;
}

.cart-empty-state i {
    font-size: 3rem;
    color: #d1d5db;
    margin-bottom: 1rem;
}

.cart-empty-state p {
    color: #6b7280;
    margin-bottom: 1rem;
}

.cart-empty-state a {
    color: #fbbf24;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cart-empty-state a:hover {
    color: #f59e0b;
}

/* ===== BOUTONS "AJOUTER AU PANIER" ===== */
[data-add-to-cart] {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

[data-add-to-cart].in-cart {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
    border-color: #10b981 !important;
}

[data-add-to-cart].in-cart:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
}

/* Animation d'ajout au panier */
[data-add-to-cart].adding {
    transform: scale(0.95);
    opacity: 0.8;
}

/* ===== ANIMATIONS D'ENTRÉE ===== */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#cartSidebar:not(.translate-x-full) {
    animation: slideInRight 0.3s ease-out;
}

#cartOverlay:not(.hidden) {
    animation: fadeIn 0.3s ease-out;
}

/* ===== INDICATEURS DE CHARGEMENT ===== */
.cart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #6b7280;
}

.cart-loading i {
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== BADGES DE STOCK ===== */
.stock-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.stock-badge.in-stock {
    background: #d1fae5;
    color: #065f46;
}

.stock-badge.low-stock {
    background: #fef3c7;
    color: #92400e;
}

.stock-badge.out-of-stock {
    background: #fee2e2;
    color: #991b1b;
}

/* ===== EFFETS DE HOVER AVANCÉS ===== */
.cart-item-actions {
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s ease;
}

.cart-item:hover .cart-item-actions {
    opacity: 1;
    transform: translateX(0);
}

/* ===== NOTIFICATIONS SPÉCIFIQUES AU PANIER ===== */
.cart-notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 60;
    max-width: 20rem;
    animation: slideInFromRight 0.3s ease-out;
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.cart-notification.success {
    border-left: 4px solid #10b981;
}

.cart-notification.error {
    border-left: 4px solid #ef4444;
}

.cart-notification.info {
    border-left: 4px solid #3b82f6;
}

/* ===== ACCESSIBILITÉ ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible pour l'accessibilité */
button:focus-visible,
[data-add-to-cart]:focus-visible {
    outline: 2px solid #fbbf24;
    outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
    #cartSidebar,
    #cartOverlay,
    #cartToggle {
        display: none !important;
    }
}

/* ===== RESPONSIVE DESIGN (MOBILE) ===== */
@media (max-width: 768px) {
    #cartSidebar {
        width: 100vw; /* Prendre toute la largeur sur mobile */
        max-width: 100vw; /* S'assurer que ça prend toute la largeur */
        height: 100%;
        max-height: 100vh;
    }

    #cartItems {
        /* Ajuster la hauteur pour laisser de la place au header et footer */
        max-height: calc(100vh - 150px); 
    }

    #cartSidebar .cart-header,
    .cart-footer {
        padding: 1rem; /* Réduire le padding sur mobile */
    }

    #cartSidebar .cart-header h2 {
        font-size: 1rem; /* Réduire la taille du titre */
    }

    .cart-item {
        gap: 0.75rem; /* Réduire l'espace entre les éléments */
        padding: 0.75rem 0;
    }

    .cart-item img {
        width: 3.5rem; /* Réduire la taille de l'image */
        height: 3.5rem;
    }

    .cart-item-name,
    .cart-item-price {
        font-size: 0.8rem; /* Réduire la taille de la police */
    }
    
    .cart-total-label {
        font-size: 1rem;
    }

    #cartTotal {
        font-size: 1.125rem;
    }

    #checkoutBtn {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
    }
}