/* =========================================================================
   The Gym — Pro Shop POS
   Dark / gold theme inspired by masterboltz.com (charcoal + #F5CA2D + Raleway)
   Fonts are linked from the page <head> (production only) so the app degrades
   to clean system fonts when offline / previewing.
   ========================================================================= */

:root {
  --bg:        #1b1b1d;
  --panel:     #272727;
  --panel-2:   #2f2f31;
  --sidebar:   #0c0c0e;
  --sidebar-2: #141416;
  --ink:       #fcfcfc;
  --muted:     #9b9b9f;
  --faint:     #6d6d72;
  --line:      rgba(255,255,255,.09);
  --line-2:    rgba(255,255,255,.05);
  --gold:      #f5ca2d;
  --gold-600:  #d8ac12;
  --gold-soft: rgba(245,202,45,.14);
  --blue:      #3d9be0;
  --green:     #35c46b;
  --red:       #ff5a52;
  --amber:     #ffab2e;
  --radius:    3px;
  --shadow:    0 6px 24px rgba(0,0,0,.35);
  --font:      'Raleway', system-ui, -apple-system, Segoe UI, sans-serif;
  --mono:      'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-600); }
h1, h2, h3, h4 { font-weight: 800; letter-spacing: .2px; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono  { font-family: var(--mono); font-size: .86em; }
code   { font-family: var(--mono); background: var(--panel-2); padding: .1em .4em; border-radius: 2px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

/* ---------------- App shell ---------------- */
.app-shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-2), var(--sidebar));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: .55rem;
  padding: 1.15rem 1.2rem; font-weight: 800; font-size: 1.15rem;
  color: var(--ink); border-bottom: 1px solid var(--line); letter-spacing: .5px;
}
.sidebar .brand b { color: var(--gold); }
.brand-mark { color: var(--gold); letter-spacing: -3px; font-size: 1rem; }

.nav { padding: .6rem .5rem; overflow-y: auto; flex: 1; }
.nav .group { color: var(--faint); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .12em; font-weight: 700; padding: 1rem .8rem .35rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .58rem .8rem; margin: 1px 0; color: var(--muted);
  border-radius: var(--radius); font-weight: 600; font-size: .92rem;
  border-left: 3px solid transparent;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--sidebar-2); color: var(--ink); }
.nav a.active { background: var(--gold-soft); color: var(--gold); border-left-color: var(--gold); }
.nav a.active svg { opacity: 1; }

.sidebar .side-foot { padding: .8rem 1rem; border-top: 1px solid var(--line); font-size: .8rem; }
.sidebar .side-foot .who { color: var(--ink); font-weight: 700; }

