/*
 * sale.css
 *
 * Sale view: product search, category chips, product tiles (white image, no
 * add button, quantity badge top-right) and the basket sheet (customer and
 * Tax Free tiles, lines, totals, Card / Cash buttons).
 */

/* Same height as the other search bars (72px from base.css); less right padding for the clear button */
.sale-view .search {
    padding: 0 12px 0 22px;
}

/* ---------- Product tiles ---------- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 14px;
}

.product-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border: 0;
    border-radius: var(--r-26);
    background: var(--surface);
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.product-tile.in-cart {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.product-tile__media {
    aspect-ratio: 1 / 1;
    border-radius: var(--r-18);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--track-off);
    overflow: hidden;
}

.product-tile__media img {
    width: 90%;
    height: 90%;
    object-fit: contain;
}

.product-tile__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.product-tile__name {
    font-size: var(--fs-body);
    font-weight: 600;
    line-height: 1.35;
    min-height: 2.7em;
    max-height: 2.7em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-tile__price {
    font-size: var(--fs-lead);
    font-weight: 800;
    letter-spacing: -0.01em;
}

.product-tile__qty {
    position: absolute;
    top: 12px;
    right: 12px;
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    border-radius: var(--r-pill);
    background: var(--accent);
    color: var(--on-fill);
    font-size: var(--fs-secondary);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sf-pop var(--dur-fast) var(--ease);
}

@media (hover: hover) and (pointer: fine) {
    .product-tile:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-hover);
    }

    .product-tile.in-cart:hover {
        box-shadow: inset 0 0 0 2px var(--accent), var(--shadow-hover);
    }
}

.product-tile:active,
.product-tile.touch-active {
    transform: scale(.97);
}

/* ---------- Basket sheet ---------- */

.cart-sheet {
    gap: 0;
    padding: 0;
}

/* The basket keeps its total and Card / Cash in view: only the tiles and lines scroll */
.view-side > .cart-sheet {
    overflow: hidden;
}

.cart-sheet__grab {
    padding: 10px 0 4px;
    display: flex;
    justify-content: center;
    touch-action: none;
}

/* The collapsed summary bar is only used by the phone bottom sheet */
.cart-sheet__bar {
    display: none;
}

.cart-sheet__body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 20px 20px;
}

.cart-sheet__scroll {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0 -20px;
    padding: 0 20px;
}

.cart-sheet__footer {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--hairline);
}

.cart-sheet__collapse {
    display: none;
}

.customer-tile__x {
    display: none;
}

.cart-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 36px;
}

.cart-sheet__title {
    font-size: var(--fs-title);
}

.cart-sheet__count {
    margin-left: 2px;
    font-size: var(--fs-body);
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0;
}

.cart-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.customer-tile {
    position: relative;
    min-width: 0;
    border-radius: var(--r-24);
    background: var(--surface-2);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.customer-tile__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.customer-tile__top .chip {
    padding: 4px 10px;
}

.customer-tile__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.customer-tile__name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-tile__meta {
    font-size: var(--fs-secondary);
    color: var(--muted);
}

.customer-tile__clear {
    align-self: flex-start;
    height: 30px;
    padding: 0 12px;
}

.customer-tile--empty {
    border: 0;
    transition: background-color var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}

@media (hover: hover) and (pointer: fine) {
    .customer-tile--empty:hover {
        background: var(--control);
    }
}

.customer-tile--empty .avatar {
    color: var(--accent);
}

/* Tax Free tile: a toggle, so it takes the solid accent fill when on */
.taxfree-tile {
    position: relative;
    min-width: 0;
    border-radius: var(--r-24);
    background: var(--surface-2);
    color: var(--ink);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}

.taxfree-tile:active:not(.is-locked),
.customer-tile--empty:active {
    transform: scale(.98);
}

@media (hover: hover) and (pointer: fine) {
    .taxfree-tile:hover {
        background: var(--control);
    }
}

.taxfree-tile__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--accent);
}

.taxfree-tile__text {
    display: flex;
    flex-direction: column;
}

.taxfree-tile__title {
    font-weight: 800;
    font-size: var(--fs-card);
}

.taxfree-tile__hint {
    font-size: var(--fs-secondary);
    color: var(--muted);
}

/* The whole tile is the hit area for the hidden checkbox */
.taxfree-tile .switch {
    position: static;
}

.taxfree-tile .switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--r-24);
}

.taxfree-tile.is-on {
    background: var(--accent);
    color: var(--on-fill);
}

@media (hover: hover) and (pointer: fine) {
    .taxfree-tile.is-on:hover {
        background: var(--accent-strong);
    }
}

.taxfree-tile.is-on .taxfree-tile__top {
    color: var(--on-fill);
}

.taxfree-tile.is-on .taxfree-tile__hint {
    color: var(--accent-on-muted);
}

/* On the solid tile the track takes the tile's lavender (one step off the surface, like the grey track when off);
   the knob stays white with its standard shadow, as on every other switch */
.taxfree-tile.is-on .switch input:checked + .switch__track {
    background: var(--accent-on-muted);
}

.taxfree-tile .switch input:focus-visible + .switch__track {
    outline-color: var(--on-fill);
}

.taxfree-tile:has(input:focus-visible) {
    outline: 3px solid var(--accent-ring);
    outline-offset: 2px;
}

/* Lines */
.cart-lines {
    list-style: none;
    display: flex;
    flex-direction: column;
}

.cart-lines__empty {
    padding: 32px 0;
}

