﻿/* =========================
   Quantity selector
========================= */
.quantity-selector {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    /* Better tap target + consistent sizing */
    .quantity-selector .quantity-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        font-size: 1rem;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* More realistic input width */
    .quantity-selector .quantity-input {
        width: 64px;
        text-align: center;
        padding: 0.375rem 0.5rem;
    }

/* =========================
   Size select wrapper
========================= */
.item-search-size-wrapper {
    display: flex;
    /*align-items: flex-end;*/ /* aligns with labeled controls */
    gap: 0.5rem;
}

    /* ensure select looks like bootstrap control */
    .item-search-size-wrapper .form-select,
    .item-search-size-wrapper .form-select.form-select-sm,
    .item-search-size-wrapper select.select-size {
        width: auto;
        min-width: 140px;
        height: calc(1.5rem + 0.75rem + 2px);
        padding: 0.25rem 0.5rem;
        line-height: 1.5;
        vertical-align: middle;
        box-sizing: border-box;
    }

    /* label placeholder (if label exists but hidden) */
    .item-search-size-wrapper .form-label {
        margin-bottom: 0;
    }

/* mobile: stack and full width */
@media (max-width: 991.98px) {
    .item-search-size-wrapper {
        align-items: stretch;
    }

        .item-search-size-wrapper .form-select,
        .item-search-size-wrapper select.select-size {
            width: 100%;
            min-width: 0;
            height: auto;
        }
}

/* =========================
   Color select wrapper
========================= */
.item-search-color-wrapper {
    display: flex;
    /*align-items: flex-end;*/ /* aligns with labeled controls */
    gap: 0.5rem;
}

    /* ensure select looks like bootstrap control */
    .item-search-color-wrapper .form-select,
    .item-search-color-wrapper .form-select.form-select-sm,
    .item-search-color-wrapper select.select-color {
        width: auto;
        min-width: 140px;
        height: calc(1.5rem + 0.75rem + 2px);
        padding: 0.25rem 0.5rem;
        line-height: 1.5;
        vertical-align: middle;
        box-sizing: border-box;
    }

    /* label placeholder (if label exists but hidden) */
    .item-search-color-wrapper .form-label {
        margin-bottom: 0;
    }

/* mobile: stack and full width */
@media (max-width: 991.98px) {
    .item-search-color-wrapper {
        align-items: stretch;
    }

        .item-search-color-wrapper .form-select,
        .item-search-color-wrapper select.select-color {
            width: 100%;
            min-width: 0;
            height: auto;
        }
}

/* =========================
   Clear cart button
========================= */
#btnClearCart {
    font-size: 0.875rem;
    padding: 0.5rem 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 2rem;
}

    #btnClearCart i {
        transition: transform 0.2s ease;
    }

    #btnClearCart:hover i {
        transform: rotate(15deg);
    }

/* =========================
   Item search dropdown
   IMPORTANT: the parent wrapper of #itemSearchList should be position: relative;
========================= */
#itemSearchList {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    z-index: 600;
    display: none;
    max-height: 300px;
    overflow: auto;
    background: var(--surface-color);
    color: var(--default-color);
    border: 1px solid color-mix(in srgb, var(--default-color), transparent 85%);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 6px 0;
    -webkit-overflow-scrolling: touch;
}

/* CART: make Qty control match the search textbox height */
#cart {
    --cart-control-h: calc(1.5em + .75rem + 2px); /* Bootstrap input height */
}

    #cart .product-quantity .quantity-selector {
        align-items: stretch; /* let children take full height */
    }

        #cart .product-quantity .quantity-selector .quantity-input.form-control {
            padding: .375rem .75rem !important; /* restore normal input padding */
            line-height: 1.5;
        }

        #cart .product-quantity .quantity-selector .quantity-btn {
            width: var(--cart-control-h) !important;
            padding: 0 !important;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

    /* optional: keep it narrower without shrinking height */
    #cart #itemSearchQty {
        width: 160px;
        height: 50px;
    }

.product-title-link {
    color: var(--heading-color) !important;
}

    .product-title-link:hover {
        color: var(--accent-color) !important;
    }

