/* 1. Sidebar Structure */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -100%; /* Hidden by default */
    width: 85%; /* Mobile width */
    max-width: 400px;
    height: 100vh;
    background: #fff;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease-in-out;
}

.cart-sidebar.open {
    right: 0;
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    display: none;
    backdrop-filter: blur(2px);
}

.cart-overlay.active {
    display: block;
}

/* 2. Header & Savings Section */
.cart-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.cart-header h3 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#header-savings {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
}

.price-line {
    display: flex;
    gap: 10px;
    align-items: baseline;
}

#header-total-sale { font-weight: 700; color: #000; font-size: 1.1rem; }
#header-total-mrp { text-decoration: line-through; color: #999; font-size: 0.9rem; }

#header-save-summary {
    font-size: 0.8rem;
    color: #28a745;
    margin-top: 4px;
    font-weight: 600;
}

#btn-close-cart {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* 3. Cart Body (The Scrollable Area) */
.cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    scrollbar-width: thin;
}

/* 7. Footer Section */
.cart-footer {
    padding: 20px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.btn-main {
    width: 100%;
    padding: 15px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}


@media (min-width: 768px) {
    /* Make the sidebar wider on tablets/desktops */
    .cart-sidebar {
        width: 400px;
    }

    
}

/* 4. Individual Cart Item */
/* --- MOBILE VIEW (Default) --- */

/* Main container for each product in the cart */
.cart-item {
    display: flex;
    padding: 15px 10px;
    border-bottom: 1px solid #eee;
    background: #fff;
    gap: 12px;
    align-items: flex-start; /* Keeps image and action buttons at the top */
}

/* Clickable area containing image and text details */
.cart-item-link {
    display: flex;
    flex: 1;
    text-decoration: none;
    color: inherit;
    gap: 12px;
    min-width: 0; /* Prevents text from pushing outside the sidebar */
}

/* 1:1 Square Thumbnail */
.cart-thumb {
    width: 85px;
    height: 85px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #f5f5f5;
}

/* Middle column: Name, Description, Variants, Price, Stepper */
.cart-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
}

/* Product Name */
.cart-item-name {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.2;
    color: #222;
}

/* Full description - will expand to fit text */
.cart-item-desc {
    font-size: 0.8rem;
    color: #777;
    margin: 0;
    line-height: 1.3;
}

/* Variant tags container */
.cart-item-variants {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 2px 0;
}

/* Individual Variant tag styling (e.g., Size: 8 inch) */
.cart-variant-tag {
    font-size: 0.7rem;
    background: #f2f2f2;
    padding: 2px 6px;
    border-radius: 4px;
    color: #555;
    border: 1px solid #e0e0e0;
}

/* Price, Quantity label, and Subtotal row */
.cart-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.cart-sale-price { font-weight: 700; color: #000; font-size: 0.9rem; }
.cart-mrp-price { text-decoration: line-through; color: #bbb; font-size: 0.75rem; }
.cart-qty-label { font-size: 0.8rem; color: #666; }
.item-subtotal { margin-left: auto; font-weight: 700; font-size: 0.9rem; }

/* Horizontal Quantity Stepper (Inside details) */
.qty-stepper {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: fit-content;
    margin-top: 8px;
    overflow: hidden;
    background: #fff;
}

.qty-stepper button {
    background: #f8f8f8;
    border: none;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
}

.qty-stepper span {
    padding: 0 10px;
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 30px;
    text-align: center;
}

/* Right side: Action column for Share and Remove */
.cart-item-action-column {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 85px; /* Matches the image height */
    padding-left: 5px;
    flex-shrink: 0;
}

.share-btn, .remove-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 1.1rem;
}

.share-btn { color: #007bff; }
.remove-btn { color: #dc3545; }

/* --- DESKTOP VIEW (@media) --- */

@media (min-width: 768px) {
    /* Slightly wider sidebar for desktop */
    .cart-sidebar {
        width: 420px;
    }

    /* Larger image for desktop */
    .cart-thumb {
        width: 100px;
        height: 100px;
    }

    /* Adjust action column height to match larger image */
    .cart-item-action-column {
        height: 100px;
    }

    .cart-item-name {
        font-size: 1.05rem;
    }

    .qty-stepper button {
        width: 32px;
        height: 32px;
    }
}

/* 7. Footer Section */
.cart-footer {
    position: sticky;
    bottom: 0;
    width: 100%;
    background: #fff;
    
    /* This adds the necessary space for iPhone navigation bars */
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    
    /* Ensures it sits above other content */
    z-index: 99; 
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.btn-main {
    width: 100%;
    padding: 15px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}


@media (min-width: 768px) {
    /* Make the sidebar wider on tablets/desktops */
    .cart-sidebar {
        width: 400px;
    }

    /* Change Qty Stepper to Horizontal for more room */
    .qty-stepper {
        flex-direction: row;
        width: auto;
    }

    .qty-stepper button {
        width: 30px;
    }

    .qty-stepper span {
        padding: 0 10px;
    }

    /* Make action buttons sit horizontally on larger viewports */
    .cart-item-action-column {
        width: 100px;
        flex-direction: row;
        justify-content: flex-end;
        gap: 10px;
        align-items: center;
    }
}