/* ============================================================================
   SHOPPING CART DESIGN IMPROVEMENTS - FIXED VERSION
   Version: 2.0
   Date: October 23, 2025

   FIXES APPLIED:
   1. Fixed desktop cart always showing (removed forced display: flex)
   2. Made cart full height and properly edge-aligned
   3. Mobile: Fixed stretched buttons (quantity +/- and delete)
   4. Desktop: Improved spacing throughout the cart
   5. Desktop: Blue round buttons for quantity controls (matching mobile style)
   6. Both: Red round background for delete/trash button
   ============================================================================ */

/* ============================================================================
   MOBILE CART IMPROVEMENTS (Default / Base Styles)
   ============================================================================ */

/* Cart Modal Container */
#cart-modal {
    display: none; /* CRITICAL: Hidden by default, JS will control visibility */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 10001 !important;
    margin: 0;
    padding: 0;
}

/* When cart is shown (via JavaScript adding a class) */
#cart-modal.show {
    display: block !important;
}

.cart-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    height: 90vh;
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px 20px 100px;
    width: 100%;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2);
    border-radius: 20px 20px 0 0;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

/* Cart Header */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 5px 15px 5px;
    border-bottom: 2px solid #eee;
}

.cart-header h3 {
    font-size: 1.5rem;
    color: var(--primary, #002B7F);
    margin: 0;
}

.cart-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    padding: 5px 10px;
    line-height: 1;
    transition: color 0.3s ease;
}

.cart-close:hover {
    color: #333;
}

/* Cart Items Container */
.cart-items {
    padding: 10px 0;
    min-height: 200px;
}

/* Individual Cart Item */
.cart-item {
    padding: 20px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #fafafa;
    border-radius: 12px;
    margin-bottom: 15px;
}

/* Item Details */
.item-details h4 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #333;
}

.package-type {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.item-price {
    font-size: 0.95rem;
    color: var(--primary, #002B7F);
    font-weight: 600;
}

/* Item Controls Row */
.item-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

/* MOBILE: Quantity Controls - Round Blue Buttons with Gray Background */
.quantity-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 25px;
    padding: 6px 12px;
}

.qty-btn {
    width: 35px;
    height: 35px;
    min-width: 35px;
    min-height: 35px;
    border-radius: 50%;
    border: none;
    background: #002B7F;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.qty-btn:hover {
    background: #001f5c;
    transform: scale(1.1);
}

.qty-btn:active {
    transform: scale(0.95);
}

.quantity {
    font-size: 16px;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
    color: #333;
}

/* MOBILE: Delete Button - Round Red Background */
.remove-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    border: none;
    background: #dc3545;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    font-size: 16px;
}

.remove-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.remove-btn:active {
    transform: scale(0.95);
}

.remove-btn i {
    pointer-events: none;
}

/* Item Total */
.item-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary, #002B7F);
    text-align: right;
}

/* Cart Footer */
.cart-footer {
    padding: 20px 15px 0;
    border-top: 2px solid #eee;
    margin-top: 20px;
}

/* Breakdown Lines */
.cart-breakdown {
    margin-bottom: 15px;
}

.breakdown-line {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 15px;
    color: #666;
    border-bottom: 1px solid #f0f0f0;
}

.breakdown-line:last-child {
    border-bottom: none;
}

