/* Copyright (c) Zhmara X. All rights reserved.
   Proprietary and confidential. Unauthorized copying of this file, via any medium, is prohibited. See LICENSE.txt. */

/* POS screen (PosLayout + Pos.razor). The screen is exactly one window tall and the page never scrolls: only the
   product grid and the cart lines scroll, each inside its own panel. Products take the wide side, the cart the
   narrow one; on a phone the cart becomes a sheet that slides up from a bar at the bottom. Highlights and buttons
   use the app's purple (#7539FF, the theme's btn-primary). Logical properties, so Arabic and Kurdish mirror it. */

.zx-pos {
    --pos-accent: #7539FF;
    --pos-accent-soft: rgba(117, 57, 255, .10);
    --pos-border: var(--bs-border-color, #e5e5ef);
    --pos-panel: var(--bs-body-bg, #fff);
    --pos-bg: var(--bs-tertiary-bg, #f5f5fa);
    --pos-muted: #8a8a8a;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--pos-bg);
}

/* ---- Layout frame: slim top bar, the POS, one copyright line ---- */

.zx-pos-top {
    flex: none;
    display: flex;
    align-items: center;
    padding: 6px 16px;
    background: var(--pos-panel);
    border-bottom: 1px solid var(--pos-border);
}

.zx-pos-top .zx-pos-fullscreen {
    margin-inline-start: auto;
}

.zx-pos-top img {
    height: 30px;
    width: auto;
}

.zx-pos-body {
    flex: 1 1 auto;
    min-height: 0;
}

.zx-pos-foot {
    flex: none;
    padding: 2px 16px 4px;
    text-align: center;
    font-size: 12px;
    color: var(--pos-muted);
}

.zx-pos-foot a {
    color: inherit;
}

/* ---- Two panels ---- */

.zx-pos-main {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 65fr) minmax(340px, 35fr);
    gap: 12px;
    padding: 12px;
}

.zx-pos-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--pos-panel);
    border: 1px solid var(--pos-border);
    border-radius: 12px;
    overflow: hidden;
}

/* ---- Products: search, category chips, grid ---- */

.zx-pos-products-head {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--pos-border);
}

.zx-pos-search {
    position: relative;
}

.zx-pos-search .form-control {
    height: 42px;
    padding-inline-start: 38px;
}

.zx-pos-search > i {
    position: absolute;
    top: 50%;
    inset-inline-start: 13px;
    transform: translateY(-50%);
    color: var(--pos-muted);
    pointer-events: none;
}

.zx-pos-search .form-control:focus {
    border-color: var(--pos-accent);
    box-shadow: 0 0 0 3px var(--pos-accent-soft);
}

.zx-pos-search .options {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline: 0;
    z-index: var(--zx-z-page-popup);
    max-height: 50vh;
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--pos-panel);
    border: 1px solid var(--pos-border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .1);
}

.zx-pos-search .options li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: auto;
    padding: 8px 12px;
}

.zx-pos-search .options li:hover {
    background: var(--pos-accent-soft);
    color: var(--pos-accent);
}

.zx-pos-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
}

.zx-pos-chip {
    flex: none;
    padding: 6px 14px;
    border: 1px solid var(--pos-border);
    border-radius: 999px;
    background: var(--pos-panel);
    color: inherit;
    font-size: .875rem;
    white-space: nowrap;
    transition: border-color .15s, background-color .15s, color .15s;
}

.zx-pos-chip:hover {
    border-color: var(--pos-accent);
    color: var(--pos-accent);
}

.zx-pos-chip.is-active {
    border-color: var(--pos-accent);
    background: var(--pos-accent);
    color: #fff;
}

.zx-pos-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    align-content: start;
    gap: 10px;
    padding: 12px;
}

.zx-pos-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 8px;
    border: 1px solid var(--pos-border);
    border-radius: 10px;
    background: var(--pos-panel);
    color: inherit;
    text-align: start;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, transform .05s;
}

.zx-pos-card:hover,
.zx-pos-card:focus-visible {
    border-color: var(--pos-accent);
    box-shadow: 0 0 0 3px var(--pos-accent-soft);
    outline: none;
}

