/**
 * Cart Sidebar Styles
 * Modern sliding cart with animations
 */

/* Sidebar Container */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
}

.cart-sidebar.active {
    pointer-events: all;
}

/* Overlay */
.cart-sidebar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.cart-sidebar.active .cart-sidebar-overlay {
    opacity: 1;
    pointer-events: all;
}

/* Sidebar Content - Fixed Footer Layout */
.cart-sidebar-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 450px;
    max-width: 100%;
    height: 100%; /* Restore height: 100% which works better in fixed parent */
    /* Remove max-height constraint which might cause issues */
    background: #ffffff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

/* Body - Scrollable Items */
.cart-sidebar-body {
    flex: 1;
    padding: 16px 24px;
    overflow-y: scroll !important; /* Force scroll */
    -webkit-overflow-scrolling: touch; /* iOS Momentum Scrolling */
    /* Custom scrollbar for the body */
    scrollbar-width: thin; 
    scrollbar-color: #bdbdbd #f5f5f5;
    /* Ensure content is not cut off at bottom */
    padding-bottom: 20px;
    min-height: 0; /* Crucial for flex child scrolling */
}

/* Scrollbar styles move to body */
.cart-sidebar-body::-webkit-scrollbar {
    width: 8px;
    display: block; 
}

.cart-sidebar-body::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.cart-sidebar-body::-webkit-scrollbar-thumb {
    background: #bdbdbd; 
    border-radius: 4px;
    transition: background 0.2s ease;
}

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

/* ... existing styles ... */

/* Webkit browsers (Chrome, Safari, Edge) - Custom scrollbar */
.cart-sidebar-content::-webkit-scrollbar {
    width: 8px;
    display: block; /* Force display */
}

.cart-sidebar-content::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.cart-sidebar-content::-webkit-scrollbar-thumb {
    background: #bdbdbd; /* Gray color */
    border-radius: 4px;
    transition: background 0.2s ease;
}

.cart-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #9e9e9e; /* Darker gray on hover */
}

.cart-sidebar.active .cart-sidebar-content {
    transform: translateX(0);
}

/* Header */
.cart-sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    flex-shrink: 0; /* Never shrink header */
}

/* Footer */
.cart-sidebar-footer {
    border-top: 1px solid #e0e0e0;
    padding: 20px 24px;
    background: #ffffff;
    flex-shrink: 0; /* Never shrink footer */
    z-index: 10;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05); 
}

.cart-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-header-title > i {
    font-size: 24px;
    color: #B2201D;
}

.cart-header-title h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
}

.cart-item-count {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.cart-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.cart-close-btn:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

.cart-close-btn i {
    font-size: 18px;
    color: #666;
}

/* Alert Section */
.cart-alert {
    padding: 16px 24px;
    background: #ffebee;
    border-left: 4px solid #c62828;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.cart-alert i {
    font-size: 20px;
    color: #c62828;
    margin-top: 2px;
}

.cart-alert strong {
    display: block;
    color: #c62828;
    font-size: 14px;
    margin-bottom: 4px;
}

.cart-alert p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

/* Body - Scrollable Items */
.cart-sidebar-body {
    flex: 1;
    padding: 16px 24px;
    overflow-y: visible; /* Let parent handle scroll */
}

.cart-items-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Empty State */
.cart-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.cart-empty-state i {
    font-size: 64px;
    color: #e0e0e0;
    margin-bottom: 16px;
}

.cart-empty-state h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #666;
}

.cart-empty-state p {
    margin: 0;
    font-size: 14px;
    color: #999;
}

/* Cart Item - Compact Layout like Original */
.cart-item {
    background: #ffffff;
    border-radius: 0;
    padding: 10px 12px; /* Reduced padding */
    display: flex;
    align-items: flex-start; 
    gap: 10px; /* Reduced gap */
    position: relative;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 0;
    z-index: 1;
}

/* Fix overflow clipping */
.cart-item {
    overflow: visible; 
    padding-right: 36px; /* Reduced right padding, still enough for delete btn */
}

.cart-item:hover {
    background: #fafafa;
}

.cart-item-image {
    width: 45px; /* Reduced size */
    height: 45px; /* Reduced size */
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

/* ... existing styles ... */

.cart-item-name {
    font-size: 13px; /* Slightly smaller */
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 2px 0;
    line-height: 1.2;
}

.cart-item-size {
    font-size: 11px; /* Smaller size */
    color: #666;
    margin: 0 0 4px 0; /* Reduced margin */
}

.cart-item-ingredients {
    margin: 2px 0 6px 0; /* Reduced margin */
}

.ingredient-tag {
    display: inline-block;
    font-size: 10px; /* Smaller font */
    color: #666;
    background: #f8f9fa;
    padding: 1px 5px; /* Reduced padding */
    border-radius: 8px;
    margin: 1px 1px; /* Tighter spacing */
    border: 1px solid #e9ecef;
}

.ingredient-tag .free-ingredient {
    color: #28a745;
    font-weight: 500;
}

.cart-item-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px; /* Slight separation */
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 6px; /* Reduced gap */
}

