/* =========================================================
   includes/console.css — VioLev "Adventure / Labs" → Console

   /adventure/console/ — the CONG-INC company store, as a working
   point-of-sale. Two live panes on one screen:
     · REGISTER (left)    — the cashier's face: catalog → ticket → tender → receipt
     · BACK OFFICE (right) — the catalog CRUD + tax rate that FEEDS the register

   Both read and write one in-memory state object; any edit re-renders
   both panes, so a change in back office shows in the register instantly.
   Nothing is saved — refresh wipes it (the point: we keep nothing).

   Shell: the same fit-to-viewport single screen as the Locator (body is
   100dvh flex column via adventure.css). The page never scrolls; each
   pane is its own min-height:0 flex child that scrolls internally.

   A POS is software — it legitimately needs JS. PHP still renders the
   catalog as a static price list for no-JS visitors (the DATA degrades
   gracefully; the APPLICATION asks for JS), styled at the bottom here.
   ========================================================= */

/* ---- the section fills main; column: head + stage ---- */
.console {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  /* top padding clears the FIXED floating nav-island (~88px tall) at any height;
     the room is full-bleed under the nav by design, but the console has a real
     heading up top, so it must sit below the island. */
  padding: clamp(92px, 12vh, 112px) 0 clamp(12px, 2vh, 18px);
}
.console .container {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  /* fill the viewport like a real register (and like the room) instead of
     capping into a centred island that detaches with void gutters when zoomed
     out. Small symmetric side padding keeps it off the edges. */
  max-width: none; padding-left: clamp(16px, 3vw, 48px); padding-right: clamp(16px, 3vw, 48px);
}

.console-head { flex: 0 0 auto; display: flex; align-items: baseline; gap: 14px 18px; flex-wrap: wrap; margin-bottom: clamp(10px, 1.8vh, 16px); }
.console-head .label { color: var(--text-muted); }
.console-head .store-name { font-family: var(--display); font-weight: 600; font-size: clamp(1.1rem, 2.2vw, 1.5rem); color: var(--mist); letter-spacing: -.01em; }
.console-head .reset-tag {
  margin-left: auto; font-family: var(--mono); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted); border: 1px solid var(--border-secondary); border-radius: var(--radius-pill);
  padding: 5px 11px;
}

/* ---- the two-pane stage ---- */
.pos-stage { flex: 1 1 auto; min-height: 0; display: flex; gap: clamp(12px, 1.6vw, 22px); }

.pane {
  min-height: 0; display: flex; flex-direction: column;
  background: var(--bg-panel); border: 1px solid var(--border-primary); border-radius: var(--radius-lg);
  overflow: hidden;
}
.pos-register   { flex: 1.32 1 0; flex-direction: row; }   /* ~57% */
.pos-backoffice { flex: 1 1 0; }                           /* ~43% */

/* ===========================================================
   REGISTER (left pane): catalog (chips + grid) | ticket rail
   =========================================================== */
.pos-register { position: relative; }   /* anchors the tender/receipt overlay */

.reg-catalog { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border-secondary); }

/* category chips */
.reg-chips { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 8px; padding: clamp(12px, 1.6vw, 18px); border-bottom: 1px solid var(--border-secondary); }
.chip-cat {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--haze); background: none; border: 1px solid var(--border-primary); border-radius: var(--radius-pill);
  padding: 7px 13px; cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.chip-cat:hover { border-color: var(--border-active); color: var(--mist); }
.chip-cat.is-active { border-color: var(--violet); color: var(--mist); background: rgba(139,92,255,.12); box-shadow: var(--glow-violet-soft); }

/* product grid (scrolls) */
.reg-grid {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px;
  padding: clamp(12px, 1.6vw, 18px); align-content: start;
}
.prod-card {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left;
  padding: 12px; cursor: pointer;
  background: var(--bg-panel-strong); border: 1px solid var(--border-primary); border-radius: var(--radius-md);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.prod-card:hover, .prod-card:focus-visible { transform: translateY(-2px); border-color: var(--border-active); box-shadow: var(--glow-violet-soft); outline: none; }
.prod-card:active { transform: translateY(0); }
.prod-card .glyph {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; line-height: 1; border-radius: var(--radius-sm);
  background: rgba(139,92,255,.08); border: 1px solid var(--border-secondary);
}
.prod-card .p-name { font-size: .82rem; color: var(--mist); line-height: 1.3; }
.prod-card .p-price { font-family: var(--mono); font-size: .76rem; color: var(--violet-bright); margin-top: auto; }
.grid-empty { grid-column: 1 / -1; color: var(--text-muted); font-size: .9rem; line-height: 1.6; padding: 18px 4px; }
.grid-empty span { color: var(--violet-bright); }

/* ticket rail */
.reg-ticket { flex: 0 0 clamp(196px, 26%, 268px); display: flex; flex-direction: column; min-width: 0; }
.ticket-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.ticket-head .label { color: var(--haze); }
.ticket-clear { font-family: var(--mono); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); background: none; border: 0; cursor: pointer; padding: 2px; }
.ticket-clear:hover { color: var(--violet-bright); }
.ticket-clear[hidden] { display: none; }

