/* pos.css — Counter terminal + register
   The terminal is a two-pane fixed-height workspace: the page itself never
   scrolls, only the catalogue grid and the bill lines do. That keeps the total
   and the Pay button nailed to the bottom right where a cashier expects them. */

.pos-shell {
  display: grid;
  grid-template-columns: 1fr 372px;
  height: calc(100vh - var(--topbar-height) - 32px);
  min-height: 460px;
  gap: 14px;
  margin: -4px 0;
}

/* ── CATALOGUE ───────────────────────────────────────────────── */
.pos-catalogue {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.pos-searchbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.pos-search-wrap {
  position: relative; flex: 1; display: flex; align-items: center;
  background: var(--bg-inset);
  border: 1.5px solid transparent;
  border-radius: var(--radius-lg);
  padding: 0 10px;
  color: var(--text-tertiary);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.pos-search-wrap:focus-within { border-color: var(--border-focus); background: var(--bg-surface); }

.pos-search {
  flex: 1; border: none; background: transparent; outline: none;
  padding: 10px 8px;
  font-family: var(--font-sans); font-size: var(--text-base);
  color: var(--text-primary);
}

.pos-categories {
  display: flex; gap: 6px; padding: 9px 12px;
  overflow-x: auto; flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  scrollbar-width: none;
}
.pos-categories::-webkit-scrollbar { display: none; }
.pos-categories:empty { display: none; }

.pos-chip {
  flex-shrink: 0; padding: 5px 11px;
  border: 1px solid var(--border-default); border-radius: var(--radius-full);
  background: var(--bg-surface); cursor: pointer;
  font-family: inherit; font-size: var(--text-sm); font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.pos-chip:hover  { border-color: var(--border-strong); }
.pos-chip.active { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }

.pos-grid {
  flex: 1; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 9px; padding: 12px;
  align-content: start;
}

.pos-tile {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px; min-height: 96px;
  text-align: left; cursor: pointer;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  font-family: inherit;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.pos-tile:hover  { border-color: var(--brand-primary-mid); box-shadow: var(--shadow-sm); }
.pos-tile:active { transform: scale(0.97); }
.pos-tile.out    { opacity: 0.55; }

.pos-tile-badge {
  width: 26px; height: 26px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; flex-shrink: 0;
}

.pos-tile-name {
  flex: 1; font-size: 12.5px; font-weight: 600; line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.pos-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pos-tile-rate  { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.pos-tile-stock { font-size: 10.5px; color: var(--text-tertiary); white-space: nowrap; }
.pos-tile-stock.is-low { color: var(--color-warning); font-weight: 600; }
.pos-tile-stock.is-out { color: var(--color-danger);  font-weight: 600; }

/* ── BILL PANE ───────────────────────────────────────────────── */
.pos-bill {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.pos-bill-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.pos-customer-btn {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; cursor: pointer; text-align: left;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  font-family: inherit;
  transition: background var(--transition-fast);
}
.pos-customer-btn:hover { background: var(--bg-inset); }

.pos-cust-avatar {
  width: 28px; height: 28px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  background: var(--bg-inset); color: var(--text-secondary);
}
.pos-cust-meta { display: flex; flex-direction: column; min-width: 0; }
.pos-cust-meta > span:first-child {
  font-size: 12.5px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pos-cust-sub {
  font-size: 10.5px; color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pos-reg-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 8px; border-radius: var(--radius-md);
  font-size: 10.5px; font-weight: 600; text-decoration: none;
  white-space: nowrap; flex-shrink: 0;
}
.pos-reg-chip.open { background: var(--color-success-light); color: var(--color-success-text); }
.pos-reg-chip.shut { background: var(--color-warning-light); color: var(--color-warning-text); }

.pos-lines { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }

.pos-empty {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  color: var(--text-tertiary); text-align: center; padding: 20px;
}
.pos-empty-icon { color: var(--text-disabled); }
.pos-empty p { margin: 0; font-size: 13px; font-weight: 500; }
.pos-empty-hint { font-size: 11px; color: var(--text-disabled); }

.pos-line {
  padding: 8px; border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: 6px; background: var(--bg-surface);
}
.pos-line-top { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 6px; }
.pos-line-name { flex: 1; font-size: 12.5px; font-weight: 600; color: var(--text-primary); line-height: 1.35; }
.pos-line-x {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
  color: var(--text-disabled); border-radius: var(--radius-sm);
}
.pos-line-x:hover { background: var(--color-danger-light); color: var(--color-danger); }

.pos-line-mid { display: flex; align-items: center; gap: 5px; }

.pos-stepper {
  display: flex; align-items: center; flex-shrink: 0;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  overflow: hidden; background: var(--bg-surface);
}
.pos-stepper button {
  width: 22px; height: 26px; border: none; background: var(--bg-inset);
  cursor: pointer; font-size: 14px; font-weight: 600; line-height: 1;
  color: var(--text-secondary); font-family: inherit;
}
.pos-stepper button:hover { background: var(--border-subtle); }
.pos-stepper input {
  width: 40px; height: 26px; border: none; outline: none; text-align: center;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--text-primary);
  -moz-appearance: textfield;
}
.pos-stepper input::-webkit-outer-spin-button,
.pos-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pos-line-x-sym { font-size: 11px; color: var(--text-disabled); flex-shrink: 0; }

.pos-line-rate, .pos-line-disc {
  height: 26px; border: 1px solid var(--border-default); border-radius: var(--radius-md);
  padding: 0 6px; outline: none; font-family: inherit; font-size: 12px;
  color: var(--text-primary); background: var(--bg-surface); min-width: 0;
}
.pos-line-rate { width: 62px; }
.pos-line-disc { width: 42px; text-align: center; }
.pos-line-rate:focus, .pos-line-disc:focus { border-color: var(--border-focus); }

.pos-line-amt {
  margin-left: auto; font-size: 12.5px; font-weight: 700;
  color: var(--text-primary); white-space: nowrap;
}

.pos-line-warn {
  display: flex; align-items: center; gap: 4px; margin-top: 5px;
  font-size: 10.5px; font-weight: 500; color: var(--color-warning-text);
}

/* ── SUMMARY + ACTIONS ───────────────────────────────────────── */
.pos-summary {
  padding: 10px 12px; border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle); flex-shrink: 0;
}
.pos-sum-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-secondary); padding: 2px 0;
}
.pos-sum-row.pos-neg { color: var(--color-success-text); }

.pos-disc-row { padding: 4px 0; }
.pos-disc-controls { display: flex; align-items: center; gap: 3px; }
.pos-disc-controls input {
  width: 60px; height: 24px; text-align: right; padding: 0 6px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 11.5px; outline: none; background: var(--bg-surface);
}
.pos-disc-controls input:focus { border-color: var(--border-focus); }
.pos-disc-controls button {
  width: 24px; height: 24px; border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); background: var(--bg-surface); cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 600; color: var(--text-secondary);
}
.pos-disc-controls button.active { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }

.pos-sum-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 7px; padding-top: 8px;
  border-top: 1.5px solid var(--border-default);
  font-size: var(--text-lg); font-weight: 700; color: var(--text-primary);
}

.pos-actions {
  display: grid; grid-template-columns: 1fr 1fr 1.6fr;
  gap: 7px; padding: 10px 12px;
  border-top: 1px solid var(--border-subtle); flex-shrink: 0;
}
.pos-pay-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: var(--text-base); font-weight: 700;
}
.pos-pay-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── PICKERS + PAYMENT MODAL ─────────────────────────────────── */
.pos-muted { color: var(--text-tertiary); font-size: 12.5px; margin: 0; }

.pos-pick-row {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 3px; cursor: pointer; text-align: left;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-lg); font-family: inherit;
  transition: background var(--transition-fast);
}
.pos-pick-row:hover { background: var(--bg-inset); }
.pos-pick-av {
  width: 32px; height: 32px; border-radius: var(--radius-full); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700;
}
.pos-pick-meta { display: flex; flex-direction: column; min-width: 0; }
.pos-pick-meta strong { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.pos-pick-meta span   { font-size: 11.5px; color: var(--text-tertiary); }

.pos-hold-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); margin-bottom: 6px;
}
.pos-hold-row strong { display: block; font-size: 13px; }
.pos-hold-row .pos-muted { display: block; font-size: 11.5px; }

