/* ============================================================
   GSC Bar — the pieces this app adds on top of the shared
   Material 3 / liquid-glass system in style.css.

   The register is the reason for most of what follows: it is used
   one-handed, at arm's length, by somebody who is also taking cash.
   Everything on it is bigger than a desktop screen would need.
   ============================================================ */

.sidebar-sub {
  margin: -8px 0 16px 20px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--md-sys-color-primary);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header-left,
.page-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header h1 { margin: 0; font-size: 1.9rem; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border-radius: 100px;
  background: var(--md-sys-color-surface-variant);
  border: var(--glass-border);
}

.user-chip-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-weight: 700;
}

.user-chip-text { display: flex; flex-direction: column; line-height: 1.15; }
.user-chip-text strong { font-size: 0.85rem; font-weight: 600; }
.user-chip-text small { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--md-sys-color-on-surface-variant); }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 24px);
  z-index: 4000;
  max-width: min(560px, calc(100vw - 32px));
  padding: 14px 24px;
  border-radius: 100px;
  background: #313033;
  color: #F4EFF4;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-success { background: #1B5E20; }
.toast-error   { background: #B3261E; }
.toast-warn    { background: #8A5300; }

/* ── The register ─────────────────────────────────────────── */
.register-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .register-grid { grid-template-columns: 1fr; }
}

/* The scan box. Deliberately loud: at a glance across the counter it
   has to be obvious whether the register is listening. */
.scan-box {
  border: 2px dashed var(--md-sys-color-outline-variant);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.scan-box.listening {
  border-color: var(--md-sys-color-primary);
  border-style: solid;
  background: var(--md-sys-color-primary-container);
}
.scan-box .scan-icon { font-size: 3rem; color: var(--md-sys-color-primary); }
.scan-box input {
  /* The field a barcode reader types into. It has to hold focus and take
     keystrokes, so it cannot be display:none — it is hidden by being
     one pixel of nothing, on top of the box that shows the real state. */
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.scan-status { font-size: 0.9rem; color: var(--md-sys-color-on-surface-variant); margin-top: 8px; }

.unit-counter {
  font-size: 4.5rem;
  font-weight: 300;
  line-height: 1;
  color: var(--md-sys-color-primary);
}

/* The card that confirms what was just sold — the only feedback a clerk
   who is looking at the customer, not the screen, will catch. */
.last-scan {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-radius: var(--border-radius-md);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  animation: pop 0.25s ease;
}
.last-scan.flash-ok    { background: #C8E6C9; color: #14361A; }
.last-scan.flash-new   { background: #D7E2FF; color: #001A40; }
.last-scan.flash-error { background: #FFDAD6; color: #410002; }
[data-theme="dark"] .last-scan.flash-ok    { background: #1B5E20; color: #DDF3DD; }
[data-theme="dark"] .last-scan.flash-new   { background: #004785; color: #D7E2FF; }
[data-theme="dark"] .last-scan.flash-error { background: #8C1D18; color: #FFDAD6; }

@keyframes pop {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.last-scan img,
.line-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  flex: none;
}

.sale-lines { list-style: none; max-height: 60vh; overflow-y: auto; }
.sale-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.sale-line:last-child { border-bottom: none; }
.sale-line-main { flex: 1; min-width: 0; }
.sale-line-main strong { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sale-line-meta { font-size: 0.78rem; color: var(--md-sys-color-on-surface-variant); }

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  /* inline-grid, not grid: two of these in a table cell are a row of buttons,
     and block-level ones stack into a column instead. */
  display: inline-grid;
  place-items: center;
  flex: none;
  vertical-align: middle;
}
.icon-btn:hover { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface); }
.icon-btn.danger:hover { background: #FFDAD6; color: #410002; }

/* ── Camera ───────────────────────────────────────────────── */
.camera-wrap {
  position: relative;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  display: none;
}
.camera-wrap.on { display: block; }
.camera-wrap video { width: 100%; height: 100%; object-fit: cover; }

/* The window the customer's hand has to land in. Without it people aim
   the whole phone at the shelf and wonder why nothing happens. */
.camera-reticle {
  position: absolute;
  inset: 22% 10%;
  border: 3px solid rgba(255,255,255,0.9);
  border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,0.35);
}

/* ── Quick tiles ──────────────────────────────────────────── */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.tile {
  border: none;
  cursor: pointer;
  padding: 16px 12px;
  border-radius: var(--border-radius-md);
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
  font-size: 0.9rem;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}
.tile:active { transform: scale(0.97); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: left; }
th {
  /* Sticky so the column titles survive a table that scrolls inside its own
     box — the movement ledger on the Stock page. */
  position: sticky;
  top: 0;
  background: var(--bg-color);
  z-index: 1;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--md-sys-color-primary);
  border-bottom: 2px solid var(--md-sys-color-outline-variant);
  white-space: nowrap;
}
td { border-bottom: 1px solid var(--md-sys-color-outline-variant); }
tbody tr:hover { background: var(--md-sys-color-surface-variant); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Chips, pills, badges ─────────────────────────────────── */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--md-sys-color-outline-variant);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip.active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: transparent;
}
.chip-count {
  background: var(--md-sys-color-surface-variant);
  border-radius: 100px;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.pill-ok     { background: #C8E6C9; color: #14361A; }
.pill-low    { background: #FFE0B2; color: #4A2800; }
.pill-out    { background: #FFDAD6; color: #410002; }
.pill-off    { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant); }
.pill-review { background: #D7E2FF; color: #001A40; }
[data-theme="dark"] .pill-ok     { background: #1B5E20; color: #DDF3DD; }
[data-theme="dark"] .pill-low    { background: #6B4300; color: #FFE0B2; }
[data-theme="dark"] .pill-out    { background: #8C1D18; color: #FFDAD6; }
[data-theme="dark"] .pill-review { background: #004785; color: #D7E2FF; }

/* ── Bars (the only chart the reports need) ───────────────── */
.bar-row { display: grid; grid-template-columns: 1fr 3fr auto; gap: 12px; align-items: center; padding: 7px 0; }
.bar-track { display: block; background: var(--md-sys-color-surface-variant); border-radius: 100px; height: 20px; overflow: hidden; }
/* display:block is load-bearing, not tidiness: these are spans, and an inline
   element ignores height, so the fill would be drawn 0px tall — a chart of
   empty grey tracks. */
.bar-fill { display: block; height: 100%; border-radius: 100px; background: var(--md-sys-color-primary); min-width: 3px; transition: width 0.3s ease; }
.bar-label { font-size: 0.87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-value { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }

/* ── Empty and loading states ─────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--md-sys-color-on-surface-variant);
}
.empty .material-symbols-rounded { font-size: 3rem; opacity: 0.45; display: block; margin-bottom: 8px; }

.skeleton {
  height: 1rem;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.12) 37%, rgba(0,0,0,0.06) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

/* ── Forms and modals ─────────────────────────────────────── */
.modal.open { display: block; }
.modal-content.wide { max-width: 720px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.stat-card { text-align: center; }
.stat-card .text-value { font-size: 2.6rem; }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; flex: 1 1 180px; }
.toolbar .btn { flex: none; }

.muted-note { font-size: 0.82rem; color: var(--md-sys-color-on-surface-variant); }
