/* Scanner-only style additions. Loaded after theme.css + app.css (+ tw-compat.css)
   on every scanner page. The scanner shares the operator shell (x-topbar /
   x-sidebar / user-avatar), so the old custom kiosk header, avatar dropdown and
   Change-PIN modal styles that lived here have been removed — the user-avatar
   widget now provides dark-mode toggle, Change PIN and Log out. What remains is
   the scan-specific chrome (scan control row, tiles, tables, toggles). */

/* ===== Scan control row on /scanner =====
   Four columns: SKU input (wide) | Logged in as | Set Mode (narrow) | Log Scan
   matching the original scanner layout. */
.scan-control {
    display: grid;
    /* SKU shrunk; the Inventory-Mode cell is content-sized (max-content) so it
       hugs the right edge instead of leaving a wide empty gap beside it. */
    grid-template-columns: 1.5fr 1.2fr 1fr 1.4fr max-content;
    gap: 1rem;
    align-items: end;
}
/* Inventory Mode cell mirrors the Log Scan / Add Item cell: centered label on
   top, control below. Match the button's height so the two labels line up and
   center the slider in it. */
.scan-inv-toggle {
    justify-content: center;
    min-height: 2.4rem;
}
@media (max-width: 900px) {
    .scan-control { grid-template-columns: 1fr 1fr; }
}
/* ── SKU scan field (shared by every scanner page) ───────────────────────────
   Many instances also carry .tb-input (topbar-search vocab), which brings an
   absolutely-positioned icon, a width:100% input and a rounded INNER focus ring
   — all wrong here. These rules normalise the field to one flat bordered flex
   row: in-flow icon with room before the input, a flexible input with NO inner
   border/curve, and the focus ring on the whole wrap (matching inventory inputs). */
.scan-input-wrap {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.scan-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Leading scan icon, when present: in flow + vertically centred + spaced.
   Resets the absolute position/transform inherited from .tb-input svg. */
.scan-input-wrap > i,
.scan-input-wrap > svg {
    position: static;
    transform: none;
    flex: 0 0 auto;
    align-self: center;
    margin: 0 10px 0 12px;
    width: 18px;
    height: 18px;
    color: var(--text-subtle);
}
.scan-input-wrap input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    height: auto;
    padding: 0.72rem 0.5rem;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}
/* Kill the rounded inner focus ring the .tb-input input draws on click — the
   focus state lives on the wrap above instead. */
.scan-input-wrap input:focus { outline: none; box-shadow: none; border: none; }
.scan-input-wrap .clear-btn {
    flex: 0 0 auto;
    align-self: center;
    background: none;
    border: none;
    margin-right: 4px;
    padding: 0 0.55rem;
    color: var(--text-subtle);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
}
.scan-input-wrap .clear-btn:hover { color: var(--text); }
/* the clear × is the Lucide x, in a box a finger can hit */
.scan-input-wrap .clear-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; }
.scan-input-wrap .clear-btn svg, .scan-input-wrap .clear-btn i[data-lucide] { position: static; transform: none; width: 16px; height: 16px; }
.scan-input-wrap .camera-btn { min-width: 44px; }
/* a field whose value was accepted (a location set once for a batch): its box goes green
   — the Scanner mock's .sc-input.ok */
.scan-input-wrap.is-ok { border-color: var(--green); }

/* The item a scan found (Scanner Dashboard, Bulk Scanner, In-House Repair): its photos
   beside its name and SKU, on the scan card's quiet surface — the mock's .sc-item. */
