/* =========================================
   CART PAGE STYLES
   ========================================= */

.cart-page {
    width: 100%;
    max-width: 100% !important;
    min-width: 0;
    /* Critical: allows grid/flex item to shrink */
    padding: 0;
    box-sizing: border-box;
    overflow-x: hidden !important;
    /* Prevent horizontal scroll */
}

.empty-cart {
    text-align: center;
    padding: 60px;
    color: #94a3b8;
}

.upsell-carousel {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
    box-sizing: border-box !important;
    display: flex !important;
    gap: 15px;
    flex-wrap: nowrap;
    scroll-snap-type: x mandatory;
    /* Smooth scrolling on mobile */
}

.cart-shipping-progress {
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0;
    /* Prevent flex/grid expansion */
    box-sizing: border-box !important;
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    overflow: hidden;
}

#cartUpsellContainer {
    margin-top: 30px;
    display: none;
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0;
    /* Ensure proper shrinking */
    box-sizing: border-box !important;
    overflow: hidden;
}

.empty-cart i {
    font-size: 50px;
    margin-bottom: 20px;
}

.empty-cart p {
    font-size: 1.2rem;
    margin-bottom: 30px;
}

/* Responsive Layout using Flexbox for easier flow */
.cart-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100% !important;
    overflow: hidden;
    overflow-x: hidden !important;
    box-sizing: border-box;
    /* Prevent expansion when dynamic content loads */
}

.cart-items {
    flex: 1 1 0%;
    width: 100%;
    min-width: 0;
    /* Crucial for flex item overflow */
    max-width: calc(100% - 350px) !important;
    /* Ensure it does not exceed parent, accounting for summary */
    overflow-x: hidden !important;
    overflow: hidden !important;
    box-sizing: border-box;
    /* Prevent expansion when dynamic content loads */
}

@media (max-width: 900px) {
    .cart-items {
        max-width: 100% !important;
    }
}

.cart-summary-wrapper {
    width: 320px;
    flex-shrink: 0;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.cart-item img {
    width: 60px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.ci-info {
    flex: 1;
    min-width: 0;
}

/* prevent flex overflow */
.ci-info h4 {
    margin: 0 0 4px 0;
    font-size: 0.95rem;
    color: #1e293b;
    font-weight: 600;
    line-height: 1.3;
}

.ci-info p {
    color: #64748b;
    font-size: 0.85rem;
    margin: 0;
}

.ci-total {
    font-weight: 700;
    color: #1e293b;
    font-size: 1rem;
    white-space: nowrap;
    margin-left: 10px;
}

.btn-remove {
    background: #fee2e2;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    margin-left: 10px;
}

/* Summary box logic */
.cart-summary {
    background: white;
    padding: 25px;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 4px 15px -3px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 90px;
}

.cart-summary h3 {
    margin-top: 0;
    font-size: 1.2rem;
    border-bottom: 2px solid #f8fafc;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    color: #64748b;
    font-size: 0.9rem;
}

.summary-row.total {
    color: #1e293b;
    font-weight: 800;
    font-size: 1.3rem;
    border-top: 2px solid #f1f5f9;
    padding-top: 15px;
    margin-bottom: 20px;
    align-items: flex-end;
}

/* Premium Checkout Button */
.btn-checkout-premium {
    width: 100%;
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 15px -3px rgba(245, 158, 11, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    .cart-layout {
        flex-direction: column;
    }

    .cart-summary-wrapper {
        width: 100%;
    }

    .cart-summary {
        position: static;
    }
}

@media (max-width: 600px) {

    /* Override main-layout for cart page on MOBILE ONLY */
    .main-layout:has(.cart-page) {
        display: block !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        padding: 20px 15px !important;
    }

    .cart-page {
        width: 100%;
        padding: 0 10px;
        box-sizing: border-box;
        overflow-x: hidden;
        /* prevent horizontal scroll */
    }

    .cart-layout {
        display: flex;
        gap: 30px;
        align-items: flex-start;
        max-width: 100%;
        overflow: hidden;
    }

    .cart-summary-wrapper {
        width: 320px;
        flex-shrink: 0;
        max-width: 100%;
    }

    .upsell-carousel,
    .cart-shipping-progress {
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .cart-item {
        padding: 12px;
        gap: 12px;
    }

    /* Sticky Footer Logic for Mobile Conversion */
    .cart-summary-wrapper {
        position: fixed;
        bottom: 0px;
        left: 0;
        width: 100%;
        z-index: 9999;
        /* Highest priority */
        padding: 0;
    }

    .cart-summary {
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.1);
        border: none;
        border-top: 1px solid #e2e8f0;
        padding: 15px 20px;
        margin: 0;
    }

    /* Hide detailed breakdown on mobile sticky, show only total */
    .cart-summary h3,
    .summary-row:not(.total) {
        display: none;
    }

    .summary-row.total {
        margin-bottom: 12px;
        padding-top: 0;
        border: none;
        font-size: 1.1rem;
    }

    /* Spacer to prevent content being hidden */
    .cart-layout {
        padding-bottom: 180px;
    }

    /* Nav bar z-index fix */
    .mobile-bottom-nav {
        z-index: 100 !important;
    }
}