.breakdown-line.total-line {
    border-top: 2px solid var(--primary, #002B7F);
    padding-top: 12px;
    margin-top: 10px;
    font-weight: bold;
    color: var(--primary, #002B7F);
    font-size: 1.1rem;
}

.breakdown-line.total-line span {
    font-size: 1.2rem;
}

/* Cart Total */
.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--primary, #002B7F);
}

/* Checkout Button */
.cart-footer .btn-primary {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border-radius: 10px;
    margin-top: 10px;
}

/* Empty Cart State */
.empty-cart {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-cart i {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #ddd;
}

.empty-cart p {
    font-size: 1.1rem;
    color: #666;
}


/* ============================================================================
   DESKTOP CART IMPROVEMENTS (min-width: 769px)
   ============================================================================ */

@media (min-width: 769px) {
    /* Desktop: Cart modal remains hidden until triggered */
    #cart-modal {
        /* Remove the forced display: flex that was causing the always-open issue */
        display: none; /* Hidden by default */
        align-items: stretch !important;
        justify-content: flex-end !important;
        padding: 0 !important;
    }
    
    /* When cart is shown on desktop */
    #cart-modal.show {
        display: flex !important; /* Use flex when shown */
    }

    /* Desktop: Cart Content as FULL-HEIGHT RIGHT-SIDE Panel */
    .cart-content {
        position: fixed !important;
        top: 0 !important; /* Start from top */
        bottom: 0 !important; /* Extend to bottom */
        left: auto !important;
        right: 0 !important; /* Flush to right edge */
        width: 100% !important;
        max-width: 450px !important; /* Narrower for edge panel */
        height: 100vh !important; /* Full viewport height */
        max-height: 100vh !important;
        border-radius: 0 !important; /* No border radius for edge panel */
        padding: 0 !important; /* Reset padding, will add internally */
        margin: 0 !important;
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2) !important;
        transform: translateX(0) !important;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Prevent overall scroll */
    }
    
    /* Desktop: Internal structure for full-height cart */
    .cart-header {
        flex-shrink: 0;
        padding: 25px 25px 20px 25px;
        margin-bottom: 0;
        border-bottom: 2px solid #eee;
        background: white;
    }
    
    .cart-items {
        flex: 1;
        overflow-y: auto;
        padding: 20px 25px;
        background: #fafafa;
    }
    
    .cart-footer {
        flex-shrink: 0;
        padding: 20px 25px 25px 25px;
        margin-top: 0;
        border-top: 2px solid #eee;
        background: white;
    }

    /* Desktop: Cart Header with Better Spacing */
    .cart-header h3 {
        font-size: 1.8rem;
    }

    .cart-close {
        font-size: 2.2rem;
        padding: 5px 15px;
    }

    /* Desktop: Cart Items with Better Spacing */
    .cart-item {
        padding: 25px 20px;
        margin-bottom: 20px;
        border-radius: 15px;
        background: white;
    }

    /* Desktop: Item Details with Better Spacing */
    .item-details {
        margin-bottom: 5px;
    }

    .item-details h4 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .package-type {
        font-size: 0.95rem;
        margin-bottom: 8px;
    }

    .item-price {
        font-size: 1rem;
        margin-top: 8px;
    }

    /* DESKTOP: Quantity Controls - Blue Round Buttons (Mobile Style) */
    .quantity-controls {
        display: flex;
        align-items: center;
        gap: 15px;
        background: rgba(0, 0, 0, 0.05);
        border-radius: 30px;
        padding: 8px 16px;
    }

    .qty-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        border-radius: 50%;
        border: none;
        background: #002B7F;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 15px;
        transition: all 0.3s ease;
        flex-shrink: 0;
    }

    .qty-btn:hover {
        background: #001f5c;
        transform: scale(1.15);
        box-shadow: 0 4px 12px rgba(0, 43, 127, 0.3);
    }

    .qty-btn:active {
        transform: scale(1.0);
    }

    .quantity {
        font-size: 17px;
        font-weight: 600;
        min-width: 35px;
        text-align: center;
    }

    /* DESKTOP: Delete Button - Red Round Background */
    .remove-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 50%;
        border: none;
        background: #dc3545;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        flex-shrink: 0;
        font-size: 17px;
    }

    .remove-btn:hover {
        background: #c82333;
        transform: scale(1.15);
        box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
    }

    .remove-btn:active {
        transform: scale(1.0);
    }

    /* Desktop: Item Total */
    .item-total {
        font-size: 1.2rem;
    }

    /* Desktop: Cart Footer Breakdown */
    .breakdown-line {
        padding: 12px 0;
        font-size: 16px;
    }

    .breakdown-line.total-line {
        padding-top: 15px;
        margin-top: 12px;
        font-size: 1.15rem;
    }

    .breakdown-line.total-line span {
        font-size: 1.3rem;
    }

    .cart-total {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }

    /* Desktop: Checkout Button */
    .cart-footer .btn-primary {
        padding: 18px;
        font-size: 1.15rem;
        border-radius: 12px;
        margin-top: 15px;
    }

    .cart-footer .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(0, 43, 127, 0.3);
    }

    /* Desktop: Empty Cart State */
    .empty-cart {
        padding: 80px 40px;
    }

    .empty-cart i {
        font-size: 5rem;
        margin-bottom: 25px;
    }

    .empty-cart p {
        font-size: 1.2rem;
    }
}