.scan-item-card { margin: 14px 0 0; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.scan-item { display: flex; align-items: center; gap: 14px; min-width: 0; }
.scan-item-photo { flex: none; width: 84px; height: 84px; object-fit: cover; border-radius: 12px; background: var(--surface-3); }
.scan-item-text { min-width: 0; }
.scan-item-text h3 { margin: 0; font: 600 18px/1.25 var(--font-display); letter-spacing: -.02em; color: var(--text); overflow-wrap: anywhere; }
.scan-item-text p { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }
.scan-item-card .scan-item-error { margin: 0; color: var(--red); font-weight: 600; }
@media (max-width: 480px) {
  .scan-item-photo { width: 64px; height: 64px; }
  .scan-item-text h3 { font-size: 16px; }
}
.scan-input-wrap .camera-btn {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: none;
    border-left: 1px solid var(--border);
    padding: 0 0.9rem;
    cursor: pointer;
    color: var(--accent);
}
.scan-input-wrap .camera-btn:hover { background: var(--accent-soft); }
.scan-input-wrap .camera-btn i,
.scan-input-wrap .camera-btn svg {
    position: static;
    left: auto;
    transform: none;
    width: 18px;
    height: 18px;
}
/* Location picker (datalist input): hide the browser's native dropdown arrow
   and draw the same Lucide chevron-down the inventory/select dropdowns use. */
.location-pick input::-webkit-calendar-picker-indicator {
    display: none !important;
    -webkit-appearance: none;
    appearance: none;
}
.scan-input-wrap .scan-chevron {
    flex: 0 0 auto;
    align-self: center;
    margin: 0 2px 0 4px;
    width: 16px;
    height: 16px;
    color: var(--text-subtle);
    cursor: pointer;
}
.scan-input-wrap .scan-chevron:hover { color: var(--text); }

/* Segmented IN | OUT pair — buttons are visually joined (no gap, shared
   border) so they read as one toggle instead of two loose buttons. */
.scan-mode-row {
    display: flex;
    width: 100%;
}
.scan-mode-row .scan-mode-btn {
    flex: 1;
    border-radius: 0;
    border-right: none;
    margin: 0;
}
.scan-mode-row .scan-mode-btn:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}
.scan-mode-row .scan-mode-btn:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    border-right: 1px solid var(--border-subtle);
}
.scan-mode-btn {
    padding: 0.6rem 0;
    border: 1px solid var(--border-subtle);
    background: var(--surface);
    color: var(--text-subtle);
    font-weight: 700;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.scan-mode-btn:hover { background: var(--surface-2); }
/* The chosen side is SELECTED, so it takes the accent — never green / red, which
   mean done / failed (the colour system; the approved Scanner mock, 2026-10-22:
   "the IN / OUT switch is a segmented control: the chosen side takes the tint"). */
.scan-mode-btn.active.in,
.scan-mode-btn.active.out,
.scan-mode-btn.active.add  { background: var(--accent); color: var(--on-brand); border-color: var(--accent); }
.scan-mode-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Touch: the switch is a tap target like every button (≥36px — mobile.css). */
@media (pointer: coarse) { .scan-mode-btn { min-height: 44px; } }

/* ===== Scanner navigation tile grid (under the scan box on dashboard) ===== */
.scanner-tile-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}
/* Dashboard quick actions: a FIXED 3-across block instead of wrap-flex. The
   wrapping version fitted 3 tiles on a laptop and 4 on a wide monitor, so the
   column's width — and with it the Log scan card beside it — changed with the
   viewport. Three fixed columns give the tile block an intrinsic width, which
   is what lets the dashboard split below hand ALL the remaining room to the
   scan card. (The base wrap-flex stays: the Orders location picker wants it.)
   minmax(0, …) so the three columns shrink rather than overflow once the two
   columns stack on a narrow screen. */
.scanner-tile-grid.cols-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 165px));
    justify-content: start;
}
/* The tile's own cap is the column's job here — let it fill its cell. */
.scanner-tile-grid.cols-3 > .scanner-tile { max-width: none; }

/* Dashboard split: tiles take exactly the width of those three columns, the
   Log scan card takes everything left over. Above the stacking breakpoint only
   — below it, app.css's own .cols-2 media rule collapses both to one column.
   (The page used to set 1fr 1.7fr from an inline <style>, whose two-class
   specificity beat that media rule and quietly kept the dashboard in two
   columns on a tablet.) */
@media (min-width: 1101px) {
    body[data-page="scanner"] .grid.cols-2 { grid-template-columns: max-content 1fr; }
}
/* Quick-action tiles: the Settings home's tile look (app.css .tile) — a plain
   surface tile, its icon in the one neutral icon chip, a hover that only
   darkens the border. No per-tile colours, no hover underline. */
.scanner-tile {
    flex: 1 1 200px;
    max-width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: border-color var(--dur-fast) var(--ease);
}
.scanner-tile:hover { border-color: var(--border-strong); }
.scanner-tile .tile-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}
.scanner-tile .tile-icon svg.lucide,.scanner-tile .tile-icon i[data-lucide] { width: 1.15rem; height: 1.15rem; }
.scanner-tile-label { font-weight: 600; }

/* Scan card: the plain app card, a little tighter at the bottom. */
.scan-card {
    padding-bottom: 0.85rem;
}

