/* Shopping Cart UI Styles */

.cart-container {
    position: relative;
    cursor: pointer;
}

.cart-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #eab308, #f59e0b);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(234, 179, 8, 0.3);
}

.cart-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(234, 179, 8, 0.4);
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: cartPulse 2s infinite;
}

@keyframes cartPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Flying cart animation */
@keyframes flyToCart {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0.3);
        opacity: 0;
    }
}

.flying-item {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.4);
    animation: flyToCart 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Cart Sidebar — flex column: header (fixed) / items (scroll) / total (fixed at bottom)
   Avoids the old "whole sidebar scrolls + sticky footer" pattern which fails on mobile
   when the items list exceeds the viewport — the checkout button used to scroll out of view. */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    /* dvh accounts for mobile browser chrome (Safari URL bar, etc.) so the checkout
       button is never hidden behind it. Falls back to vh on older browsers. */
    height: 100dvh;
    background: #fff;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.cart-sidebar.open {
    right: 0;
}

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

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

.cart-header {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0; /* fixed at top, never scrolls or shrinks */
}

.cart-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #000;
}

.cart-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.cart-close:hover {
    background: #f3f4f6;
    color: #000;
}

.cart-items {
    padding: 24px;
    flex: 1 1 auto;          /* expand to fill all space between header and total */
    overflow-y: auto;        /* scroll only THIS region when items overflow */
    -webkit-overflow-scrolling: touch; /* momentum scrolling on iOS */
    min-height: 0;           /* required for flex children that overflow */
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #f3f4f6;
}

.cart-item-image {
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.cart-item-details {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    color: #000;
    margin-bottom: 4px;
    font-size: 14px;
}

.cart-item-size {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

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

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

.quantity-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
}

.quantity-btn:hover {
    border-color: #eab308;
    background: #fef3c7;
}

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

.cart-total {
    /* Pinned at the bottom of the sidebar via flex layout (parent is flex column).
       Adds safe-area inset so the checkout button isn't covered by iOS Safari's
       bottom toolbar or the iPhone home indicator. */
    padding: 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    border-top: 2px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0; /* never shrinks — checkout button always visible */
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.total-label {
    font-size: 1.1rem;
    font-weight: bold;
    color: #000;
}

.total-price {
    font-size: 1.3rem;
    font-weight: bold;
    color: #eab308;
}

.checkout-btn {
    width: 100%;
    background: linear-gradient(135deg, #eab308, #f59e0b);
    color: #000;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.checkout-btn:hover {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(234, 179, 8, 0.3);
}

.empty-cart {
    text-align: center;
    padding: 40px 20px;
}

.empty-cart i {
    font-size: 48px;
    color: #d1d5db;
    margin-bottom: 16px;
}

.empty-cart p {
    color: #6b7280;
    margin-bottom: 8px;
}

@media (max-width: 480px) {
    .cart-sidebar {
        width: 100%;
        right: -100%;
    }
}