/* ---------------- Topbar + main ---------------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.6rem; border-bottom: 1px solid var(--line);
  background: #17171a; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.15rem; }
.topbar .spacer { flex: 1; }
.content { padding: 1.6rem; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .card-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .6rem; }
.card .card-head h2, .card .card-head h3 { margin: 0; }
.card .card-body { padding: 1.1rem; }
.card .card-body.tight { padding: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------------- Stat tiles ---------------- */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); }
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat .value { font-size: 1.7rem; font-weight: 800; margin-top: .2rem; }
.stat .sub { color: var(--faint); font-size: .82rem; margin-top: .15rem; }
.stat.warn::before  { background: var(--amber); }
.stat.danger::before{ background: var(--red); }
.stat.green::before { background: var(--green); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: .62rem .8rem; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data thead th { color: var(--muted); font-size: .74rem; text-transform: uppercase;
  letter-spacing: .07em; font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data tbody tr:hover { background: rgba(255,255,255,.03); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
.row-link { cursor: pointer; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; justify-content: center;
  font-family: var(--font); font-weight: 700; font-size: .9rem; line-height: 1;
  padding: .6rem .95rem; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); cursor: pointer; transition: .12s;
  text-transform: uppercase; letter-spacing: .04em;
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn svg { width: 16px; height: 16px; }
.btn-gold { background: var(--gold); color: #1a1a1a; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-600); border-color: var(--gold-600); color: #1a1a1a; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: rgba(255,90,82,.4); background: transparent; }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: .38rem .6rem; font-size: .78rem; }
.btn-lg { padding: .8rem 1.3rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: .55rem; flex-wrap: wrap; }

/* ---------------- Badges ---------------- */
.badge { display: inline-block; padding: .18em .55em; border-radius: 2px; font-size: .72rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge-success { background: rgba(53,196,107,.16); color: var(--green); }
.badge-info    { background: rgba(61,155,224,.16); color: var(--blue); }
.badge-warn    { background: rgba(255,171,46,.16); color: var(--amber); }
.badge-danger  { background: rgba(255,90,82,.16); color: var(--red); }
.badge-muted   { background: rgba(255,255,255,.08); color: var(--muted); }

/* ---------------- Forms ---------------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .9rem; }
label > span.req { color: var(--gold); }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%; margin-top: .3rem; padding: .55rem .7rem;
  background: var(--sidebar-2); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); font-family: var(--font); font-size: .92rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
textarea { resize: vertical; min-height: 70px; }
.stack > * + * { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.inline-field { display: flex; align-items: center; gap: .5rem; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-weight: 600; }
.check input { width: auto; margin: 0; }

/* ---------------- Alerts ---------------- */
.alert { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid var(--line); font-weight: 600; }
.alert-success { background: rgba(53,196,107,.12); border-color: rgba(53,196,107,.4); color: #b8f0cd; }
.alert-error   { background: rgba(255,90,82,.12); border-color: rgba(255,90,82,.4); color: #ffc9c6; }
.alert-info    { background: rgba(61,155,224,.12); border-color: rgba(61,155,224,.4); color: #cfe6f8; }

.flash-wrap { position: fixed; top: 1rem; right: 1rem; z-index: 100; width: min(360px, 90vw); }
.flash-wrap .alert { box-shadow: var(--shadow); }

/* ---------------- Empty states ---------------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.2rem; margin-bottom: .3rem; }

/* ---------------- Auth pages ---------------- */
.auth-body { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #232326, var(--bg)); padding: 1.5rem; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.auth-brand { text-align: center; font-size: 1.5rem; font-weight: 800; margin-bottom: 1.4rem; letter-spacing: .5px; }
.auth-brand b { color: var(--gold); }
.auth-card h1 { text-align: center; }
.auth-card .muted { text-align: center; margin-top: -.2rem; }
.auth-card form { margin-top: 1.2rem; }

/* ---------------- POS layout ---------------- */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; align-items: start; }
.pos-search input { font-size: 1rem; padding: .7rem .9rem; }
.pos-results { max-height: 62vh; overflow-y: auto; }
.pos-item { display: flex; align-items: center; gap: .8rem; padding: .6rem .8rem;
  border-bottom: 1px solid var(--line-2); cursor: pointer; }
.pos-item:hover { background: rgba(245,202,45,.07); }
.pos-item .pi-main { flex: 1; min-width: 0; }
.pos-item .pi-name { font-weight: 700; }
.pos-item .pi-meta { color: var(--muted); font-size: .8rem; }
.pos-item .pi-price { font-weight: 800; color: var(--gold); }

/* browse tree (category → product → variant) */
.tree-row { display: flex; align-items: center; gap: .55rem; padding: .5rem .8rem; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.tree-row:hover { background: rgba(245,202,45,.08); }
.tree-row .tw { display: inline-block; width: 1em; text-align: center; color: var(--faint); font-size: .75rem; flex: none; }
.tree-row .tlabel { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .tcount { color: var(--faint); font-size: .78rem; white-space: nowrap; flex: none; }
.tree-row .tstock { color: var(--muted); font-size: .78rem; white-space: nowrap; flex: none; }
.tree-row .sp { font-weight: 800; color: var(--gold); white-space: nowrap; flex: none; min-width: 68px; text-align: right; }
.tree-cat-head { font-weight: 700; background: rgba(255,255,255,.03); }
.tree-prod-head { padding-left: 1.7rem; font-weight: 600; }
.tree-var { padding-left: 3.1rem; }
.tree-var .tlabel { font-weight: 500; }

.cart { position: sticky; top: 78px; }
.cart-lines { max-height: 46vh; overflow-y: auto; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; padding: .55rem 0; border-bottom: 1px solid var(--line-2); }
.cart-line .cl-name { font-weight: 700; font-size: .9rem; }
.cart-line .cl-sku { color: var(--faint); font-size: .74rem; }
.cart-line .cl-controls { display: flex; align-items: center; gap: .3rem; }
.cart-line input.qty { width: 52px; text-align: center; padding: .3rem; margin: 0; }
.cart-line input.price { width: 78px; text-align: right; padding: .3rem; margin: 0; }
.cart-line .cl-tax { display: inline-flex; align-items: center; gap: .2rem; margin: 0; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cart-line .cl-tax input { width: auto; margin: 0; }
.cart-line .cl-remove { color: var(--red); cursor: pointer; background: none; border: none; font-size: 1.1rem; }
.totals { margin-top: .6rem; }
.totals .trow { display: flex; justify-content: space-between; padding: .28rem 0; }
.totals .trow.grand { border-top: 1px solid var(--line); margin-top: .35rem; padding-top: .6rem; font-size: 1.35rem; font-weight: 800; }
.totals .trow.grand .amt { color: var(--gold); }

.qty-step { display: inline-flex; }
.qty-step button { width: 26px; height: 30px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer; }
.qty-step button:hover { border-color: var(--gold); color: var(--gold); }

/* variant rows in product editor */
.vrow { display: grid; grid-template-columns: 1.4fr 1fr .8fr .8fr .7fr .7fr .7fr auto; gap: .5rem; align-items: end; margin-bottom: .5rem; }
.vrow label { margin-bottom: 0; }
.vrow .drop { color: var(--red); background: none; border: none; cursor: pointer; font-size: 1.2rem; padding: .4rem; }
.vrow-head { font-size: .7rem; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }

/* misc utilities */
.flex { display: flex; align-items: center; gap: .6rem; }
.wrap-gap { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt0{margin-top:0}.mt1{margin-top:.5rem}.mt2{margin-top:1rem}.mb0{margin-bottom:0}
.pill-tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.pill-tabs a { padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .85rem; }
.pill-tabs a.active { background: var(--gold); color: #1a1a1a; border-color: var(--gold); }
.kbd { font-family: var(--mono); background: var(--sidebar-2); border: 1px solid var(--line); padding: .05em .4em; border-radius: 3px; font-size: .8em; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: 236px; height: 100vh; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; }
  .pos { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .vrow { grid-template-columns: 1fr 1fr; }
}
.menu-btn { display: none; background: none; border: 1px solid var(--line); color: var(--ink); padding: .4rem .6rem; border-radius: var(--radius); cursor: pointer; }
@media (max-width: 900px) { .menu-btn { display: inline-flex; } }

/* ---------------- Print (invoices) ---------------- */
@media print {
  body { background: #fff; color: #111; }
  .no-print, .sidebar, .topbar, .flash-wrap { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; max-width: none; }
  .print-invoice { color: #111; }
  .print-invoice a { color: #111; }
}