.qty-btn {
    width: 22px; /* Smaller button */
    height: 22px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #666;
    transition: all 0.2s ease;
}

.qty-btn:hover {
    background: #f8f9fa;
    border-color: #B2201D;
    color: #B2201D;
}

.quantity {
    font-weight: 600;
    min-width: 16px; /* Compact width */
    text-align: center;
    font-size: 13px;
    color: #1a1a1a;
}

.cart-item-price {
    font-size: 13px; /* Slightly smaller */
    font-weight: 700;
    color: #B2201D;
}

.cart-item-remove {
    /* ... positioning remains static from previous fix ... */
    position: static !important;
    transform: none !important;
    width: 24px !important; /* Smaller remove button */
    height: 24px !important;
    border: none;
    background: #ff4757 !important;
    color: white !important;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease !important;
    opacity: 1 !important;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15); /* Lighter shadow */
    
    flex-shrink: 0;
    align-self: center; 
    margin-left: auto;
}

.cart-item:hover {
    background: #fafafa;
}

.cart-item-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

/* ... existing styles ... */

.cart-item-remove {
    position: static !important; /* Force static positioning (flex item) */
    transform: none !important;
    width: 28px !important;
    height: 28px !important;
    border: none;
    background: #ff4757 !important;
    color: white !important;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease !important;
    opacity: 1 !important;
    z-index: 2;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    
    /* Flex item properties */
    flex-shrink: 0;
    align-self: center; /* Vertically center the button */
    margin-left: auto; /* Push slightly if needed, but gap handles it */
}

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

/* Fix overflow clipping */
.cart-item {
    overflow: visible; /* Allow elements to overflow if needed, but safer to padding */
    padding-right: 40px; /* Make space for the delete button */
}

.cart-item:hover {
    background: #fafafa;
}

.cart-item-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.cart-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 2px 0;
    line-height: 1.2;
}

.cart-item-size {
    font-size: 12px;
    color: #666;
    margin: 0 0 8px 0;
}

.cart-item-ingredients {
    margin: 4px 0 8px 0;
}

.ingredient-tag {
    display: inline-block;
    font-size: 11px;
    color: #666;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 10px;
    margin: 1px 2px;
    border: 1px solid #e9ecef;
}

.ingredient-tag .free-ingredient {
    color: #28a745;
    font-weight: 500;
}

.cart-item-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.qty-btn:hover {
    background: #f8f9fa;
    border-color: #B2201D;
    color: #B2201D;
}

.quantity {
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    font-size: 14px;
    color: #1a1a1a;
}

.cart-item-price {
    font-size: 14px;
    font-weight: 700;
    color: #B2201D;
}

