/* ============================================================
   SHARED.CSS — Whims & Whimsey Admin Portal
   Mobile-first, dark theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:        #0F1117;
  --surface:   #181C27;
  --surface2:  #1E2330;
  --surface3:  #252A3A;
  --gold:      #F5B820;
  --gold2:     #FFD60A;
  --golddim:   rgba(245,184,32,0.12);
  --teal:      #4BBFB5;
  --tealdim:   rgba(75,191,181,0.12);
  --red:       #EF4444;
  --reddim:    rgba(239,68,68,0.10);
  --green:     #22C55E;
  --greendim:  rgba(34,197,94,0.10);
  --blue:      #60A5FA;
  --bluedim:   rgba(96,165,250,0.10);
  --purple:    #A78BFA;
  --purpledim: rgba(167,139,250,0.10);
  --orange:    #FB923C;
  --orangedim: rgba(251,146,60,0.10);
  --text:      #E8EAF0;
  --textdim:   #6B7280;
  --border:    #2A2F42;
  --radius:    10px;
  --nav-h:     52px;
  --tab-h:     44px;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Top Nav ────────────────────────────────────────────── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}
.nav-logo {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: var(--golddim);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--gold);
  flex-shrink: 0;
}
.nav-name { font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }
.nav-sub  { font-size: 10px; color: var(--textdim); margin-top: 1px; }
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-clock {
  font-family: 'DM Mono', monospace;
  font-size: 11px; color: var(--textdim);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 9px;
}

/* ── Bottom Nav (mobile) ────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 6px;
  text-decoration: none;
  color: var(--textdim);
  font-size: 10px;
  font-weight: 500;
  gap: 3px;
  transition: color 0.15s;
  position: relative;
}
.bn-item.active { color: var(--gold); }
.bn-item .bn-icon { font-size: 18px; line-height: 1; }
.bn-badge {
  position: absolute;
  top: 6px; right: calc(50% - 14px);
  background: var(--red);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  min-width: 14px;
  text-align: center;
}
.bn-badge.gold { background: var(--gold); color: #0F1117; }

/* ── Page content ───────────────────────────────────────── */
.page {
  padding: 14px 16px;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  flex: 1;
}

