/* ──────────────────────────────────────────────────────────────────────────
   Sales Order — POS layout: product catalog pane, cart pane and checkout.

   These rules style markup that lives in child components of SalesOrderForm
   (ProductPane / CartPane / OrderSummary). Blazor's scoped CSS stamps its
   isolation attribute only on a component's own elements, so rules kept in
   SalesOrderForm.razor.css never matched the child markup even under ::deep —
   the catalog rendered unstyled. They live here as global rules instead,
   namespaced by the pos-/cart- prefixes.
   ────────────────────────────────────────────────────────────────────────── */

/* ── Page-standard type scale ──
   The POS page reads at the theme's fs-3 (1.5rem on desktop) so it stays legible
   at arm's length; form controls and buttons scale up with it. */
.pos-page {
    font-size: calc(1.275rem + 0.3vw);
}

@media (min-width: 1200px) {
    .pos-page {
        font-size: 1.5rem;
    }
}

.pos-page .form-control,
.pos-page .form-control-sm {
    font-size: 1.15rem;
}

.pos-page .btn {
    font-size: 1.1rem;
}

/* ── Two-pane POS layout ──
   The panes sit in a standard bootstrap row (col-lg-7 / col-lg-5). The theme
   sizes every .card to calc(100% - 30px) with a 1.875rem bottom margin, which
   stretched the pane to its column height and spread the cart line cards apart -
   neutralize both inside the panes so cards take their natural height. */
.pos-cart-pane,
.pos-cart-pane .card,
.pos-grid > .pos-card {
    height: auto;
    margin-bottom: 0;
}

/* Search + filter chips stay reachable while the grid scrolls under them. */
.pos-pane-toolbar {
    position: sticky;
    top: 4.25rem;
    z-index: 5;
    background: #fff;
    padding-bottom: 0.5rem;
}

/* Fixed bottom summary bar for small screens; hidden on desktop where the
   cart pane is always visible. */
.pos-mobile-bar {
    display: none;
}

@media (max-width: 991.98px) {
    .pos-mobile-bar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        background: #00273a;
        color: #fff;
        padding: 0.6rem 1rem;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        box-shadow: 0 -0.25rem 0.75rem rgba(0, 0, 0, 0.2);
    }

    /* Keeps the last cart rows tappable above the fixed bar. */
    .pos-page-pad {
        padding-bottom: 4.5rem;
    }
}

.pos-category-menu {
    max-height: 320px;
    overflow-y: auto;
}

/* ── Product grid ──
   One product per row at every width, so each card gets the full pane width
   and the name, SKU and price read on a single line-up. */
.pos-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
}

/* ── Product card ──
   A horizontal row: media rail, text column, price rail. The three rails keep
   image, name and amount each on a fixed x so a long pane scans as columns
   rather than as a stack of independently-shaped cards. */