/* ===== Status pills, used for outstanding markers etc. ===== */
.status-pill {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.status-pill.green { background: var(--pill-green-bg); color: var(--pill-green-text); }
.status-pill.red   { background: var(--pill-red-bg); color: var(--pill-red-text); }
.status-pill.gray  { background: var(--border); color: var(--text-subtle); }
.status-pill.amber { background: var(--pill-amber-bg); color: var(--pill-amber-text); }

/* Use 90% of the viewport width on all scanner pages. */
/* Operator-shell main area (replaces the old centered kiosk container). Sits
   below the fixed x-topbar (--topbar-h) and right of the x-sidebar when present
   (operators); PIN-kiosk users have no sidebar so no left offset. */
.scanner-container { width: auto; max-width: none; margin: var(--topbar-h) 0 0 0;
  padding: 22px var(--view-pad-x) 48px; min-height: calc(100vh - var(--topbar-h)); box-sizing: border-box; }
/* …its side padding IS the scanner's page margin: the app's one margin (`.view`, app.css
   --view-pad-x; 16px at ≤768px, 12px at ≤480px — mobile.css "Scanner"). It kept 26px of its own,
   so a scanner page sat 8px in from every other page on a laptop and 14px on a phone
   (2026-10-10). src/ui/phone-layout-consistency.browser.test.js */
body[data-page="scanner"].has-rail .scanner-container { margin-left: calc(var(--rail-w) + var(--rail-inset) + var(--rail-gap)); }   /* the floating rail (app.css SIDEBAR) */
/* The page column inside it: no side padding (the container has it). This was an
   inline style on every scanner view; app.css "PAGE TITLE IN THE TOPBAR" trims
   its top on a desktop, where the title sits in the topbar. */
.scanner-container > .view { padding: 20px 0 40px; }
/* Desktop, title in the topbar (app.css "PAGE TITLE IN THE TOPBAR"): the page
   starts 15px under the bar and at the same left edge as every other page — under
   its title — like .main > .view does. Phone/tablet keep the spacing above. */
@media screen and (min-width: 1200px) {
  html[data-topbar-title] body[data-page="scanner"] .scanner-container:has(> .view > .page-head h1) { padding-top: 0; padding-left: var(--view-pad-x); padding-right: var(--view-pad-x); }
  html[data-topbar-title] body[data-page="scanner"] .scanner-container:has(> .view > .page-head h1) > .view { padding-top: 15px; }
}

/* Tailwind compat: a few classes the legacy scanner JS relies on. */
.hidden  { display: none !important; }
.opacity-50 { opacity: 0.5 !important; }

/* ===== Toggle switch ===== */
.scanner-toggle {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
}
.scanner-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.scanner-toggle .slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background-color: var(--border-subtle);
    transition: background-color var(--dur) var(--ease);
    border-radius: 999px;
}
.scanner-toggle .slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--surface);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform var(--dur) var(--ease);
}
.scanner-toggle input:checked + .slider { background-color: var(--accent); }
.scanner-toggle input:checked + .slider::before { transform: translateX(22px); }
.scanner-toggle input:focus-visible + .slider {
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.scanner-toggle-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-subtle);
    font-size: 0.9rem;
    cursor: pointer;
}

/* Form labels in scanner specific blocks. */
.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-subtle);
    margin-bottom: 0.35rem;
}
.field-help { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.4rem; }
.message-area { min-height: 1.25em; font-weight: 600; }
.message-area.success { color: var(--success); }
.message-area.error   { color: var(--danger); }
.message-area.info    { color: var(--accent); }
.actions-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.actions-row.end { justify-content: flex-end; }

/* Buttons on a scanner page are the app's own (.btn — app.css). The scanner's
   button "polish" (its own padding, a lift on hover, a Tailwind-utility button
   family for the JS-built rows) is gone (2026-10-22): a scanner button is the
   same size and presses the same way as everywhere else, and on a touch screen
   mobile.css grows it to 36px like every other. The page's one big scan action
   (Log Scan, Complete Picklist, Process Batch, Finish …) is .scan-cta. */
.scan-cta { width: 100%; justify-content: center; height: 46px; font-size: 14px; }

/* ===== Orders page: highlighted "Unmapped Orders" tile =====
   Sits at the top of the location-picker list and is visually
   unmissable so pickers know to handle these orders separately. */
.unmapped-orders-tile {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--warning-surface);
    border: 1px solid var(--warning-surface-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    color: var(--warning-surface-text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease);
    width: 100%;
    position: relative;
}

/* Open Orders' location picker: each storage location is a plain tile (the
   quick-action tile's look — a surface, a border, no colour of its own), its name
   over its warehouse. The orders waiting there are a count badge on its corner,
   amber — orders waiting on a picker (the colour system: amber = waiting on
   someone). Theme tokens only, so dark mode needs no override. */