/* =========================
   Cart entry mobile improvement
========================= */
@media (max-width: 767.98px) {

    #cart .add-by-search {
        margin-bottom: 1rem;
    }

        #cart .add-by-search .row {
            row-gap: 0.75rem;
            align-items: stretch !important;
        }

        /* search stays full width */
        #cart .add-by-search .col-12.position-relative {
            width: 100%;
        }

        /* qty + add on same row */
        #cart .add-by-search .col-3,
        #cart .add-by-search .col-6 {
            display: flex;
            align-items: stretch;
        }

    /* quantity field */
    #cart .product-quantity,
    #cart .product-quantity .quantity-selector {
        width: 100%;
    }

    #cart #itemSearchQty {
        width: 100% !important;
        min-width: 0;
        height: 46px;
        border-radius: 14px;
    }

    /* add button */
    #cart #btnItemSearchAdd {
        width: 100%;
        height: 46px;
        border-radius: 10px;
        font-weight: 600;
    }

    /* size and color each take full width */
    #cart .item-search-size-wrapper,
    #cart .item-search-color-wrapper {
        width: 100%;
        display: block;
    }

        #cart .item-search-size-wrapper .form-select,
        #cart .item-search-color-wrapper .form-select,
        #cart .item-search-size-wrapper select,
        #cart .item-search-color-wrapper select {
            width: 100% !important;
            min-width: 0 !important;
            height: 46px;
            border-radius: 10px;
        }

    /* search input */
    #cart #itemSearch {
        height: 46px;
        border-radius: 12px;
    }

    /* hint spacing */
    #cart #itemSearchHint {
        margin-top: 0.4rem;
        font-size: 0.9rem;
        line-height: 1.3;
    }

    /* dropdown result list */
    #cart #itemSearchList {
        max-height: 260px;
        border-radius: 10px;
    }
}


/* =========================
   FINAL CART FIX - keep row layout
========================= */

#cart .cart-header .cart-item-grid,
#cart .cart-item-grid {
    display: grid !important;
    align-items: center;
    width: 100%;
    column-gap: 16px;
}

    #cart .cart-header .cart-item-grid > div,
    #cart .cart-item-grid > div {
        width: auto !important;
        max-width: none !important;
        flex: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Header + items with discount */
    #cart .cart-header .cart-item-grid,
    #cart .cart-item-grid.has-discount {
        grid-template-columns: minmax(0, 42%) 13% 11% 21% 13%;
        grid-template-areas: "product price discount quantity total";
    }

    /* Items without discount */
    #cart .cart-item-grid.no-discount {
        grid-template-columns: minmax(280px, 1fr) 100px 160px 110px;
        grid-template-areas: "product price quantity total";
    }

#cart .cart-product-cell {
    grid-area: product;
    min-width: 0;
}

#cart .cart-price-cell {
    grid-area: price;
    text-align: center;
}

#cart .cart-discount-cell {
    grid-area: discount;
    text-align: center;
}

#cart .cart-qty-cell {
    grid-area: quantity;
    text-align: center;
}

#cart .cart-total-cell {
    grid-area: total;
    text-align: right;
}

#cart .cart-item .quantity-selector {
    width: 130px !important;
    min-width: 130px !important;
    max-width: 130px !important;
}

#cart .cart-item .quantity-btn {
    flex: 0 0 38px !important;
    width: 38px !important;
}

#cart .cart-item .quantity-input {
    flex: 0 0 42px !important;
    width: 42px !important;
    min-width: 42px !important;
}

#cart .line-total {
    white-space: nowrap;
}

/* Narrow desktop/tablet inside cart column */
@media (max-width: 1199.98px) {
    #cart .cart-header .cart-item-grid,
    #cart .cart-item-grid.has-discount {
        grid-template-columns: minmax(0, 42%) 13% 11% 21% 13%;
        column-gap: 0;
    }

    #cart .cart-item-grid.no-discount {
        grid-template-columns: minmax(200px, 1fr) 75px 135px 85px;
        column-gap: 10px;
    }

    #cart .cart-item .product-image {
        flex: 0 0 72px;
        width: 72px;
        height: 72px;
    }

    #cart .cart-item .quantity-selector {
        width: 128px !important;
        min-width: 128px !important;
        max-width: 128px !important;
    }

    #cart .cart-item .quantity-btn {
        flex-basis: 32px !important;
        width: 32px !important;
    }

    #cart .cart-item .quantity-input {
        flex-basis: 38px !important;
        width: 38px !important;
        min-width: 38px !important;
    }
}