/* ============================================================================
   LARGE DESKTOP OPTIMIZATIONS (min-width: 1200px)
   ============================================================================ */

@media (min-width: 1200px) {
    .cart-content {
        max-width: 500px; /* Slightly wider on large screens */
    }
    
    .cart-header {
        padding: 30px 30px 25px 30px;
    }
    
    .cart-items {
        padding: 25px 30px;
    }
    
    .cart-footer {
        padding: 25px 30px 30px 30px;
    }

    .cart-header h3 {
        font-size: 2rem;
    }

    .cart-item {
        padding: 30px 25px;
    }

    .item-details h4 {
        font-size: 1.3rem;
    }
}


/* ============================================================================
   ULTRA-WIDE DESKTOP (min-width: 1920px)
   ============================================================================ */

@media (min-width: 1920px) {
    .cart-content {
        max-width: 550px; /* Even wider for ultra-wide displays */
    }
}


/* ============================================================================
   ACCESSIBILITY & TOUCH IMPROVEMENTS
   ============================================================================ */

/* Focus states for keyboard navigation */
.qty-btn:focus,
.remove-btn:focus,
.cart-close:focus {
    outline: 3px solid #0066ff;
    outline-offset: 2px;
}

.qty-btn:focus:not(:focus-visible),
.remove-btn:focus:not(:focus-visible),
.cart-close:focus:not(:focus-visible) {
    outline: none;
}

/* Better touch targets for mobile */
@media (max-width: 768px) {
    .qty-btn,
    .remove-btn,
    .cart-close {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Smooth scrolling for cart content */
.cart-items {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Loading state for cart */
.cart-items.loading {
    opacity: 0.6;
    pointer-events: none;
}


/* ============================================================================
   ANIMATION IMPROVEMENTS
   ============================================================================ */

/* Cart modal fade in */
#cart-modal.show {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Cart content slide up (mobile) */
@media (max-width: 768px) {
    #cart-modal.show .cart-content {
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

/* Cart content slide in from right (desktop) */
@media (min-width: 769px) {
    #cart-modal.show .cart-content {
        animation: slideInRight 0.3s ease;
    }

    @keyframes slideInRight {
        from {
            transform: translateX(100%);
        }
        to {
            transform: translateX(0);
        }
    }
}

/* Item add animation */
.cart-item {
    animation: itemSlideIn 0.3s ease;
}

@keyframes itemSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* ============================================================================
   SCROLLBAR STYLING
   ============================================================================ */

/* Custom scrollbar for cart items */
.cart-items::-webkit-scrollbar {
    width: 8px;
}

.cart-items::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.cart-items::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.cart-items::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    #cart-modal {
        position: static !important;
        background: white !important;
    }

    .cart-content {
        max-height: none !important;
        overflow: visible !important;
        box-shadow: none !important;
        position: static !important;
    }

    .cart-close,
    .qty-btn,
    .remove-btn,
    .cart-footer .btn-primary {
        display: none !important;
    }
}


/* ============================================================================
   RESPONSIVE BREAKPOINT DEBUGGING (Remove in production)
   ============================================================================ */

/* Uncomment to see current breakpoint during development */
/*
body::after {
    content: "Mobile";
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: red;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    z-index: 99999;
}

@media (min-width: 769px) {
    body::after {
        content: "Desktop";
        background: blue;
    }
}

@media (min-width: 1200px) {
    body::after {
        content: "Large Desktop";
        background: green;
    }
}

@media (min-width: 1920px) {
    body::after {
        content: "Ultra Wide";
        background: purple;
    }
}
*/