/**
 * Cart Sidebar Styles
 * Panier latéral professionnel à droite de l'écran
 */

/* Cart Icon Button */
.cart-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 1rem;
    text-decoration: none;
    outline: none;
}

.cart-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Bouton panier avec articles (rouge) */
.cart-icon-btn.has-items {
    background: rgba(220, 53, 69, 0.9);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.cart-icon-btn.has-items:hover {
    background: rgba(220, 53, 69, 1);
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.5);
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: none; /* Caché par défaut, affiché via JavaScript */
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
    z-index: 10;
}

.cart-badge:not([style*="display: none"]) {
    display: flex !important;
}

/* Cart Overlay */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Cart Sidebar */
.cart-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100%;
    max-width: 450px;
    height: 100vh;
    background: white;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.2);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.cart-sidebar.active {
    left: 0;
    animation: slideInLeft 0.4s ease-out;
}

/* Sidebar réduite */
.cart-sidebar.minimized {
    max-width: 100px;
}

.cart-sidebar.minimized .cart-sidebar-header {
    padding: 1rem 0.75rem;
    flex-direction: column;
    gap: 0.5rem;
}

.cart-sidebar.minimized .cart-sidebar-header h2 {
    display: none;
}

.cart-sidebar.minimized .cart-header-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
}

.cart-sidebar.minimized .cart-sidebar-body {
    display: none;
}

.cart-sidebar.minimized .cart-sidebar-footer {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    gap: 0.75rem;
    border-top: 1px solid #e9ecef;
}

.cart-sidebar.minimized .cart-total {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    width: 100%;
}

.cart-sidebar.minimized .cart-total-label {
    font-size: 0.7rem;
    color: #666;
}

.cart-sidebar.minimized .cart-total-amount {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ca8a04;
}

.cart-sidebar.minimized .btn-checkout {
    width: 100%;
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-sidebar.minimized .btn-checkout span {
    display: none;
}

.cart-sidebar.minimized .btn-checkout svg {
    width: 18px;
    height: 18px;
    margin: 0;
}

.cart-sidebar.minimized .cart-minimize-btn svg {
    transform: rotate(180deg);
}

@keyframes slideInLeft {
    from {
        left: -100%;
        opacity: 0;
    }
    to {
        left: 0;
        opacity: 1;
    }
}

/* Cart Header */
.cart-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    background: linear-gradient(135deg, #ca8a04 0%, #eab308 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.cart-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-sidebar-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.cart-minimize-btn,
.cart-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10001;
    pointer-events: auto;
    flex-shrink: 0;
}

.cart-minimize-btn:hover,
.cart-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.cart-close-btn:hover {
    transform: rotate(90deg) scale(1.1);
}

.cart-minimize-btn:active,
.cart-close-btn:active {
    transform: scale(0.95);
}

.cart-close-btn:active {
    transform: rotate(90deg) scale(0.95);
}

.cart-minimize-btn svg,
.cart-close-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
    pointer-events: none;
}

/* Cart Body */
.cart-sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: #f8f9fa;
    min-height: 0; /* Important pour le scroll */
}

/* Cart Empty */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    min-height: 300px;
}

.cart-empty-icon {
    color: #ccc;
    margin-bottom: 1.5rem;
}

.cart-empty p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 1.5rem;
}

/* Cart Items */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 1rem;
}

.cart-items:empty::before {
    content: "جاري التحميل...";
    display: block;
    text-align: center;
    color: #999;
    padding: 2rem;
    font-style: italic;
}

.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    animation: fadeInUp 0.3s ease-out;
    margin-bottom: 0.5rem;
}

.cart-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

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

.cart-item-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.cart-item-image:hover {
    border-color: #eab308;
    transform: scale(1.05);
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.cart-item:hover .cart-item-image img {
    transform: scale(1.1);
}

.cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cart-item-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8em;
}

.cart-item-price {
    font-size: 0.9rem;
    color: #ca8a04;
    font-weight: 600;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    color: #333;
}

.qty-btn:hover {
    background: #ca8a04;
    color: white;
    border-color: #eab308;
}

.qty-value {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    color: #333;
}

.cart-item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.5rem;
}

.cart-item-remove {
    background: transparent;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-remove:hover {
    background: #fee;
    transform: scale(1.1);
}

.cart-item-total {
    font-size: 1rem;
    font-weight: 700;
    color: #ca8a04;
}

/* Cart Footer */
.cart-sidebar-footer {
    padding: 1.5rem;
    background: white;
    border-top: 2px solid #f0f0f0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.cart-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    margin-bottom: 1rem;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.cart-total-label {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.cart-total-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ca8a04;
}

.btn-checkout {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #ca8a04 0%, #eab308 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-checkout:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(234, 179, 8, 0.4);
}

/* Cart Notifications */
.cart-notification {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 10000;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    max-width: 350px;
}

.cart-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.cart-notification-success {
    border-right: 4px solid #ca8a04;
}

.cart-notification-error {
    border-right: 4px solid #dc3545;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.notification-content svg {
    flex-shrink: 0;
}

.cart-notification-success .notification-content svg {
    color: #ca8a04;
}

.cart-notification-error .notification-content svg {
    color: #dc3545;
}

.notification-content span {
    font-weight: 500;
    color: #333;
}

/* Scrollbar */
.cart-sidebar-body::-webkit-scrollbar {
    width: 6px;
}

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

.cart-sidebar-body::-webkit-scrollbar-thumb {
    background: #ca8a04;
    border-radius: 3px;
}

.cart-sidebar-body::-webkit-scrollbar-thumb:hover {
    background: #a16207;
}

/* Responsive */
@media (max-width: 768px) {
    .cart-sidebar {
        max-width: 100%;
    }
    
    .cart-item {
        flex-direction: column;
    }
    
    .cart-item-image {
        width: 100%;
        height: 150px;
    }
    
    .cart-item-actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    
    .cart-notification {
        right: 10px;
        left: 10px;
        max-width: none;
        transform: translateY(-100px);
    }
    
    .cart-notification.show {
        transform: translateY(0);
    }
}

/* Animation */
@keyframes slideInLeft {
    from {
        left: -100%;
    }
    to {
        left: 0;
    }
}

@keyframes slideOutLeft {
    from {
        left: 0;
    }
    to {
        left: -100%;
    }
}


/* ===== Free Shipping box in cart ===== */
.free-ship-box{
    margin: 10px 0 12px;
    padding: 10px 12px;
    border-radius: 16px;
    background: linear-gradient(90deg, rgba(31,168,85,0.14), rgba(31,107,68,0.10));
    border: 1px solid rgba(31,168,85,0.22);
}
.free-ship-row{
    display:flex;
    align-items:center;
    gap:8px;
    color: #422006;
    font-weight: 900;
}
.free-ship-mini-icon{font-size:16px;}
.free-ship-mini-text{font-size:13px; font-weight:900;}
.free-ship-mini-badge{
    margin-inline-start:auto;
    font-size:12px;
    font-weight:900;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(31,168,85,0.16);
    border: 1px solid rgba(31,168,85,0.22);
    white-space:nowrap;
}
.free-ship-mini-progress{
    margin-top:8px;
    height: 10px;
    width:100%;
    border-radius:999px;
    background: rgba(0,0,0,0.06);
    overflow:hidden;
}
.free-ship-mini-progress-bar{
    height:100%;
    width:0%;
    border-radius:999px;
    background: linear-gradient(90deg, rgba(31,168,85,0.90), rgba(31,168,85,0.35));
    animation: progressShimmer 1.8s linear infinite;
}