.zx-pos-card:active {
    transform: scale(.98);
}

.zx-pos-card.in-cart {
    border-color: var(--pos-accent);
}

.zx-pos-card.is-out {
    opacity: .55;
}

.zx-pos-card-img {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    margin-bottom: 6px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--pos-bg);
}

.zx-pos-card-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.zx-pos-card-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.5em;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.25;
}

.zx-pos-card-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
    margin-top: auto;
    padding-top: 4px;
    font-size: .8rem;
}

.zx-pos-card-price {
    color: var(--pos-accent);
    font-weight: 700;
}

.zx-pos-card-stock {
    color: var(--pos-muted);
    white-space: nowrap;
}

.zx-pos-card.is-out .zx-pos-card-stock {
    color: var(--bs-danger, #dc3545);
}

.zx-pos-card-badge {
    position: absolute;
    top: 6px;
    inset-inline-end: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--pos-accent);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
}

.zx-pos-empty {
    grid-column: 1 / -1;
    padding: 40px 0;
    text-align: center;
    color: var(--pos-muted);
}

.zx-pos-empty img {
    max-width: 160px;
    margin-bottom: 8px;
}

/* ---- Cart: customer + options, lines, totals and buttons ---- */

.zx-pos-cart-head {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--pos-border);
}

.zx-pos-cart-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zx-pos-cart-row .wrapper1 {
    flex: 1 1 auto;
    min-width: 0;
    float: none;
}

.zx-pos-icon-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--pos-border);
    border-radius: 8px;
    background: var(--pos-panel);
    color: inherit;
}

.zx-pos-icon-btn:hover,
.zx-pos-icon-btn.is-active {
    border-color: var(--pos-accent);
    background: var(--pos-accent-soft);
    color: var(--pos-accent);
}

.zx-pos-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.zx-pos-options label {
    display: block;
    margin-bottom: 2px;
    font-size: .75rem;
    color: var(--pos-muted);
}

.zx-pos-lines {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0 12px;
}

.zx-pos-line {
    padding: 10px 0;
    border-bottom: 1px dashed var(--pos-border);
}

.zx-pos-line:last-child {
    border-bottom: 0;
}

.zx-pos-line-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.zx-pos-line-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .9rem;
    font-weight: 600;
}

.zx-pos-line-del {
    flex: none;
    padding: 0 4px;
    border: 0;
    background: none;
    color: var(--bs-danger, #dc3545);
}

.zx-pos-line-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.zx-pos-line-rate {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .8rem;
    color: var(--pos-muted);
}

.zx-pos-stepper {
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--pos-border);
    border-radius: 8px;
}

.zx-pos-stepper button {
    width: 32px;
    height: 32px;
    border: 0;
    background: var(--pos-accent-soft);
    color: var(--pos-accent);
    font-weight: 700;
}

.zx-pos-stepper button:hover {
    background: var(--pos-accent);
    color: #fff;
}

.zx-pos-stepper input {
    width: 56px;
    height: 32px;
    border: 0;
    background: transparent;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}

.zx-pos-stepper input::-webkit-inner-spin-button,
.zx-pos-stepper input::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.zx-pos-line-total {
    min-width: 90px;
    text-align: end;
    font-weight: 700;
    white-space: nowrap;
}

.zx-pos-line-total s {
    margin-inline-end: 6px;
    font-size: .8rem;
    font-weight: 400;
    color: var(--pos-muted);
}

.zx-pos-line-discount {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: .8rem;
    color: var(--pos-muted);
}

.zx-pos-line-discount label {
    margin: 0;
}

.zx-pos-line-discount .form-control {
    width: 110px;
    height: 30px;
}

/* Shortcut hints: F2 inside the search box, F9 on Cash Payment (js/pos-keys.js). Hidden on touch screens. */
.zx-pos-kbd {
    padding: 1px 6px;
    border: 1px solid currentColor;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-size: .7rem;
    font-weight: 600;
    opacity: .7;
}