.location-tile { position: relative; font: inherit; text-align: left; cursor: pointer; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-height: 56px; }
.scanner-tile-grid .location-tile { padding: 0.6rem 0.85rem; }
.location-tile .loc-name { font-weight: 600; font-size: 15px; line-height: 1.3; color: var(--text); }
.location-tile .loc-wh { font-size: 12.5px; line-height: 1.3; color: var(--text-muted); }
.order-count-badge {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 9999px;
    background: var(--amber);
    color: var(--on-brand);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    pointer-events: none;
}
/* the loading tiles hold the real tiles' box */
.location-tile.is-skel { cursor: default; pointer-events: none; }
.unmapped-orders-tile:hover { border-color: var(--warning); }
.unmapped-orders-tile .tile-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    background: transparent;
    color: var(--warning);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.unmapped-orders-tile .tile-icon svg.lucide,.unmapped-orders-tile .tile-icon i[data-lucide] { width: 1.25rem; height: 1.25rem; }
.unmapped-orders-tile h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--warning-surface-text);
    border: none;
    padding: 0;
}
.unmapped-orders-tile p {
    margin: 0.2rem 0 0 0;
    color: var(--warning-surface-text);
    font-size: 0.85rem;
    line-height: 1.4;
}
.unmapped-orders-tile .chevron {
    margin-left: auto;
    color: var(--warning);
    flex-shrink: 0;
    width: 1.1rem; height: 1.1rem;
}

/* ===================================================================
   Dark-mode overrides for scanner colors with no token equivalent.
   Light mode is untouched above; these only apply under
   html[data-theme="dark"]. Off-palette slate tints become dark
   surfaces; off-palette status shades use the theme.css pill-dark
   analogy values.
   =================================================================== */

/* Slate-tint hover/fill surfaces (no token match in light) → dark surfaces */
html[data-theme="dark"] .pin-keypad button:hover { background: var(--surface-3); }
html[data-theme="dark"] .pin-keypad button.utility { background: var(--surface-2); }
html[data-theme="dark"] .pin-keypad button.utility:hover { background: var(--surface-3); }

/* Status pills now use the theme-aware --pill-* token trios, which already
   adapt for dark mode — no per-theme override needed here. */

/* The Unmapped Orders tile and the count badge are theme tokens
   (--warning-surface*, --amber, --on-brand): no dark-mode override. */

/* Scanned-item remove button — matches the formula-editor token "x"
   (Lucide x icon, danger color) instead of a bare "×" glyph. */
.token-remove {
    margin-left: 1rem;
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    border-radius: 6px;
}
.token-remove:hover { background: var(--danger-soft, color-mix(in srgb, var(--danger) 14%, transparent)); }
@media (pointer: coarse) { .token-remove { min-width: 36px; min-height: 36px; } }
.token-remove i, .token-remove svg { width: 17px; height: 17px; position: static; left: auto; transform: none; }

/* Stocktake-report row spotlight — applied briefly when the operator opens a
   report from a product page's scanner-activity "View report" link, so they land
   on the SKU they came from. Fades out on its own (removed by JS after ~4s). */
/* Opaque tint (not translucent) so the global `tbody tr:hover` grey behind it
   can't wash the accent out — the row stays clearly spotlit even on hover. */
.stocktake-row-highlight > td,
.stocktake-row-highlight:hover > td {
    background: color-mix(in srgb, var(--accent) 26%, var(--surface)) !important;
    transition: background 0.5s ease;
}
.stocktake-row-highlight > td:first-child {
    box-shadow: inset 3px 0 0 0 var(--accent);
}

/* The camera box (#scanner-container, every scanner page): at most 560px wide,
   and never taller than the screen — the picture is square
   (ScannerScan.startConfig, scan-format.js), so a 560px box ran off the bottom
   of a phone held sideways (owner, 2026-10-08: "the overlay is quite large").
   html5-qrcode sizes the picture to this box's width when the camera starts. */
#scanner-container { max-width: min(560px, calc(var(--vh, 100vh) - 120px)); margin-inline: auto; }

/* The camera overlay (#scanner-overlay, every scanner page) is the full-bleed
   `.x-modal-backdrop.is-full` (App.modal — Esc, the close button and a click on
   the surround all stop the camera). The picture box and the hint under it: */
#scanner-overlay #scanner-container { width: 100%; background: var(--viewer-scrim); border-radius: 8px; overflow: hidden; position: relative; }
#scanner-overlay #scanner-message { margin: 0; color: var(--viewer-ctl-fg); }

/* A warning mark inside a line of text (the Order Picklist's bad-customer,
   mismatch and point-of-sale warnings): the Lucide alert-triangle, one text line
   tall. Never the ⚠ character — an iPhone draws it as a colour emoji
   (src/scanner/no-emoji-marks.test.js). The class rides from the <i> onto the
   <svg> Lucide swaps in, so this one rule sizes both. */
.scan-mark { width: 1em; height: 1em; vertical-align: -0.15em; margin-right: 0.3em; flex: 0 0 auto; }