.ticket-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; list-style: none; margin: 0; padding: 0 16px; }
.ticket-empty { color: var(--text-muted); font-size: .82rem; line-height: 1.6; padding: 8px 0; }
.tline { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 11px 0; border-bottom: 1px solid var(--border-secondary); }
.tline .tl-name { font-size: .82rem; color: var(--mist); line-height: 1.3; }
.tline .tl-amt { font-family: var(--mono); font-size: .78rem; color: var(--mist); text-align: right; white-space: nowrap; }
.tline .tl-ctrl { display: inline-flex; align-items: center; gap: 8px; }
.qbtn {
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: .9rem; line-height: 1; color: var(--haze);
  background: var(--bg-panel-strong); border: 1px solid var(--border-primary); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.qbtn:hover { border-color: var(--violet); color: var(--violet-bright); }
.tline .tl-qty { font-family: var(--mono); font-size: .76rem; color: var(--haze); min-width: 16px; text-align: center; }
.tline .tl-rm { font-family: var(--mono); font-size: .62rem; color: var(--text-muted); background: none; border: 0; cursor: pointer; padding: 0; }
.tline .tl-rm:hover { color: #ff9a9a; }

.ticket-foot { flex: 0 0 auto; padding: 14px 16px; border-top: 1px solid var(--border-secondary); background: var(--bg-panel-strong); }
.tot-row { display: flex; align-items: baseline; justify-content: space-between; font-size: .84rem; margin-bottom: 7px; }
.tot-row .tl { color: var(--text-secondary); }
.tot-row .tv { font-family: var(--mono); color: var(--mist); }
.tot-row.grand { margin: 10px 0 14px; padding-top: 11px; border-top: 1px solid var(--border-secondary); }
.tot-row.grand .tl { color: var(--mist); font-size: 1rem; }
.tot-row.grand .tv { color: var(--violet-bright); font-size: 1.1rem; }
.charge-btn { width: 100%; justify-content: center; }
.charge-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- tender / receipt overlay (covers the register only) ---- */
.reg-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  background: var(--abyss);   /* solid — the register must not bleed through the receipt */
  padding: clamp(18px, 2.4vw, 30px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: ovIn 260ms ease;
}
.reg-overlay[hidden] { display: none; }
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }
.ov-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: clamp(16px, 2.4vh, 24px); }
.ov-head .label { display: block; margin-bottom: 6px; color: var(--violet-bright); }
.ov-head h2 { font-family: var(--display); font-weight: 600; font-size: clamp(1.3rem, 2.6vw, 1.7rem); color: var(--mist); }
.ov-due { font-family: var(--mono); color: var(--violet-bright); font-size: clamp(1.4rem, 3vw, 1.9rem); }
.ov-close { flex: 0 0 auto; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-primary); border-radius: var(--radius-sm); color: var(--haze); font-size: 1.1rem; line-height: 1; cursor: pointer; background: none; }
.ov-close:hover { color: var(--mist); border-color: var(--border-active); background: rgba(139,92,255,.1); }