/* ── Page title ─────────────────────────────────────────── */
.page-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Section label ──────────────────────────────────────── */
.sec {
  font-size: 10px;
  font-weight: 600;
  color: var(--textdim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.sec:first-child { margin-top: 0; }
.sec::before {
  content: '';
  width: 2px; height: 10px;
  background: var(--gold);
  border-radius: 1px;
  flex-shrink: 0;
}
.sec-count {
  color: var(--textdim);
  font-weight: 400;
  font-size: 10px;
  margin-left: 2px;
}

/* ── Sub-tabs (inside a page) ───────────────────────────── */
.subtabs {
  display: flex;
  background: var(--surface2);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 14px;
  gap: 2px;
}
.subtab {
  flex: 1;
  padding: 7px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--textdim);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.subtab.active {
  background: var(--surface);
  color: var(--gold);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  margin-bottom: 10px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}
.card-title { font-size: 12px; font-weight: 600; }

/* ── Metrics ────────────────────────────────────────────── */
.metrics {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.metrics.c2 { grid-template-columns: 1fr 1fr; }
.metrics.c3 { grid-template-columns: 1fr 1fr 1fr; }
.metrics.c4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.met {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
}
.met-lbl { font-size: 10px; color: var(--textdim); margin-bottom: 4px; }
.met-val { font-size: 20px; font-weight: 700; font-family: 'DM Mono', monospace; }
.met-sub { font-size: 10px; color: var(--textdim); margin-top: 2px; }

/* ── Form ───────────────────────────────────────────────── */
.fg   { display: grid; gap: 9px; margin-bottom: 9px; }
.fg.c2 { grid-template-columns: 1fr 1fr; }
.fg.c3 { grid-template-columns: 1fr 1fr 1fr; }
.f    { display: flex; flex-direction: column; gap: 4px; }
.f label {
  font-size: 10px; font-weight: 600;
  color: var(--textdim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.f input,
.f select,
.f textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s;
  width: 100%;
  -webkit-appearance: none;
}
.f input:focus,
.f select:focus,
.f textarea:focus  { border-color: var(--gold); }
.f input::placeholder,
.f textarea::placeholder { color: var(--textdim); }
.f input[readonly] { opacity: 0.5; }
.f select option   { background: var(--surface2); }
.f textarea        { resize: vertical; min-height: 70px; line-height: 1.5; }

/* search-dropdown combo */
.search-wrap { position: relative; }
.search-dropdown {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--surface2);
  border: 1px solid var(--gold);
  border-radius: 0 0 8px 8px;
  z-index: 50;
  max-height: 180px;
  overflow-y: auto;
}
.search-dropdown.open { display: block; }
.sd-item {
  padding: 9px 11px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sd-item:last-child { border-bottom: none; }
.sd-item:hover { background: var(--surface3); }
.sd-meta { font-size: 10px; color: var(--textdim); }

/* new customer fields — hidden by default */
.new-cust-fields { display: none; margin-top: 8px; }
.new-cust-fields.show { display: grid; gap: 9px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-full { width: 100%; }
.btn-sm   { padding: 6px 11px; font-size: 11px; border-radius: 6px; }
.btn-gold   { background: var(--gold); color: #0F1117; }
.btn-gold:active { background: var(--gold2); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--textdim); }
.btn-outline:active { color: var(--text); border-color: var(--text); }
.btn-teal   { background: var(--tealdim); color: var(--teal); border: 1px solid rgba(75,191,181,0.2); }
.btn-red    { background: var(--reddim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-green  { background: var(--greendim); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.btn-orange { background: var(--orangedim); color: var(--orange); border: 1px solid rgba(251,146,60,0.2); }
.btn-row    { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ── List rows ──────────────────────────────────────────── */
.list-row {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.list-row:last-child { border-bottom: none; padding-bottom: 0; }

/* Queue row */
.qr-no    { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--textdim); min-width: 24px; padding-top: 2px; }
.qr-body  { flex: 1; min-width: 0; }
.qr-title { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-meta  { font-size: 10px; color: var(--textdim); margin-top: 2px; line-height: 1.5; }
.qr-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.qr-price { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--gold); }
.qr-del   { background: var(--reddim); color: var(--red); border: none; border-radius: 5px; padding: 3px 7px; font-size: 10px; font-weight: 600; cursor: pointer; }

/* ── Bulk action bar ────────────────────────────────────── */
.bulk-bar {
  display: none;
  position: fixed;
  bottom: calc(58px + env(safe-area-inset-bottom));
  left: 12px; right: 12px;
  background: var(--surface3);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 10px 13px;
  z-index: 150;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.bulk-bar.show { display: flex; }
.bulk-count { font-size: 12px; font-weight: 600; color: var(--gold); flex-shrink: 0; }
.bulk-select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  font-family: 'DM Sans', sans-serif;
  -webkit-appearance: none;
}
.bulk-select:focus { border-color: var(--gold); }
.bulk-select option { background: var(--surface2); }

/* ── Table (scrollable) ─────────────────────────────────── */
.tw { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 600px; }
th {
  background: var(--surface2); color: var(--textdim);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 8px 11px; text-align: left;
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
td { padding: 9px 11px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:active td { background: var(--surface2); }
.mono { font-family: 'DM Mono', monospace; font-size: 11px; }

/* ── Pills ──────────────────────────────────────────────── */
.pill { display: inline-block; font-size: 9px; padding: 2px 8px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.pp  { background: var(--purpledim); color: var(--purple);  border: 1px solid rgba(167,139,250,0.2); } /* On process    */
.pa  { background: var(--bluedim);   color: var(--blue);    border: 1px solid rgba(96,165,250,0.2);  } /* Arrived       */
.pr  { background: var(--greendim);  color: var(--green);   border: 1px solid rgba(34,197,94,0.2);   } /* Ready to ship */
.ps  { background: rgba(56,189,248,0.1); color: #38BDF8;    border: 1px solid rgba(56,189,248,0.2);  } /* Shipped       */
.pd  { background: var(--greendim);  color: #86EFAC;        border: 1px solid rgba(134,239,172,0.2); } /* Delivered     */
.pc  { background: var(--surface2);  color: var(--textdim); border: 1px solid var(--border);         } /* Cancelled     */
.poo { background: var(--reddim);    color: #FCA5A5;        border: 1px solid rgba(252,165,165,0.2); } /* Out of stock  */
.pi  { background: var(--reddim);    color: #FCA5A5;        border: 1px solid rgba(252,165,165,0.2); } /* Issued        */
.pt  { background: var(--orangedim); color: var(--orange);  border: 1px solid rgba(251,146,60,0.2);  } /* Partial       */
.pk  { background: var(--surface2);  color: var(--textdim); border: 1px solid var(--border);         } /* Paid          */
.pg  { background: var(--golddim);   color: var(--gold);    border: 1px solid rgba(245,184,32,0.2);  } /* Ongoing PO    */
.prs { background: var(--tealdim);   color: var(--teal);    border: 1px solid rgba(75,191,181,0.2);  } /* Ready Stock   */
.pev { background: var(--purpledim); color: var(--purple);  border: 1px solid rgba(167,139,250,0.2); } /* Event         */

/* ── Bar chart ──────────────────────────────────────────── */
.bar-row  { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 11px; }
.bar-lbl  { min-width: 90px; color: var(--textdim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; background: var(--surface3); border-radius: 3px; height: 6px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; background: var(--gold); transition: width 0.6s ease; }
.bar-fill.t { background: var(--teal); }
.bar-val  { min-width: 52px; text-align: right; font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text); }

/* ── Rank rows ──────────────────────────────────────────── */
.rr { display: flex; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: center; }
.rr:last-child { border-bottom: none; padding-bottom: 0; }
.rr-rank  { font-family: 'DM Mono', monospace; font-weight: 700; font-size: 11px; color: var(--textdim); min-width: 16px; }
.rr-rank.top { color: var(--gold); }
.rr-body  { flex: 1; min-width: 0; }
.rr-name  { font-size: 12px; font-weight: 500; }
.rr-sub   { font-size: 10px; color: var(--textdim); margin-top: 1px; }
.rr-val   { font-family: 'DM Mono', monospace; font-size: 11px; white-space: nowrap; }

/* ── Packing status dot ─────────────────────────────────── */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; flex-shrink: 0; }
.dot-pack { background: #FCD34D; }
.dot-ship { background: #38BDF8; }
.dot-dlv  { background: #4ADE80; }

/* ── Outstanding row ────────────────────────────────────── */
.ost-row {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 12px;
}
.ost-row:last-child { border-bottom: none; padding-bottom: 0; }
.ost-body { flex: 1; min-width: 0; }
.ost-name { font-weight: 500; }
.ost-sub  { font-size: 10px; color: var(--textdim); margin-top: 2px; }
.ost-amt  { font-family: 'DM Mono', monospace; font-size: 12px; white-space: nowrap; }

/* ── Payment row ────────────────────────────────────────── */
.pay-row {
  display: flex;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 12px;
}
.pay-row:last-child { border-bottom: none; padding-bottom: 0; }
.pay-date { font-size: 10px; color: var(--textdim); min-width: 68px; flex-shrink: 0; }
.pay-body { flex: 1; }
.pay-type { font-weight: 500; }
.pay-ref  { font-size: 10px; color: var(--textdim); margin-top: 1px; font-family: 'DM Mono', monospace; }
.pay-pos  { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--teal); white-space: nowrap; }
.pay-neg  { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--red); white-space: nowrap; }

/* ── Deposit hero ───────────────────────────────────────── */
.dep-hero {
  background: linear-gradient(135deg, var(--surface3), var(--surface2));
  border: 1px solid rgba(245,184,32,0.2);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.dep-lbl  { font-size: 10px; color: rgba(255,255,255,0.5); margin-bottom: 4px; }
.dep-val  { font-size: 24px; font-weight: 700; color: var(--gold); font-family: 'DM Mono', monospace; }
.dep-note { font-size: 10px; color: rgba(255,255,255,0.35); margin-top: 3px; }
.dep-icon {
  width: 40px; height: 40px;
  background: var(--golddim);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Toast notification ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red);   }
.toast.show    { opacity: 1; }

/* ── Divider ────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ── Empty state ────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--textdim);
  font-size: 12px;
}
.empty-icon { font-size: 28px; margin-bottom: 8px; }

/* ── Utility ────────────────────────────────────────────── */
.gold    { color: var(--gold); }
.teal    { color: var(--teal); }
.red     { color: var(--red); }
.green   { color: var(--green); }
.blue    { color: var(--blue); }
.textdim { color: var(--textdim); }
.fw6     { font-weight: 600; }
.fw7     { font-weight: 700; }
.fs10    { font-size: 10px; }
.fs11    { font-size: 11px; }
.fs12    { font-size: 12px; }
.mt4     { margin-top: 4px; }
.mt8     { margin-top: 8px; }
.mt12    { margin-top: 12px; }
.mb0     { margin-bottom: 0; }
.gap8    { gap: 8px; }
.flex    { display: flex; }
.flex-ac { display: flex; align-items: center; }
.jcsb    { justify-content: space-between; }
.w100    { width: 100%; }

/* ── Shared JS helpers (inline script in each page) ─────── */

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

/* ── Input number hide arrows ───────────────────────────── */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; }

/* ── Admin Login ─────────────────────────────────────────── */
.admin-login-wrap {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.admin-login-logo {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--golddim);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: var(--gold);
  margin-bottom: 14px;
}
.admin-login-title {
  font-size: 18px; font-weight: 700; color: var(--text);
  margin-bottom: 4px; text-align: center;
}
.admin-login-sub {
  font-size: 11px; color: var(--textdim);
  margin-bottom: 28px; text-align: center;
}
.admin-login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 20px;
  width: 100%; max-width: 320px;
}
.admin-login-error {
  background: var(--reddim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
}
.admin-login-btn {
  width: 100%;
  padding: 12px;
  background: var(--gold);
  color: #0F1117;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  margin-top: 4px;
  transition: background 0.15s;
}
.admin-login-btn:active { background: var(--gold2); }
.admin-login-btn:disabled { opacity: 0.6; cursor: not-allowed; }
