/**
 * Modern Cart System Styles
 * Clean, responsive design with smooth animations
 */

/* Modern Cart Container */
.modern-cart {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modern-cart.open {
    pointer-events: all;
}

/* Cart Overlay */
.cart-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modern-cart.open .cart-overlay {
    opacity: 1;
}

/* Cart Sidebar */
.cart-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 450px;
    height: 100%;
    background: #ffffff;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modern-cart.open .cart-sidebar {
    transform: translateX(0);
}

/* Cart Header */
.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    color: white;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.2);
}

.cart-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.cart-title i {
    font-size: 1.5rem;
}

.cart-count-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 1.5rem;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.cart-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.cart-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.cart-close i {
    font-size: 1.25rem;
}

/* Cart Content */
.cart-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 200px !important;
}

/* Empty Cart State */
.cart-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #64748b;
}

.empty-icon {
    width: 4rem;
    height: 4rem;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.empty-icon i {
    font-size: 2rem;
    color: #94a3b8;
}

.cart-empty h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #475569;
}

.cart-empty p {
    margin-bottom: 2rem;
    color: #64748b;
}

.btn-browse-products {
    background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-browse-products:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.3);
}

/* Cart Items */
.cart-item {
    background: white !important;
    border-radius: 1rem !important;
    padding: 1rem !important;
    margin-bottom: 1rem !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05) !important;
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    gap: 1rem !important;
    align-items: center !important;
    animation: slideInRight 0.3s ease forwards !important;
    transition: all 0.2s ease !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 120px !important;
    border: 1px solid #e2e8f0 !important;
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Item Image */
.item-image {
    width: 4rem;
    height: 4rem;
    border-radius: 0.75rem;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: white;
    border: 1px solid #e2e8f0;
}

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

/* Item Details */
.item-details {
    min-width: 0;
}