.cart-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 0;
    border-radius: var(--r-16);
}

.cart-line + .cart-line {
    border-top: 1px solid var(--hairline);
}

.cart-line.just-updated-in-cart {
    animation: sf-flash .6s ease-out;
}

.cart-line__thumb {
    width: 56px;
    height: 56px;
    border-radius: var(--r-16);
    border: 1px solid var(--hairline);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    overflow: hidden;
}

.cart-line__thumb img {
    width: 84%;
    height: 84%;
    object-fit: contain;
}

.cart-line__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cart-line__name {
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cart-line__meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-line__meta .chip {
    padding: 2px 8px;
}

.cart-line__total {
    font-weight: 800;
}

.cart-line__total.is-negative {
    color: var(--warning-text);
}

.stepper {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border-radius: var(--r-pill);
    background: var(--control);
    flex: none;
}

.stepper__btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--dur-fast) var(--ease), transform var(--dur-press) var(--ease);
}

@media (hover: hover) and (pointer: fine) {
    .stepper__btn:hover:not(:disabled) {
        background: var(--surface-2);
    }
}

.stepper__btn:active:not(:disabled) {
    transform: scale(.92);
}

.stepper__btn:disabled {
    opacity: .4;
}

.stepper__qty {
    min-width: 22px;
    text-align: center;
    font-weight: 800;
}

/* Totals */
.cart-figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.cart-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.cart-total__label {
    font-size: var(--fs-body);
    font-weight: 700;
    color: var(--muted);
}

.cart-total__amount {
    font-size: calc(var(--fs-amount-xl) * var(--amount-scale, 1));
    font-weight: 800;
    white-space: nowrap;
    letter-spacing: -0.04em;
    line-height: 1;
}

.cart-total__amount.is-negative {
    color: var(--warning-text);
}

/* VAT Exempt: the old amount sits struck through above the new one */
.cart-total.has-was {
    align-items: flex-end;
}

.cart-total__figures {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 0;
}

.cart-total__was {
    font-size: var(--fs-body);
    font-weight: 700;
    color: var(--muted);
    text-decoration-thickness: 2px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cart-total__amount {
    font-variant-numeric: tabular-nums;
}

.was-enter-active,
.was-leave-active {
    transition: opacity var(--dur-enter) var(--ease), transform var(--dur-enter) var(--ease);
}

.was-enter-from,
.was-leave-to {
    opacity: 0;
    transform: translateY(6px);
}

/* Korea VAT Exempt refund, taken off at the till */
.vatx {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 12px 12px 16px;
    border-radius: var(--r-24);
    background: var(--accent-tint);
    overflow: hidden;
}

.vatx__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.vatx__row--meta {
    align-items: center;
}

.vatx__title {
    font-weight: 800;
    color: var(--accent-strong);
}

.vatx__amount {
    font-size: var(--fs-title);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--accent-strong);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    padding-right: 4px;
}

.vatx__meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    font-size: var(--fs-secondary);
    color: var(--text-2);
    overflow-wrap: anywhere;
}

.vatx.is-voided,
.vatx.is-voiding {
    background: var(--surface-2);
}

.vatx.is-voided .vatx__title,
.vatx.is-voided .vatx__amount,
.vatx.is-voiding .vatx__title,
.vatx.is-voiding .vatx__amount {
    color: var(--ink);
}

.vatx.is-voided .vatx__amount {
    text-decoration: line-through;
    color: var(--muted);
}

.vatx-enter-active,
.vatx-leave-active {
    transition: opacity var(--dur-enter) var(--ease), max-height var(--dur-enter) var(--ease), transform var(--dur-enter) var(--ease);
    max-height: 160px;
}

.vatx-enter-from,
.vatx-leave-to {
    opacity: 0;
    max-height: 0;
    transform: translateY(-4px);
}

@media (prefers-reduced-motion: reduce) {
    .vatx-enter-active,
    .vatx-leave-active,
    .was-enter-active,
    .was-leave-active {
        transition: none;
    }
}

.cart-pay {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
}

.cart-pay--single {
    grid-template-columns: 1fr;
}

.cart-pay-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Tax Free form issued before payment (During Sales) */
.taxfree-issued {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 12px 16px;
    border-radius: var(--r-24);
    background: var(--accent-tint);
}

.taxfree-issued__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.taxfree-issued__title {
    font-weight: 800;
    color: var(--accent);
}

.taxfree-issued__meta {
    font-size: var(--fs-secondary);
    color: var(--text-2);
    overflow-wrap: anywhere;
}

/* Voided form: shown in grey for a moment before the basket unlocks */
.taxfree-issued.is-voided {
    background: var(--surface-2);
}

.taxfree-issued.is-voided .taxfree-issued__title {
    color: var(--ink);
}

/* Issue failed or cancelled: the reason stays until the cashier pays or issues again */
.taxfree-issued.is-error {
    background: var(--warning-tint);
}

.taxfree-issued.is-error .taxfree-issued__title {
    color: var(--warning-text);
}

.taxfree-issued__done {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Locked while a During Sales form is issued: still shows as on, but not tappable */
.taxfree-tile.is-locked {
    cursor: default;
}

@media (hover: hover) and (pointer: fine) {
    .taxfree-tile.is-locked:hover {
        background: var(--accent);
    }
}

@media (max-width: 1099px) and (min-width: 901px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .cart-total__amount {
        font-size: calc(var(--fs-amount) * var(--amount-scale, 1));
    }
}