.pos-pay-body { padding: 14px; }

.pos-pay-due {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 14px; margin-bottom: 12px;
  background: var(--brand-primary-light); border-radius: var(--radius-lg);
}
.pos-pay-due span   { font-size: 12.5px; color: var(--text-secondary); }
.pos-pay-due strong { font-size: var(--text-2xl); font-weight: 700; color: var(--brand-primary); }

.pos-quick-cash { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pos-cash-chip {
  padding: 7px 12px; border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); background: var(--bg-surface); cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.pos-cash-chip:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.pos-tender {
  padding: 9px; margin-bottom: 8px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
}
.pos-tender-methods { display: flex; gap: 4px; margin-bottom: 7px; flex-wrap: wrap; }
.pos-tender-btn {
  flex: 1; min-width: 62px; padding: 6px 8px;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--bg-surface); cursor: pointer;
  font-family: inherit; font-size: 11.5px; font-weight: 600; color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.pos-tender-btn.active { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }

.pos-tender-row { display: flex; gap: 6px; align-items: center; }
.pos-tender-amt { flex: 0 0 120px; font-weight: 700; }
.pos-tender-ref { flex: 1; min-width: 0; }

.pos-add-tender {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; margin-bottom: 12px; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: transparent; font-family: inherit;
  font-size: 12.5px; font-weight: 600; color: var(--brand-primary);
  transition: all var(--transition-fast);
}
.pos-add-tender:hover { background: var(--brand-primary-light); border-color: var(--brand-primary-mid); }

.pos-pay-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: var(--radius-lg); margin-bottom: 12px;
  font-size: 12.5px; font-weight: 600;
}
.pos-pay-status strong { font-size: var(--text-lg); display: flex; align-items: center; }
.pos-pay-status.is-change { background: var(--color-warning-light); color: var(--color-warning-text); }
.pos-pay-status.is-short  { background: var(--color-danger-light);  color: var(--color-danger-text); }
.pos-pay-status.is-exact  { background: var(--color-success-light); color: var(--color-success-text); }