.cart-item-remove {
    position: absolute;
    top: 50%; /* Center vertically */
    right: 10px; /* Fixed distance from right */
    transform: translateY(-50%); /* Adjust for perfect center */
    width: 28px !important;
    height: 28px !important;
    border: none;
    background: #ff4757 !important;
    color: white !important;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 1 !important;
    z-index: 10; /* Higher than item content */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.cart-item-remove:hover {
    background: #ff3742 !important;
    transform: translateY(-50%) scale(1.1); /* Keep vertical centering on hover */
}

/* Gift Section */
.cart-gift-section {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.gift-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.gift-header i {
    font-size: 20px;
    color: #2e7d32;
}

.gift-header strong {
    font-size: 14px;
    color: #2e7d32;
}

.gift-subtitle {
    font-size: 12px;
    color: #666;
    margin: 0 0 12px 0;
}

.gift-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gift-option {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gift-option:hover {
    border-color: #2e7d32;
    background: #f9fdf9;
}

.gift-option input[type="radio"] {
    margin: 0;
}

.gift-option span:nth-child(2) {
    flex: 1;
    font-size: 13px;
    color: #1a1a1a;
}

.gift-badge {
    background: #2e7d32;
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

/* Gift Upsell Message */
.gift-upsell {
    margin-top: 12px;
    padding: 12px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 8px;
    font-size: 13px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gift-upsell::before {
    content: '💡';
    font-size: 18px;
}

.gift-upsell-only {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe8a1 100%);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 2px solid #ffc107;
}

.gift-upsell-only i {
    font-size: 24px;
    color: #ffc107;
    margin-bottom: 8px;
    display: block;
}

.gift-upsell-only p {
    margin: 0;
    font-size: 14px;
    color: #856404;
    font-weight: 600;
}

/* Footer */
.cart-sidebar-footer {
    border-top: 1px solid #e0e0e0;
    padding: 20px 24px;
    background: #ffffff;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05); /* Subtle shadow to indicate scroll */
}

.cart-totals {
    margin-top: 20px;
    margin-bottom: 20px;
    padding-top: 15px;
    border-top: 1px dashed #e0e0e0;
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    color: #666;
}

.cart-total-row.cart-total-final {
    border-top: 2px solid #e0e0e0;
    margin-top: 8px;
    padding-top: 12px;
}

.cart-total-row.cart-total-final strong {
    font-size: 16px;
    color: #1a1a1a;
}

.cart-total-amount {
    font-size: 24px !important;
    color: #B2201D !important;
}

/* Actions */
.cart-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-checkout {
    width: 100%;
    padding: 16px;
    background: #2e7d32;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-checkout:hover {
    background: #1b5e20;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.btn-checkout:disabled {
    background: #bdbdbd;
    cursor: not-allowed;
    transform: none;
}

.checkout-info {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin: 0;
}

.btn-continue-shopping {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: #666;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-continue-shopping:hover {
    border-color: #B2201D;
    color: #B2201D;
}

/* Responsive */
@media (max-width: 768px) {
    .cart-sidebar-content {
        width: 100%;
        max-width: 100%;
    }
    
    .cart-sidebar-header {
        padding: 16px 20px;
    }
    
    .cart-sidebar-body {
        padding: 12px 20px;
    }
    
    .cart-sidebar-footer {
        padding: 16px 20px;
    }
    
    .cart-item {
        padding: 12px;
    }
    
    .cart-item-image {
        width: 70px;
        height: 70px;
    }
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

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

/* Loading State */
.cart-loading {
    text-align: center;
    padding: 40px 20px;
}

.cart-loading i {
    font-size: 32px;
    color: #B2201D;
    animation: spin 1s linear infinite;
}

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

/* Enhanced Gift Section Styles - Design doux */
#cartGiftSection {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    color: #495057;
    position: relative;
}

#cartGiftSection::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #e9ecef 0%, #6c757d 50%, #e9ecef 100%);
    border-radius: 8px 8px 0 0;
}

#cartGiftSection .gift-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    position: relative;
    color: #495057;
}

#cartGiftSection .gift-header.congratulations {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 15px;
}

#cartGiftSection .gift-subtitle {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 12px;
    position: relative;
}

#cartGiftSection .gift-options {
    position: relative;
}

#cartGiftSection .gift-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 6px;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
}

#cartGiftSection .gift-option:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

#cartGiftSection .gift-option input[type="radio"] {
    margin: 0;
    accent-color: #6c757d;
}

#cartGiftSection .gift-option .gift-icon {
    font-size: 16px;
    color: #6c757d;
}

#cartGiftSection .gift-option .gift-details {
    flex: 1;
}

#cartGiftSection .gift-option .gift-name {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 13px;
    color: #495057;
}

#cartGiftSection .gift-option .gift-description {
    font-size: 11px;
    color: #6c757d;
}

#cartGiftSection .gift-badge {
    background: #e9ecef;
    color: #495057;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
}

/* Enhanced Upsell Styles - Design doux */
.gift-upsell-enhanced {
    position: relative;
    background: #ffffff;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
}

.gift-upsell-enhanced.urgent {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
}

.gift-upsell-enhanced.close {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 8px;
    margin-top: 10px;
}

.upsell-message {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #495057;
}

.upsell-icon {
    font-size: 16px;
    color: #6c757d;
}

#cartGiftSection .progress-container {
    margin-top: 8px;
}

#cartGiftSection .progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 4px;
    color: #6c757d;
}

#cartGiftSection .progress-bar {
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

#cartGiftSection .progress-fill {
    height: 100%;
    background: #6c757d;
    border-radius: 3px;
    transition: width 0.8s ease-out;
    position: relative;
}

#cartGiftSection .progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: progress-shine 3s ease-in-out infinite;
}

/* Override legacy styles for enhanced version - Style doux */
#cartGiftSection .gift-upsell, 
#cartGiftSection .gift-upsell-only {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 13px;
    position: relative;
    color: #495057;
}

#cartGiftSection .gift-upsell.urgent, 
#cartGiftSection .gift-upsell-only.urgent {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

#cartGiftSection .gift-upsell-only {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Enhanced Animations - Versions douces */
@keyframes shimmer {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

@keyframes urgent-pulse {
    /* Animation supprimée pour un style plus doux */
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}