/* Import theme colors */
@import url('theme-color.css');

.cart-page {
    background: var(--secondary-light);
    min-height: calc(100vh - 100px);
}

/* Thin scrollbars for all scrollable areas on cart page */
.cart-page {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue, #4d6a92) var(--tertiary-light, #f3f4f6);
}

.cart-page::-webkit-scrollbar,
.cart-page *::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.cart-page::-webkit-scrollbar-track,
.cart-page *::-webkit-scrollbar-track {
    background: var(--tertiary-light, #f3f4f6);
    border-radius: 4px;
}

.cart-page::-webkit-scrollbar-thumb,
.cart-page *::-webkit-scrollbar-thumb {
    background: var(--accent-blue, #4d6a92);
    border-radius: 4px;
}

.cart-page::-webkit-scrollbar-thumb:hover,
.cart-page *::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue, #3d5a82);
}

/* Remove card styling - use clean borders instead */
.cart-items-section,
.cart-summary-section {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cart-item-row {
    transition: background-color 0.2s ease;
}

.cart-item-row:hover {
    background-color: var(--tertiary-light);
    border-radius: 6px;
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Desktop Cart Item Styles */
.cart-item-desktop {
    padding: 0;
}

.cart-item-row {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.cart-item-row:last-child {
    border-bottom: none;
}

.cart-item-image-wrapper {
    display: block;
}

.cart-item-image {
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Quantity Controls - Simple and Compact */
.cart-quantity-control {
    max-width: 110px;
    display: inline-flex;
}

.cart-quantity-control .quantity-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.4rem;
    min-width: 32px;
    font-weight: 600;
    border-radius: 0;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.cart-quantity-control .quantity-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.cart-quantity-control .quantity-btn:last-child {
    border-radius: 0 4px 4px 0;
}

.cart-quantity-control .quantity-btn:hover:not(:disabled) {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.cart-quantity-control .quantity-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.cart-quantity-control .quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cart-quantity-control .quantity-input {
    font-size: 0.8125rem;
    padding: 0.25rem 0.2rem;
    text-align: center;
    font-weight: 600;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    min-width: 45px;
    max-width: 60px;
    user-select: text;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    touch-action: manipulation;
}

.cart-quantity-control .quantity-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(77, 106, 146, 0.1);
    z-index: 1;
}

/* Remove number input spinners */
.cart-quantity-control .quantity-input::-webkit-inner-spin-button,
.cart-quantity-control .quantity-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .cart-quantity-control {
        max-width: 115px;
    }
    
    .cart-quantity-control .quantity-btn {
        min-width: 34px;
        padding: 0.3rem 0.45rem;
        font-size: 0.8125rem;
    }
    
    .cart-quantity-control .quantity-input {
        font-size: 0.8125rem;
        padding: 0.3rem 0.25rem;
        min-width: 48px;
    }
}

@media (max-width: 576px) {
    .cart-quantity-control {
        max-width: 110px;
    }
    
    .cart-quantity-control .quantity-btn {
        min-width: 32px;
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }
    
    .cart-quantity-control .quantity-input {
        font-size: 0.75rem;
        padding: 0.25rem 0.2rem;
        min-width: 45px;
    }
}

/* Remove Item Button Styles */
.remove-item-btn {
    transition: all 0.15s ease;
    border-width: 1.5px;
}

.remove-item-btn:hover {
    background-color: var(--accent-orange);
    border-color: var(--accent-orange);
    color: white;
    transform: translateY(-1px);
}

.remove-item-btn:active {
    transform: translateY(0);
}

.input-group .form-control:focus {
    box-shadow: none;
    border-color: var(--border-light);
}

.input-group .btn {
    border-color: var(--border-light);
}

/* Desktop: Sticky sidebar */
@media (min-width: 992px) {
    .cart-summary-section {
        position: sticky;
        top: 1px;
        z-index: 10;
    }
}

/* Mobile: reduce spacing above content */
@media (max-width: 991.98px) {
    .cart-page-header {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .cart-page-container {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .cart-page-row {
        --bs-gutter-y: 0.75rem;
    }
}

/* Order Summary - Responsive dropdown (mobile) */
.cart-summary-mobile-trigger {
    background: var(--accent-blue);
    border: none;
    margin: 0;
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    -webkit-tap-highlight-color: transparent;
    border-radius: 6px;
}

.cart-summary-mobile-trigger:hover {
    background: var(--accent-blue);
    opacity: 0.92;
}

.cart-summary-trigger-inner {
    padding: 0;
}

.cart-summary-trigger-label {
    color: #fff;
    font-size: 0.875rem;
}

.cart-summary-trigger-label i {
    color: #fff;
}

.cart-summary-trigger-total {
    color: #fff;
    font-size: 0.9375rem;
}

.cart-summary-trigger-chevron {
    font-size: 0.75rem;
    color: #fff;
    transition: transform 0.3s ease;
}

/* Mobile: compact summary section padding */
@media (max-width: 991.98px) {
    .cart-summary-section {
        padding: 0.5rem 0.75rem !important;
    }
}

.cart-summary-mobile-trigger .fa-chevron-down {
    transition: transform 0.3s ease;
}

.cart-summary-chevron-open {
    transform: rotate(180deg);
}

.cart-summary-collapse {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s ease-out;
}

.cart-summary-collapse-open {
    grid-template-rows: 1fr;
}

.cart-summary-collapse-inner {
    overflow: hidden;
    min-height: 0;
}

/* Desktop: always show collapse content */
@media (min-width: 992px) {
    .cart-summary-collapse {
        grid-template-rows: 1fr;
    }

    .cart-summary-collapse-inner {
        overflow: visible;
    }
}

/* Mobile: Vertical list – scroll inside a fixed-height area so the page doesn’t get too long */
.cart-items-mobile {
    padding-bottom: 10px;
    min-height: 320px;
    max-height: 75vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Thin scrollbars */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue, #4d6a92) var(--tertiary-light, #f3f4f6);
}

.cart-items-mobile::-webkit-scrollbar {
    width: 5px;
}

.cart-items-mobile::-webkit-scrollbar-track {
    background: var(--tertiary-light, #f3f4f6);
    border-radius: 4px;
}

.cart-items-mobile::-webkit-scrollbar-thumb {
    background: var(--accent-blue, #4d6a92);
    border-radius: 4px;
}

.cart-items-mobile::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue, #3d5a82);
}

.cart-items-list-mobile {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-item-mobile {
    width: 100%;
    min-width: 0;
}

.cart-item-card {
    background: var(--primary-light);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 12px;
    height: 100%;
}

.cart-item-image-mobile {
    flex-shrink: 0;
}

.cart-item-image-mobile img {
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Sticky Checkout Button - Mobile */
/* Sticky Checkout Button Removed - Now using global .sticky-add-to-cart in bottom-nav.css */


.sticky-checkout-button:hover:not(:disabled) {
    box-shadow: 0 3px 10px rgba(77, 106, 146, 0.3);
}

/* Checkout Button Loading State */
.checkout-btn:disabled,
.sticky-checkout-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.checkout-btn:disabled:hover,
.sticky-checkout-button:disabled:hover {
    box-shadow: none;
    transform: none;
}

/* Mobile: Hide sticky order summary sidebar, show sticky button instead */
@media (max-width: 991.98px) {
    /* .page-header {
        margin-top: 60px !important;
    } */

    .container {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .col-lg-8 {
        margin-bottom: 0.75rem !important;
    }

    .order-summary-sidebar {
        position: relative;
        margin-top: 0.75rem !important;
        z-index: 10;
    }

    .order-summary-sidebar .card-body {
        padding: 1rem !important;
    }

    .cart-items-mobile {
        margin-bottom: 0.75rem;
    }

    .hero-card {
        margin-bottom: 0.5rem;
    }

    .cart-items-desktop {
        padding-bottom: 0.75rem !important;
    }

    .cart-item-desktop {
        padding: 0.75rem 0 !important;
        margin-bottom: 0.75rem !important;
    }

    .cart-item-desktop.border-bottom {
        padding-bottom: 0.75rem !important;
    }

    /* Add padding to bottom of page on mobile to prevent content from being hidden behind sticky button */
    .cart-page {
        padding-bottom: 65px !important;
    }

    /* Hide scrollbar on very small screens */
    @media (max-width: 576px) {
        .cart-item-mobile {
            flex: 0 0 260px;
            min-width: 260px;
        }

        .cart-item-image-mobile {
            width: 85px !important;
        }

        .cart-item-image-mobile img,
        .cart-item-image-mobile .bg-light {
            height: 85px !important;
        }

        .sticky-checkout-btn {
            bottom: 5.25rem;
        }

        .sticky-checkout-btn .text-muted {
            font-size: 0.65rem !important;
        }

        .sticky-checkout-btn .fw-bold {
            font-size: 1rem !important;
        }

        .sticky-checkout-button {
            padding: 0.5rem 1.25rem !important;
            font-size: 0.8125rem !important;
            margin-left: 0.75rem !important;
            border-radius: 10px !important;
        }

        .sticky-checkout-button i {
            margin-right: 0.35rem !important;
        }

        /* .cart-page {
            padding-bottom: 9.5rem !important;
        } */
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991.98px) {
    .cart-item-mobile {
        flex: 0 0 280px;
        min-width: 280px;
    }
}

.cart-item-image img,
.cart-item-image .bg-light {
    height: 70px !important;
}

/* Reduce spacing in cart items */
.cart-item-desktop {
    padding: 0.5rem 0 !important;
}

/* Responsive spacing adjustments */
@media (max-width: 991.98px) {
    .cart-item-desktop {
        padding: 0.5rem 0 !important;
        margin-bottom: 0.5rem !important;
    }
    
    .cart-items-section,
    .cart-summary-section {
        padding: 10px !important;
    }
    
    .container-fluid {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

/* Tooltip styling for discount suggestions */
[data-bs-toggle="tooltip"] {
    cursor: help;
    text-decoration: none;
}

.tooltip {
    font-size: 0.75rem;
    max-width: 250px;
}

/* 260px and below: full responsive cart page */
@media (max-width: 260px) {
    .cart-page .container-fluid {
        padding-left: 0.4rem !important;
        padding-right: 0.4rem !important;
        padding-top: 0.4rem !important;
        padding-bottom: 0.4rem !important;
    }

    /* .cart-page .page-header {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    } */

    .cart-page .page-header h1 {
        font-size: 1.15rem !important;
    }

    .cart-page .page-header .text-muted {
        font-size: 0.75rem !important;
    }

    .cart-page .cart-items-section,
    .cart-page .cart-summary-section {
        padding: 0.5rem 0.6rem !important;
        border-radius: 6px;
    }

    .cart-page .cart-items-section h4 {
        font-size: 0.8125rem !important;
    }

    .cart-page .cart-items-section .btn-outline-secondary.btn-sm {
        font-size: 0.75rem !important;
        padding: 0.3rem 0.5rem !important;
    }

    .cart-page .cart-items-section .btn-outline-secondary .me-1 {
        margin-right: 0.25rem !important;
    }

    /* Mobile cart cards: fit 260px viewport, allow horizontal scroll */
    .cart-item-mobile {
        flex: 0 0 240px;
        min-width: 240px;
    }

    .cart-item-card {
        padding: 8px !important;
    }

    .cart-item-image-mobile {
        width: 70px !important;
        margin-right: 8px !important;
    }

    .cart-item-image-mobile img,
    .cart-item-image-mobile .bg-light {
        height: 70px !important;
    }

    .cart-item-info h6,
    .cart-item-info .fw-bold {
        font-size: 0.8125rem !important;
        line-height: 1.3 !important;
    }

    .cart-item-info .badge {
        font-size: 0.5625rem !important;
        padding: 0.15rem 0.3rem !important;
    }

    .cart-item-info .text-muted {
        font-size: 0.625rem !important;
    }

    .cart-item-info .fw-bold.text-danger,
    .cart-item-info .fw-bold[style*="accent-blue"] {
        font-size: 0.8125rem !important;
    }

    .cart-quantity-control {
        max-width: 100px;
    }

    .cart-quantity-control .quantity-btn {
        min-width: 28px;
        padding: 0.2rem 0.3rem;
        font-size: 0.6875rem;
    }

    .cart-quantity-control .quantity-input {
        font-size: 0.6875rem;
        padding: 0.2rem 0.15rem;
        min-width: 38px;
        max-width: 48px;
    }

    /* Desktop-style cart rows (if shown on very small screens) */
    .cart-page .cart-item-row .col-3,
    .cart-page .cart-item-row .col-9 {
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }

    .cart-page .cart-item-image,
    .cart-page .cart-item-image .bg-light {
        max-width: 50px !important;
        width: 50px !important;
        height: 50px !important;
    }

    /* Order summary / cart summary */
    .cart-page .cart-summary-section h5,
    .cart-page .cart-summary-section .fw-bold {
        font-size: 0.8125rem !important;
    }

    .cart-page .cart-summary-section .text-muted,
    .cart-page .cart-summary-section small {
        font-size: 0.6875rem !important;
    }

    /* Sticky checkout button */
    .cart-page {
        padding-bottom: 58px !important;
    }

    .sticky-checkout-btn {
        padding: 0.35rem 0.4rem !important;
    }

    .sticky-checkout-btn .text-muted {
        font-size: 0.5625rem !important;
    }

    .sticky-checkout-btn .fw-bold {
        font-size: 0.8125rem !important;
    }

    .sticky-checkout-button {
        padding: 0.35rem 0.6rem !important;
        font-size: 0.625rem !important;
        margin-left: 0.35rem !important;
    }

    .sticky-checkout-button i {
        margin-right: 0.2rem !important;
    }

    /* Alerts */
    .cart-page .alert {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.5rem !important;
    }
}