/* Only mobile stacks */
@media (max-width: 575.98px) {
    #cart .cart-header {
        display: none !important;
    }

    #cart .cart-item-grid.has-discount,
    #cart .cart-item-grid.no-discount {
        grid-template-columns: 1fr;
        grid-template-areas:
            "product"
            "price"
            "discount"
            "quantity"
            "total";
    }
}


/* =========================
   Final mobile resize fix
   Avoid qty/total collision
========================= */
@media (max-width: 767.98px) {
    #cart .cart-header {
        display: none !important;
    }

    #cart .cart-item-grid.has-discount,
    #cart .cart-item-grid.no-discount {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "product product"
            "price discount"
            "quantity quantity"
            "total total";
        column-gap: 12px;
        row-gap: 10px;
        align-items: center;
    }

    #cart .cart-product-cell {
        grid-area: product;
    }

    #cart .cart-price-cell {
        grid-area: price;
        text-align: left !important;
    }

    #cart .cart-discount-cell {
        grid-area: discount;
        text-align: right !important;
    }

    #cart .cart-qty-cell {
        grid-area: quantity;
        text-align: left !important;
    }

    #cart .cart-total-cell {
        grid-area: total;
        text-align: left !important;
    }

    #cart .cart-item .quantity-selector {
        width: 140px !important;
        min-width: 140px !important;
        max-width: 140px !important;
        margin-inline: 0 !important;
    }

    #cart .cart-total-cell .item-total::before {
        content: "Total: ";
        font-weight: 600;
        color: var(--default-color);
        margin-right: 5px;
    }

    #cart .cart-price-cell .price-tag::before {
        content: "Price: ";
        font-weight: 600;
        color: var(--default-color);
        margin-right: 5px;
    }

    #cart .cart-discount-cell .item-discount::before {
        content: "Discount: ";
        font-weight: 600;
        color: var(--default-color);
        margin-right: 5px;
    }

    #cart .line-total,
    #cart .current-price {
        white-space: nowrap;
    }
}


/* =========================
   Cart narrow-column layout
   Fix collision when summary is beside cart
========================= */
@media (max-width: 1199.98px) {
    #cart .cart-header {
        display: none !important;
    }

    #cart .cart-header-mobile {
        display: block !important;
    }

    #cart .cart-item-grid.has-discount,
    #cart .cart-item-grid.no-discount {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "product product"
            "price discount"
            "quantity quantity"
            "total total";
        column-gap: 12px;
        row-gap: 10px;
        align-items: center;
    }

    #cart .cart-product-cell {
        grid-area: product;
    }

    #cart .cart-price-cell {
        grid-area: price;
        text-align: left !important;
    }

    #cart .cart-discount-cell {
        grid-area: discount;
        text-align: right !important;
    }

    #cart .cart-qty-cell {
        grid-area: quantity;
        text-align: left !important;
    }

    #cart .cart-total-cell {
        grid-area: total;
        text-align: left !important;
    }

    #cart .cart-item .quantity-selector {
        width: 145px !important;
        min-width: 145px !important;
        max-width: 145px !important;
        margin-inline: 0 !important;
    }

    #cart .cart-price-cell .price-tag::before {
        content: "Price: ";
        font-weight: 600;
        color: var(--default-color);
        margin-right: 5px;
    }

    #cart .cart-discount-cell .item-discount::before {
        content: "Discount: ";
        font-weight: 600;
        color: var(--default-color);
        margin-right: 5px;
    }

    #cart .cart-total-cell .item-total::before {
        content: "Total: ";
        font-weight: 600;
        color: var(--default-color);
        margin-right: 5px;
    }
}

/* Shipping Information link.
   Keeps the original shipping row layout intact and follows the Theme Engine. */
#cart .summary-label .shipping-info-link {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: 0.2rem;
    color: var(--accent-color);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    vertical-align: middle;
    white-space: nowrap;
}

    #cart .summary-label .shipping-info-link i {
        color: inherit;
        font-size: 0.8rem;
    }

    #cart .summary-label .shipping-info-link span {
        text-decoration: underline;
        text-underline-offset: 2px;
    }

    #cart .summary-label .shipping-info-link:hover {
        color: var(--accent-variant);
    }

    #cart .summary-label .shipping-info-link:focus-visible {
        outline: 2px solid var(--accent-color);
        outline-offset: 2px;
        border-radius: 4px;
    }