.item-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-price {
    font-weight: 700;
    color: #059669;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* Quantity Controls */
.item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-btn {
    width: 2rem;
    height: 2rem;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #64748b;
}

.quantity-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

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

.quantity-value {
    font-weight: 600;
    color: #1e293b;
    min-width: 1.5rem;
    text-align: center;
}

/* Item Total */
.item-total {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.total-price {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.875rem;
}

.remove-btn {
    background: #fee2e2;
    border: none;
    color: #dc2626;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-btn:hover {
    background: #fecaca;
    transform: scale(1.1);
}

.remove-btn i {
    font-size: 0.75rem;
}

/* Cart Footer */
.cart-footer {
    background: white;
    padding: 1.5rem;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

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

.cart-total span:first-child {
    font-weight: 600;
    color: #475569;
    font-size: 1rem;
}

.cart-total span:last-child {
    font-weight: 700;
    color: #1e293b;
    font-size: 1.25rem;
}

.cart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn-clear-cart,
.btn-checkout {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.btn-clear-cart {
    background: #fee2e2;
    color: #dc2626;
}

.btn-clear-cart:hover {
    background: #fecaca;
    transform: translateY(-1px);
}

.btn-checkout {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
}

.btn-checkout:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(5, 150, 105, 0.3);
}

/* Notifications */
.modern-notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: white;
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 10000;
    max-width: 300px;
}

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

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

.modern-notification.success {
    border-left: 4px solid #059669;
}

.modern-notification.success i {
    color: #059669;
}

.modern-notification.error {
    border-left: 4px solid #dc2626;
}

.modern-notification.error i {
    color: #dc2626;
}

.modern-notification.info {
    border-left: 4px solid #8B5CF6;
}

.modern-notification.info i {
    color: #8B5CF6;
}

/* Cart Toggle Button */
[data-cart-toggle] {
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-cart-toggle]:hover {
    transform: scale(1.05);
}

[data-cart-count] {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: #dc2626;
    color: white;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .modern-cart {
        z-index: 99999 !important; /* Ensure cart is above everything on mobile */
    }
    
    .cart-sidebar {
        max-width: 100%;
        width: 100%;
        z-index: 100000 !important; /* Higher than any other element */
        /* Keep desktop-like design on mobile */
        border-radius: 0;
        box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    }
    
    .cart-overlay {
        z-index: 99999 !important;
    }
    
    .cart-header {
        padding: 1.5rem;
        background: linear-gradient(135deg, #8B5CF6, #7C3AED);
    }
    
    .cart-title {
        font-size: 1.25rem;
        font-weight: 600;
    }
    
    .cart-content {
        padding: 1.5rem;
        /* Keep desktop spacing */
    }
    
    .cart-item {
        /* Keep desktop grid layout on mobile */
        grid-template-columns: auto 1fr auto;
        gap: 1rem;
        padding: 1.5rem;
        margin-bottom: 1.5rem;
        /* Enhanced mobile styling */
        border-radius: 1rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        background: white;
    }
    
    .item-image {
        width: 80px;
        height: 80px;
        border-radius: 0.75rem;
        overflow: hidden;
    }
    
    .item-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .item-details {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .item-name {
        font-size: 1rem;
        font-weight: 600;
        color: #1e293b;
        line-height: 1.4;
    }
    
    .item-price {
        font-size: 1.125rem;
        font-weight: 700;
        color: #059669;
    }
    
    .item-quantity {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-top: 0.5rem;
    }
    
    .quantity-btn {
        width: 36px;
        height: 36px;
        border-radius: 0.5rem;
        border: 1px solid #e2e8f0;
        background: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .quantity-btn:hover {
        background: #f8fafc;
        border-color: #cbd5e1;
    }
    
    .quantity-value {
        font-size: 1rem;
        font-weight: 600;
        min-width: 2rem;
        text-align: center;
    }
    
    .item-total {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 0.75rem;
    }
    
    .total-price {
        font-size: 1.125rem;
        font-weight: 700;
        color: #1e293b;
    }
    
    .remove-btn {
        width: 36px;
        height: 36px;
        border-radius: 0.5rem;
        border: 1px solid #fecaca;
        background: #fef2f2;
        color: #dc2626;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .remove-btn:hover {
        background: #fecaca;
        border-color: #fca5a5;
    }
    
    .cart-footer {
        padding: 1.5rem;
        background: white;
        border-top: 1px solid #e2e8f0;
    }
    
    .cart-total {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1.5rem;
        font-size: 1.25rem;
        font-weight: 700;
        color: #1e293b;
    }
    
    .cart-actions {
        display: grid;
        grid-template-columns: 1fr 2fr;
        gap: 1rem;
    }
    
    .btn-clear-cart {
        background: linear-gradient(135deg, #ef4444, #dc2626);
        color: white;
        border: none;
        padding: 1rem 1.5rem;
        border-radius: 0.75rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .btn-checkout {
        background: linear-gradient(135deg, #059669, #047857);
        color: white;
        border: none;
        padding: 1rem 1.5rem;
        border-radius: 0.75rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .btn-clear-cart:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
    }
    
    .btn-checkout:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(5, 150, 105, 0.3);
    }
    
    .modern-notification {
        right: 1rem;
        left: 1rem;
        max-width: none;
        border-radius: 1rem;
    }
}

@media (max-width: 480px) {
    .cart-item {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .item-image {
        margin: 0 auto;
    }
    
    .item-quantity {
        justify-content: center;
    }
    
    .item-total {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Scrollbar Styling */
.cart-content::-webkit-scrollbar {
    width: 6px;
}

.cart-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.cart-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.cart-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Loading States */
.cart-item.loading {
    opacity: 0.7;
    pointer-events: none;
}

.cart-item.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

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

/* Focus States for Accessibility */
.cart-close:focus,
.quantity-btn:focus,
.remove-btn:focus,
.btn-clear-cart:focus,
.btn-checkout:focus {
    outline: 2px solid #8B5CF6;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .cart-sidebar {
        border: 2px solid #000;
    }
    
    .cart-item {
        border: 1px solid #000;
    }
    
    .quantity-btn,
    .remove-btn {
        border: 1px solid #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .modern-cart,
    .cart-sidebar,
    .cart-overlay,
    .cart-item,
    .modern-notification {
        transition: none;
    }
    
    .cart-item {
        animation: none;
    }
}