.pos-print-toggle {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-secondary); cursor: pointer;
}

/* ── REGISTER / DAY CLOSE ────────────────────────────────────── */
.reg-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.reg-metric {
  padding: 11px 12px; border-radius: var(--radius-lg);
  background: var(--bg-subtle); border: 1px solid var(--border-subtle);
}
.reg-metric span   { display: block; font-size: 11px; color: var(--text-tertiary); margin-bottom: 3px; }
.reg-metric strong { font-size: var(--text-lg); font-weight: 700; color: var(--text-primary); }
.reg-metric.accent { background: var(--brand-primary-light); border-color: var(--brand-primary-mid); }
.reg-metric.accent strong { color: var(--brand-primary); }

.reg-split { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.reg-h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-tertiary); }

.reg-tender {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 13px; color: var(--text-secondary);
}
.reg-tender strong { color: var(--text-primary); font-weight: 600; }

.reg-denoms { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 7px; }
.reg-denom {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
}
.reg-denom-face { font-size: 12.5px; font-weight: 700; width: 40px; flex-shrink: 0; }
.reg-denom-x    { font-size: 11px; color: var(--text-disabled); }
.reg-denom input {
  width: 52px; height: 26px; text-align: center; padding: 0 4px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 12px; outline: none;
}
.reg-denom input:focus { border-color: var(--border-focus); }
.reg-denom-sub { margin-left: auto; font-size: 11.5px; color: var(--text-tertiary); }

.reg-close-totals {
  margin-top: 14px; padding: 10px 12px;
  background: var(--bg-subtle); border-radius: var(--radius-lg);
}
.reg-close-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0; font-size: 13px; color: var(--text-secondary);
}
.reg-close-row strong { font-weight: 700; color: var(--text-primary); }
.reg-close-row.ok    { color: var(--color-success-text); border-top: 1px solid var(--border-default); margin-top: 5px; padding-top: 7px; }
.reg-close-row.ok strong { color: var(--color-success); display: flex; }
.reg-close-row.short,
.reg-close-row.over  { color: var(--color-danger-text); border-top: 1px solid var(--border-default); margin-top: 5px; padding-top: 7px; }
.reg-close-row.short strong, .reg-close-row.over strong { color: var(--color-danger); }

/* ── NARROW SCREENS ──────────────────────────────────────────── */
@media (max-width: 980px) {
  .pos-shell {
    grid-template-columns: 1fr;
    height: auto; min-height: 0;
  }
  .pos-catalogue { height: 52vh; }
  .pos-bill      { height: auto; min-height: 46vh; }
  .pos-lines     { max-height: 34vh; }
  .reg-split     { grid-template-columns: 1fr; gap: 16px; }
}
