/* ===================================
   CART SIDEBAR DRAWER STYLES
   =================================== */

/* Overlay */
.cart-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9998;
    backdrop-filter: blur(2px);
}

.cart-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Cart Sidebar */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-white);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-sidebar.active {
    right: 0;
}

/* Header */
.cart-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    flex-shrink: 0;
}

.cart-sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.cart-sidebar-title i {
    font-size: 1.25rem;
}

.cart-sidebar-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.cart-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Content */
.cart-sidebar-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: opacity 0.2s ease;
}

/* Empty Cart */
.cart-sidebar-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    text-align: center;
    color: var(--text-light);
}

.cart-sidebar-empty i {
    font-size: 4rem;
    color: var(--border-color);
    margin-bottom: var(--spacing-md);
}

.cart-sidebar-empty p {
    font-size: 1rem;
    margin-bottom: var(--spacing-lg);
}

.cart-sidebar-shop-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Cart Items */
.cart-sidebar-items {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
}

.cart-sidebar-item {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg) var(--spacing-sm) var(--spacing-sm);
    background: var(--bg-light);
    border-radius: 12px;
    margin-bottom: var(--spacing-sm);
    position: relative;
    transition: all 0.3s ease;
}

.cart-sidebar-item:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.cart-item-image {
    flex-shrink: 0;
    width: 70px;
    height: 70px;
    border-radius: 10px;
    overflow: hidden;
    background: white;
}

.cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cart-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-name a {
    color: var(--text-dark);
    text-decoration: none;
}

.cart-item-name a:hover {
    color: var(--primary-color);
}

.cart-item-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 6px;
}

.cart-item-quantity {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: white;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    width: fit-content;
}

.cart-item-quantity .qty-btn {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-dark);
    transition: all 0.2s ease;
    font-size: 0.7rem;
}

.cart-item-quantity .qty-btn:hover {
    background: var(--primary-color);
    color: white;
}

.cart-item-quantity .qty-value {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.cart-item-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #ff4757;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.cart-item-remove:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Footer */
.cart-sidebar-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.cart-sidebar-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    font-size: 1rem;
}

.cart-sidebar-subtotal span:first-child {
    color: var(--text-light);
    font-weight: 500;
}

.cart-sidebar-subtotal .subtotal-amount {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 1.15rem;
}

.cart-sidebar-checkout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: var(--spacing-sm);
}

.cart-sidebar-view-cart {
    display: block;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    padding: 8px;
    transition: color 0.2s ease;
}

.cart-sidebar-view-cart:hover {
    color: var(--primary-color);
}

/* Loading State */
.cart-sidebar-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.cart-sidebar-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .cart-sidebar-checkout-btn {
        padding: var(--spacing-sm) !important;
        font-size: 0.9rem !important;
    }

    .cart-sidebar {
        width: 100%;
        max-width: 100%;
        right: -100%;
    }

    .cart-sidebar-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .cart-sidebar-title {
        font-size: 1rem;
    }

    .cart-sidebar-items {
        padding: var(--spacing-sm);
    }

    .cart-item-image {
        width: 60px;
        height: 60px;
    }

    .cart-sidebar-footer {
        padding: var(--spacing-sm) var(--spacing-md);
        /* Add padding for mobile bottom navigation (approx 70px) + safe area */
        padding-bottom: calc(var(--spacing-sm) + env(safe-area-inset-bottom));
    }
}

/* For tablets and larger phones where mobile bottom nav is still visible */
@media (max-width: 992px) {
    .cart-sidebar-footer {
        padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom));
    }
}