/* tender method toggle */
.tender-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tender-tab {
  flex: 1 1 0; font-family: var(--mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--haze); background: var(--bg-panel); border: 1px solid var(--border-primary); border-radius: var(--radius-sm);
  padding: 12px; cursor: pointer; transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.tender-tab.is-active { border-color: var(--violet); color: var(--mist); background: rgba(139,92,255,.1); }

.tender-pane { display: none; }
.tender-pane.is-active { display: block; animation: ovIn 200ms ease; }

/* cash */
.cash-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }
.cash-chip { font-family: var(--mono); font-size: .74rem; color: var(--haze); background: var(--bg-panel); border: 1px solid var(--border-primary); border-radius: var(--radius-sm); padding: 9px 13px; cursor: pointer; transition: border-color var(--transition-fast), color var(--transition-fast); }
.cash-chip:hover { border-color: var(--violet); color: var(--violet-bright); }
.cash-field label { display: block; font-family: var(--mono); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--haze); margin-bottom: 6px; }
.cash-field input {
  width: 100%; font-family: var(--mono); font-size: 1.1rem; color: var(--mist);
  background: rgba(6,4,12,.6); border: 1px solid var(--border-primary); border-radius: var(--radius-sm); padding: 12px 14px;
}
.cash-field input:focus { outline: none; border-color: var(--violet); box-shadow: var(--glow-violet-soft); }
.cash-change { margin: 16px 0 20px; display: flex; align-items: baseline; justify-content: space-between; }
.cash-change .cl { font-size: .9rem; color: var(--text-secondary); }
.cash-change .cv { font-family: var(--mono); font-size: 1.3rem; color: var(--violet-bright); }
.cash-change.short .cv { color: #ff9a9a; }

/* card */
.card-sim { text-align: center; padding: 10px 0 18px; }
.card-reader {
  width: 100%; max-width: 220px; margin: 0 auto 16px; aspect-ratio: 1.6;
  border: 1px dashed var(--border-active); border-radius: var(--radius-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--haze); font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  background: rgba(139,92,255,.04);
}
.card-reader .cr-icon { font-size: 1.6rem; }
.card-reader.approving { border-style: solid; border-color: var(--violet); color: var(--violet-bright); }
.card-reader .spinner { width: 22px; height: 22px; border: 2px solid var(--border-active); border-top-color: var(--violet-bright); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card-note {
  font-family: var(--mono); font-size: .6rem; letter-spacing: .04em; line-height: 1.7; color: var(--text-muted);
  max-width: 38ch; margin: 0 auto; text-transform: none;
}
.card-note strong { color: var(--haze); font-weight: 400; }

.ov-action { margin-top: auto; }
.ov-action .btn { width: 100%; justify-content: center; }
.ov-action .btn:disabled { opacity: .4; cursor: not-allowed; }

/* receipt */
.receipt-paper {
  background: rgba(6,4,12,.5); border: 1px solid var(--border-secondary); border-radius: var(--radius-md);
  padding: clamp(16px, 2.2vw, 24px); margin-bottom: 18px; font-family: var(--mono); font-size: .8rem; color: var(--text-secondary);
}
.receipt-paper .r-store { font-family: var(--display); font-size: 1rem; color: var(--mist); margin-bottom: 2px; }
.receipt-paper .r-meta { font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 14px; }
.receipt-paper .r-line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.receipt-paper .r-line .rl-q { color: var(--haze); }
.receipt-paper .r-sep { border-top: 1px dashed var(--border-secondary); margin: 10px 0; }
.receipt-paper .r-line.r-grand { color: var(--mist); }
.receipt-paper .r-line.r-grand .rl-v { color: var(--violet-bright); }
.receipt-paper .r-paid { color: var(--cyan); }
.receipt-kept { font-family: var(--mono); font-size: .62rem; letter-spacing: .06em; line-height: 1.7; color: var(--text-muted); margin-bottom: 18px; }
.receipt-kept strong { color: var(--haze); font-weight: 400; }

/* ===========================================================
   BACK OFFICE (right pane): table (scrolls) + add/edit form + tax
   =========================================================== */
.pos-backoffice { min-width: 0; }
.bo-head { flex: 0 0 auto; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 14px clamp(14px, 1.6vw, 18px) 10px; border-bottom: 1px solid var(--border-secondary); }
.bo-head .label { color: var(--haze); }
.bo-head .bo-hint { font-family: var(--mono); font-size: .58rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }

.bo-table-wrap { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.bo-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.bo-table thead th {
  position: sticky; top: 0; z-index: 1; text-align: left; background: var(--bg-panel-strong);
  font-family: var(--mono); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted);
  padding: 10px clamp(14px, 1.6vw, 18px); border-bottom: 1px solid var(--border-secondary);
}
.bo-table thead th.num, .bo-table tbody td.num { text-align: right; }
.bo-table tbody td { padding: 10px clamp(14px, 1.6vw, 18px); border-bottom: 1px solid var(--border-secondary); color: var(--mist); vertical-align: middle; }
.bo-table tbody tr.is-editing td { background: rgba(139,92,255,.08); }
.bo-table .bt-cat { font-family: var(--mono); font-size: .64rem; letter-spacing: .06em; text-transform: uppercase; color: var(--haze); }
.bo-table .bt-price { font-family: var(--mono); color: var(--violet-bright); }
.bo-table .bt-glyph { font-size: 1rem; }
.bo-act { font-family: var(--mono); font-size: .6rem; letter-spacing: .06em; text-transform: uppercase; background: none; border: 0; cursor: pointer; padding: 0 0 0 10px; color: var(--haze); }
.bo-act.edit:hover { color: var(--violet-bright); }
.bo-act.del:hover { color: #ff9a9a; }
.bo-table-empty td { color: var(--text-muted); }

/* add / edit form */
.bo-form { flex: 0 0 auto; border-top: 1px solid var(--border-secondary); padding: clamp(12px, 1.6vw, 16px) clamp(14px, 1.6vw, 18px); background: var(--bg-panel-strong); }
.bo-form .bo-form-title { font-family: var(--mono); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: var(--haze); margin-bottom: 10px; }
.bo-grid { display: grid; grid-template-columns: 2.4fr 1.6fr 1fr 0.7fr; gap: 8px; align-items: end; }
.bo-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bo-cell label { font-family: var(--mono); font-size: .56rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.bo-cell input {
  width: 100%; min-width: 0; font-family: var(--body); font-size: .86rem; color: var(--mist);
  background: rgba(6,4,12,.6); border: 1px solid var(--border-primary); border-radius: var(--radius-sm); padding: 8px 10px;
}
.bo-cell input.glyph-in { text-align: center; }
.bo-cell input:focus { outline: none; border-color: var(--violet); box-shadow: var(--glow-violet-soft); }
.bo-cell input.invalid { border-color: rgba(255,120,120,.55); }
.bo-form-actions { display: flex; gap: 8px; margin-top: 12px; }
.bo-form .btn { font-size: .66rem; padding: .7em 1.2em; }
.bo-cancel[hidden] { display: none; }
.bo-form-err { font-family: var(--mono); font-size: .6rem; color: #ff9a9a; margin-top: 8px; min-height: 0; }

/* tax rate */
.bo-tax { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 12px clamp(14px, 1.6vw, 18px); border-top: 1px solid var(--border-secondary); }
.bo-tax label { font-family: var(--mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--haze); }
.bo-tax .tax-wrap { display: inline-flex; align-items: center; gap: 6px; }
.bo-tax input {
  width: 78px; font-family: var(--mono); font-size: .9rem; color: var(--mist); text-align: right;
  background: rgba(6,4,12,.6); border: 1px solid var(--border-primary); border-radius: var(--radius-sm); padding: 7px 9px;
}
.bo-tax input:focus { outline: none; border-color: var(--violet); box-shadow: var(--glow-violet-soft); }
.bo-tax .pct { color: var(--haze); font-family: var(--mono); }
.bo-tax .tax-live { margin-left: auto; font-family: var(--mono); font-size: .58rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }

/* ===========================================================
   NO-JS fallback price list (PHP-rendered). Hidden when JS runs.
   =========================================================== */
.console-static { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
html.js .console-static { display: none; }
.console-static .static-note { font-family: var(--mono); font-size: .72rem; letter-spacing: .03em; line-height: 1.7; color: var(--text-muted); margin-bottom: 20px; max-width: 60ch; }
.console-static .static-note strong { color: var(--haze); font-weight: 400; }
.static-cat { font-family: var(--mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--violet-bright); margin: 18px 0 8px; }
.static-row { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--border-secondary); max-width: 460px; }
.static-row .sr-name { color: var(--mist); font-size: .9rem; }
.static-row .sr-price { font-family: var(--mono); color: var(--violet-bright); font-size: .85rem; }
html:not(.js) .pos-stage { display: none; }   /* the live app only exists with JS */

/* ---- narrower landscape (tablets): ease the register split ---- */
@media (max-width: 900px) {
  .pos-register { flex: 1.5 1 0; }
  .reg-ticket { flex-basis: clamp(180px, 30%, 230px); }
  .bo-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- portrait gate (phones + tablets): rotate-to-landscape wall ---- */
.rotate-nag { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  .rotate-nag {
    display: flex; position: fixed; inset: 0; z-index: 9999;
    flex-direction: column; align-items: center; justify-content: center;
    gap: 18px; padding: 40px; text-align: center; background: var(--void);
  }
  .rotate-nag-title { font-family: var(--display); font-weight: 600; font-size: clamp(1.4rem, 7vw, 2rem); color: var(--mist); }
  .rotate-nag-sub  { font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--haze); max-width: 32ch; line-height: 1.7; }
}

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .reg-overlay, .tender-pane.is-active { animation: none; }
  .card-reader .spinner { animation-duration: 1.2s; }
}

/* sr-only */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
