/* ---- Electronics Shop POS — black & white theme (logo-based) ---- */
:root {
  --bg:        #f6f6f7;   /* page */
  --surface:   #ffffff;   /* cards, topbar */
  --ink:       #0a0a0a;   /* near-black text (matches logo) */
  --ink-soft:  #3f3f46;
  --muted:     #71717a;   /* gray */
  --line:      #e4e4e7;   /* light borders */
  --accent:    #0a0a0a;   /* black accent (replaces the old gold) */
  --on-accent: #ffffff;
  --radius:    12px;
  --shadow:    0 1px 2px rgba(0,0,0,.06), 0 10px 28px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Raleway', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 700; margin: 0 0 .4rem; letter-spacing: .2px; }
a { color: var(--ink); text-decoration: none; }
strong { color: var(--ink); }

/* ---------- Shell ---------- */
.pos-shell { min-height: 100vh; display: flex; flex-direction: column; }

.pos-topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}

.pos-brand { display: flex; align-items: center; gap: .6rem; }
.pos-brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 800; font-size: .8rem; letter-spacing: .5px;
}
.pos-brand-name { font-weight: 800; letter-spacing: .5px; text-transform: uppercase; font-size: .9rem; }

/* ---------- Nav ---------- */
.pos-nav { display: flex; gap: .25rem; flex: 1 1 auto; flex-wrap: wrap; }
.pos-nav-link {
  color: var(--muted); padding: .45rem .8rem; border-radius: 8px;
  font-weight: 600; transition: background .15s, color .15s;
}
.pos-nav-link:hover { color: var(--ink); background: #f0f0f1; }
.pos-nav-link.is-active { color: var(--on-accent); background: var(--accent); }

/* ---------- User / sign-out ---------- */
.pos-user { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.pos-user-meta { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.pos-user-name { font-weight: 700; font-size: .9rem; }
.pos-user-role { color: var(--muted); font-size: .75rem; }

/* ---------- Buttons ---------- */
.pos-btn {
  font-family: inherit; font-weight: 700; font-size: .9rem;
  padding: .5rem .9rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.pos-btn:hover { background: #f0f0f1; }
/* primary = solid black (class name kept for compatibility) */
.pos-btn-gold { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.pos-btn-gold:hover { background: #262626; }
.pos-btn-ghost { background: var(--surface); color: var(--muted); }
.pos-btn-ghost:hover { color: var(--ink); background: #f0f0f1; }
.pos-btn-block { width: 100%; padding: .75rem; font-size: 1rem; }

/* ---------- Main / cards ---------- */
.pos-main { padding: 1.4rem 1rem; max-width: 1100px; width: 100%; margin: 0 auto; }
.pos-page-head { margin-bottom: 1.1rem; }
.pos-page-head h1 { font-size: 1.5rem; }
.pos-muted { color: var(--muted); }

.pos-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 720px) { .pos-grid { grid-template-columns: 1fr 1fr; } }

.pos-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.pos-card-title { font-size: 1rem; }

/* ---------- Fields ---------- */
.pos-field { display: block; margin-bottom: 1rem; }
.pos-label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .35rem; font-weight: 700; }
.pos-req { color: var(--ink); font-style: normal; font-weight: 800; cursor: help; }
.pos-input {
  width: 100%; font-family: inherit; font-size: 1rem;
  padding: .65rem .8rem; border-radius: 9px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.pos-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(10,10,10,.10); }
.pos-input-pin { letter-spacing: .5em; text-align: center; font-size: 1.4rem; }

/* ---------- Alerts (inverted for emphasis) ---------- */
.pos-alert { padding: .7rem .9rem; border-radius: 9px; margin-bottom: 1rem; font-size: .9rem; }
.pos-alert-error { background: var(--accent); color: var(--on-accent); }

/* ---------- Login ---------- */
.pos-login-body { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: var(--surface); }
.pos-login-card {
  width: 100%; max-width: 390px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 1.75rem 1.5rem; box-shadow: var(--shadow);
}
.pos-login-head { text-align: center; margin-bottom: 1.25rem; }
.pos-login-logo { width: 150px; height: auto; margin: 0 auto .5rem; display: block; }
.pos-login-head h1 { font-size: 1.2rem; margin: .5rem 0 .1rem; text-transform: uppercase; letter-spacing: .5px; }
.pos-login-head p { color: var(--muted); font-size: .85rem; margin: 0; }

/* ---------- Toasts (monochrome; error inverts) ---------- */
.pos-toasts {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  display: flex; flex-direction: column; gap: .5rem; max-width: min(92vw, 360px);
}
.pos-toast {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .9rem; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: .9rem;
  border-left: 4px solid var(--ink);
}
.pos-toast-success { border-left: 4px solid var(--ink); }
.pos-toast-warning { border-left: 4px dashed var(--ink); }
.pos-toast-error {
  background: var(--accent); color: var(--on-accent);
  border-color: var(--accent); border-left: 4px solid var(--on-accent);
}
.pos-toast span { flex: 1; }
.pos-toast-x { background: none; border: none; color: inherit; opacity: .6; font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0; }
.pos-toast-x:hover { opacity: 1; }

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .pos-topbar { gap: .5rem; }
  .pos-user-meta { display: none; }
  .pos-nav { order: 3; width: 100%; }
}

/* ============ Phase 2 — Stock module ============ */
[x-cloak] { display: none !important; }

/* Tabs — segmented control */
.pos-tabs {
  display: inline-flex; gap: .25rem; margin: 0 0 1.5rem; flex-wrap: wrap;
  padding: .3rem; background: #ececee; border-radius: 11px;
}
.pos-tab {
  padding: .55rem 1.15rem; font-weight: 700; font-size: .9rem;
  color: var(--muted); border-radius: 8px; transition: background .15s, color .15s;
}
.pos-tab:hover { color: var(--ink); }
.pos-tab.is-active { color: var(--on-accent); background: var(--ink); }

/* Form grid (2-col desktop, 1-col mobile) */
.pos-form-grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 640px) { .pos-form-grid { grid-template-columns: 1fr 1fr; } }

.pos-input-row { display: flex; gap: .5rem; }
.pos-input-row .pos-input { flex: 1; }

.pos-check { display: flex; align-items: center; gap: .55rem; margin: .25rem 0 1rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.pos-check input { width: 18px; height: 18px; accent-color: var(--ink); }

.pos-hint { display: block; color: var(--muted); font-size: .78rem; margin-top: .25rem; }
.pos-err { display: block; color: var(--ink); font-weight: 700; font-size: .8rem; margin-top: .25rem; }
textarea.pos-input { resize: vertical; }

/* Search bar */
.pos-searchbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pos-searchbar .pos-input { flex: 1 1 200px; }

/* Table */
.pos-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.pos-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 900px; }
.pos-table th, .pos-table td { white-space: nowrap; }
.pos-table thead th {
  text-align: left; padding: .8rem 1.1rem; background: #f4f4f5;
  color: var(--ink-soft); font-weight: 700; border-bottom: 1px solid var(--line);
}
.pos-table tbody td { padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pos-table tbody tr:nth-child(even) { background: #fafafa; }
.pos-table tbody tr:hover { background: #f0f0f1; }
.pos-table tbody tr:last-child td { border-bottom: none; }
.pos-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
.pos-empty { text-align: center; color: var(--muted); padding: 1.5rem; }

/* Status badges (monochrome) */
.pos-badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.pos-badge-in { background: var(--ink); color: var(--on-accent); }
.pos-badge-sold { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.pos-btn-sm { padding: .3rem .6rem; font-size: .8rem; }

/* Pager */
.pos-pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }
.pos-pager-btn { padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 8px; font-weight: 700; color: var(--ink); }
.pos-pager-btn.is-disabled { color: var(--muted); opacity: .5; }
.pos-pager-info { color: var(--muted); font-size: .85rem; }

/* Barcode scanner overlay */
.pos-scan { position: fixed; inset: 0; background: rgba(0,0,0,.8); display: grid; place-items: center; z-index: 80; padding: 1rem; }
.pos-scan-box { background: var(--surface); border-radius: 14px; padding: 1rem; text-align: center; max-width: 420px; width: 100%; }
.pos-scan-box video { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 4/3; object-fit: cover; }
.pos-scan-box p { margin: .6rem 0; }

/* ============ Stock List upgrade (Phase 2.5) ============ */
.pos-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 1rem; }

/* Summary strip */
.pos-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 1.1rem; }
.pos-metric { background: #f4f4f5; border: 1px solid var(--line); border-radius: 10px; padding: .85rem 1rem; }
.pos-metric-label { color: var(--muted); font-size: .78rem; }
.pos-metric-value { font-size: 1.35rem; font-weight: 800; color: var(--ink); margin-top: .15rem; line-height: 1.2; }

/* Quick time-range chips */
.pos-chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .85rem; }
.pos-chip { padding: .35rem .85rem; border: 1px solid var(--line); border-radius: 999px; font-size: .8rem; font-weight: 700; color: var(--muted); background: var(--surface); }
.pos-chip:hover { color: var(--ink); border-color: var(--muted); }
.pos-chip.is-active { background: var(--ink); color: var(--on-accent); border-color: var(--ink); }

/* Narrow toolbar inputs (date pickers, status) — override the flex:1 from .pos-searchbar */
.pos-searchbar .pos-input-sm { flex: 0 0 auto; width: 150px; }

/* Compact stock table — stacked cells so all fields fit one page (no min-width) */
.pos-stock-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.pos-stock-table thead th { background: #f4f4f5; text-align: left; padding: .7rem .9rem; color: var(--ink-soft); font-weight: 700; font-size: .78rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pos-stock-table tbody td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.pos-stock-table tbody tr:nth-child(even) { background: #fafafa; }
.pos-stock-table tbody tr:hover { background: #f0f0f1; }
.pos-stock-table tbody tr:last-child td { border-bottom: none; }
.pos-cell-strong { color: var(--ink); font-weight: 700; }
.pos-cell-sub { color: var(--muted); font-size: .8rem; margin-top: .1rem; }
.pos-cell-sub2 { color: var(--muted); font-size: .74rem; margin-top: .1rem; }
.pos-id-line { font-size: .82rem; line-height: 1.5; }
.pos-id-label { color: var(--muted); display: inline-block; width: 2.6em; }

@media (max-width: 640px) {
    .pos-searchbar .pos-input-sm { flex: 1 1 45%; width: auto; }
}