.zx-pos-search .zx-pos-kbd {
    position: absolute;
    top: 50%;
    inset-inline-end: 10px;
    transform: translateY(-50%);
    color: var(--pos-muted);
    pointer-events: none;
}

.zx-pos-search .form-control {
    padding-inline-end: 44px;
}

@media (hover: none) {
    .zx-pos-kbd {
        display: none;
    }
}

.zx-pos-cart-empty {
    padding: 32px 0;
    text-align: center;
    color: var(--pos-muted);
}

.zx-pos-cart-empty img {
    max-width: 140px;
    margin-bottom: 8px;
}

.zx-pos-cart-foot {
    flex: none;
    padding: 12px;
    border-top: 1px solid var(--pos-border);
    background: var(--pos-bg);
}

.zx-pos-sum {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: .875rem;
}

.zx-pos-sum-discount {
    display: flex;
    align-items: center;
    gap: 6px;
}

.zx-pos-sum-discount .form-select {
    width: auto;
    height: 32px;
    padding-block: 0;
}

.zx-pos-sum-discount .form-control {
    width: 110px;
    height: 32px;
}

.zx-pos-grand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 8px 0 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--pos-accent);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
}

.zx-pos-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.zx-pos-actions .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 42px;
}

/* Hold, Print bill, Approved in one row; the payment buttons below them. */
.zx-pos-actions .btn-outline-primary {
    flex-basis: calc(33.333% - 8px);
    padding-inline: 4px;
}

/* ---- Held sales: the icon with its count, the banner on a held sale, the list ---- */

.zx-pos-held-btn {
    position: relative;
}

.zx-pos-held-count {
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--pos-accent);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
}

.zx-pos-held-banner {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--pos-accent-soft);
    color: var(--pos-accent);
    font-size: .85rem;
    font-weight: 600;
}

.zx-pos-banner-link {
    margin-inline-start: auto;
    color: inherit;
    text-decoration: underline;
}

.zx-pos .zx-pos-held-list,
.zx-pos-held-list {
    max-height: 70vh;
    overflow-y: auto;
}

.zx-pos-held-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 4px;
    border-bottom: 1px dashed var(--bs-border-color, #e5e5ef);
}

.zx-pos-held-row:last-child {
    border-bottom: 0;
}

.zx-pos-held-row.is-current {
    background: rgba(117, 57, 255, .10);
    border-radius: 8px;
}

.zx-pos-held-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.zx-pos-held-info small {
    color: #8a8a8a;
}

.zx-pos-held-total {
    white-space: nowrap;
}

.zx-pos-held-row .zx-pos-line-del {
    border: 0;
    background: none;
    color: var(--bs-danger, #dc3545);
}

/* Phone only: the bar that opens the cart, the sheet's close button and its backdrop. */
.zx-pos-cartbar,
.zx-pos-sheet-close,
.zx-pos-backdrop {
    display: none;
}

/* ---- Tablet ---- */
@media (max-width: 1199.98px) {
    .zx-pos-main {
        grid-template-columns: minmax(0, 55fr) minmax(300px, 45fr);
    }

    .zx-pos-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
}

/* ---- Phone: products fill the screen, the cart slides up as a sheet ---- */
@media (max-width: 767.98px) {
    .zx-pos-top,
    .zx-pos-foot {
        display: none;
    }

    .zx-pos-main {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .zx-pos-products {
        flex: 1 1 auto;
    }

    .zx-pos-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .zx-pos-cartbar {
        flex: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        min-height: 52px;
        padding: 0 16px;
        border: 0;
        border-radius: 12px;
        background: var(--pos-accent);
        color: #fff;
        font-weight: 700;
    }

    .zx-pos-cart {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 30;
        height: 88vh;
        height: 88dvh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, .15);
        transform: translateY(105%);
        transition: transform .25s ease;
    }

    .zx-pos-cart.is-open {
        transform: none;
    }

    .zx-pos-backdrop.is-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(10, 10, 10, .3);
    }

    .zx-pos-sheet-close {
        display: inline-flex;
    }
}

@media print {
    .zx-pos {
        height: auto;
        overflow: visible;
    }
}