.pos-card {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 0.875rem;
    padding: 0.75rem;
    cursor: pointer;
    background: #fff;
    border: 1px solid #e6ebf1;
    border-radius: 0.5rem;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.pos-card:hover {
    border-color: #547792;
    box-shadow: 0 0.375rem 0.875rem rgba(26, 50, 99, 0.12);
    transform: translateY(-1px);
}

/* Already in the order: a left border rather than a full outline, so the
   selected state reads without the card jumping in weight. */
.pos-card-selected {
    border-color: #1A3263;
    box-shadow: inset 0.25rem 0 0 #1A3263;
}

.pos-card-muted {
    opacity: 0.6;
}

/* Exhausted differs from muted: the order already holds every available unit,
   so adding is refused and the card must not invite a tap. */
.pos-card-exhausted {
    cursor: not-allowed;
}

.pos-card-exhausted:hover {
    transform: none;
    border-color: #e6ebf1;
    box-shadow: none;
}

/* ── Media rail ── */
.pos-media {
    position: relative;
    flex: 0 0 76px;
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f7fa;
    border-radius: 0.375rem;
    overflow: hidden;
}

.pos-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pos-media-icon {
    font-size: 1.75rem;
    color: #547792;
}

/* Count of this product already in the order. Anchored to the card's own
   top-right corner - it describes the whole line, not the thumbnail. */
.pos-incart {
    position: absolute;
    /* Inset rather than hanging off the corner: the card spans the full pane
       width, so a negative offset risks clipping at the pane boundary. */
    top: 0.4rem;
    right: 0.4rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    height: 1.5rem;
    padding: 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: #1A3263;
    border: 2px solid #fff;
    border-radius: 0.75rem;
    box-shadow: 0 0.125rem 0.25rem rgba(26, 50, 99, 0.25);
}

.pos-incart i {
    font-size: 0.7rem;
    opacity: 0.85;
}

/* The badge occupies the card's top-right, which is where the centred price
   rail would otherwise sit on a short card - drop the rail clear of it. */
.pos-card-selected .pos-pricing {
    padding-top: 1.35rem;
}

/* ── Text column ── */
.pos-detail {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
}

.pos-code {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8a97a6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The name is the anchor of the card, so it carries the weight and is the one
   element allowed two lines before it clips. */
.pos-name {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.25;
    color: #1A3263;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.pos-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.1rem;
    font-size: 0.8rem;
    line-height: 1;
}

/* Availability is a tinted pill rather than a solid badge - a row of solid
   colour blocks down the pane competes with the price for attention. */
.pos-stock {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.45rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.pos-stock.is-available {
    color: #15653f;
    background: #e6f4ec;
}

.pos-stock.is-empty,
.pos-stock.is-exhausted {
    color: #9b2c2c;
    background: #fdeaea;
}

.pos-stock.is-service {
    color: #1A3263;
    background: #e8eef7;
}

.pos-incoming,
.pos-category {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #8a97a6;
}

.pos-category::before {
    content: "";
    width: 0.25rem;
    height: 0.25rem;
    border-radius: 50%;
    background: #c7d0da;
}

/* ── Price rail ── */
.pos-pricing {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0.1rem;
    padding-left: 0.25rem;
    text-align: right;
}

.pos-price {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.1;
    color: #1A3263;
    white-space: nowrap;
}

.pos-uom {
    font-size: 0.75rem;
    color: #8a97a6;
    white-space: nowrap;
}

/* Affordance for the whole-card tap target. It brightens on hover so the card
   reads as a button without needing a real one competing for the click. */
.pos-add {
    margin-top: 0.3rem;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #547792;
    background: #f0f4f8;
    border-radius: 0.25rem;
    transition: color 0.12s ease, background-color 0.12s ease;
}

.pos-card:hover .pos-add {
    color: #fff;
    background: #1A3263;
}

.pos-card-exhausted:hover .pos-add {
    color: #9b2c2c;
    background: #fdeaea;
}

@media (max-width: 575.98px) {
    .pos-card {
        gap: 0.625rem;
        padding: 0.625rem;
    }

    .pos-media {
        flex-basis: 60px;
        width: 60px;
        height: 60px;
    }

    .pos-name {
        font-size: 0.95rem;
    }

    .pos-price {
        font-size: 1.1rem;
    }

    /* The add affordance is redundant on touch, where the tap target is the
       whole card and there is no hover to reveal it. */
    .pos-add {
        display: none;
    }
}

.pos-total {
    color: #1A3263;
}

.pos-cart-icon {
    color: #547792;
}

/* ── Cart lines ── */
/* Lets the product name truncate inside a flex row rather than widening it. */
.cart-line-main {
    min-width: 0;
}

/* Product names wrap onto as many lines as they need instead of being clipped —
   long descriptions are common and the item cell is the widest column anyway.
   overflow-wrap covers unbroken strings (SKU-like names) that have no space to break on. */
.cart-item-name {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Preserves the line breaks a user typed into a line item description. */
.text-prewrap {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ── Line amounts ──
   Right-aligned inputs on label/value rows; capped so the row reads label-left,
   figure-right without the input stretching the full card width. */
.cart-amount-input {
    max-width: 8rem;
}

/* ── Quantity stepper ──
   A compact inline -/+ control around a typeable box. The input is sized to the
   digits it holds so the two buttons stay adjacent rather than being pushed apart. */
.cart-qty-stepper .cart-qty-input {
    width: 3.5rem;
    min-width: 3.5rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

/* Transparent stepper buttons - the icons alone carry the control, so the button
   drops its background and border and only lifts a faint tint on hover. */
.cart-qty-stepper .cart-qty-btn {
    background-color: transparent;
    border-color: transparent;
    box-shadow: none;
}

.cart-qty-stepper .cart-qty-btn:hover:not(:disabled) {
    background-color: #e2e8f0;
}

/* Bootstrap's .btn:disabled only fades the button, but .text-dark sets the icon
   colour explicitly and would stay full strength - dim the icon itself so a
   stepper at the stock ceiling still reads as unavailable. */
.cart-qty-stepper .cart-qty-btn:disabled {
    background-color: transparent;
    opacity: 1;
}

.cart-qty-stepper .cart-qty-btn:disabled i {
    color: #adb5bd !important;
}

/* ── Editable field affordance ──
   Unit cost and quantity are the only two line fields a user can change, and in a
   dense table a bare bordered input reads as static text. A tinted well plus a
   visible border marks them as inputs at a glance; focus resolves to the standard
   bootstrap ring so the cue never competes with the real focus state. */
.cart-editable {
    background-color: #f1f5f9;
    border: 1px solid #94a3b8 !important;
    cursor: text;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.cart-editable:hover:not(:focus) {
    background-color: #e2e8f0;
    border-color: #547792 !important;
}

.cart-editable:focus {
    background-color: #fff;
    border-color: #547792 !important;
}

/* Readonly quantity (non-tracked goods derive it from the stock dialog) must NOT
   read as editable - it keeps the flat, borderless look of a value cell. */
.cart-readonly {
    background-color: transparent;
    border: 1px solid transparent !important;
    cursor: default;
    box-shadow: none;
}

