/* ============================================================
   FoxStore Admin — Design System
   Modern SaaS dashboard. Light + Dark. Responsive.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --brand: #f97316;
  --brand-600: #ea580c;
  --brand-700: #c2410c;
  --brand-soft: rgba(249, 115, 22, .12);

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e9edf5;
  --border: #e5e8f0;
  --border-strong: #d4d9e4;

  --text: #0f172a;
  --text-2: #5b6577;
  --text-3: #8a93a6;

  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #e11d48;
  --danger-soft: #ffe4e6;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;

  --sidebar-bg: #0f1729;
  --sidebar-ink: #aeb6c8;
  --sidebar-ink-dim: #6b7488;
  --sidebar-active: #ffffff;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, .10);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .22);

  --sidebar-w: 250px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #121a2b;
  --surface-2: #1a2438;
  --surface-3: #212d45;
  --border: #263149;
  --border-strong: #33405c;

  --text: #e7ecf5;
  --text-2: #97a1b6;
  --text-3: #6b7488;

  --success-soft: rgba(22, 163, 74, .18);
  --warning-soft: rgba(217, 119, 6, .18);
  --danger-soft: rgba(225, 29, 72, .18);
  --info-soft: rgba(37, 99, 235, .18);
  --violet-soft: rgba(124, 58, 237, .2);

  --sidebar-bg: #0a0f1c;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
::selection { background: var(--brand-soft); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ============================================================
   Layout shell
   ============================================================ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  flex-shrink: 0;
  position: fixed;
  inset: 0 auto 0 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width .22s var(--ease), transform .22s var(--ease);
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar__logo {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  display: grid; place-items: center; font-size: 18px;
  box-shadow: 0 4px 12px rgba(249, 115, 22, .4);
}
.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar__group { color: var(--sidebar-ink-dim); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 14px 12px 6px; white-space: nowrap; }
.sidebar__link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
  color: var(--sidebar-ink); font-weight: 500; white-space: nowrap; overflow: hidden;
  transition: background .15s, color .15s;
}
.sidebar__link svg { width: 19px; height: 19px; flex-shrink: 0; stroke-width: 2; }
.sidebar__link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar__link.active { background: linear-gradient(90deg, var(--brand), var(--brand-600)); color: #fff; box-shadow: 0 6px 16px rgba(249, 115, 22, .35); }
.sidebar__link .label { flex: 1; }
.sidebar__foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 12px; color: var(--sidebar-ink-dim); white-space: nowrap; overflow: hidden; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .22s var(--ease);
}

/* Collapsed */
.shell.collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.shell.collapsed .main { margin-left: var(--sidebar-w-collapsed); }
.shell.collapsed .sidebar__brand span,
.shell.collapsed .sidebar__link .label,
.shell.collapsed .sidebar__group,
.shell.collapsed .sidebar__foot { opacity: 0; pointer-events: none; }
.shell.collapsed .sidebar__link { justify-content: center; }
.shell.collapsed .sidebar__brand { justify-content: center; padding: 0; }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.topbar__left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar__crumb { color: var(--text-3); font-size: 13px; }
.topbar__title { font-size: 18px; font-weight: 700; }
.topbar__right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 19px; height: 19px; }

.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 11px; padding: 0 12px; height: 40px; min-width: 220px;
}
.search svg { width: 17px; height: 17px; color: var(--text-3); }
.search input { border: none; background: none; outline: none; color: var(--text); width: 100%; font-size: 14px; }

.usermenu { position: relative; }
.usermenu__btn { display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); }
.usermenu__btn:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-700)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.usermenu__pop {
  position: absolute; right: 0; top: 48px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 200px; padding: 8px; display: none; z-index: 50;
}
.usermenu.open .usermenu__pop { display: block; }
.usermenu__pop a, .usermenu__pop button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 11px; border-radius: 9px; border: none; background: none; color: var(--text); font-size: 14px; cursor: pointer; text-align: left; }
.usermenu__pop a:hover, .usermenu__pop button:hover { background: var(--surface-2); }
.usermenu__pop hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

.content { padding: 24px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; }
.page-head p { color: var(--text-2); margin: 3px 0 0; font-size: 13.5px; }

/* ============================================================
   Grid
   ============================================================ */
.grid { display: grid; gap: 18px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, 1fr); } .g-2-1, .g-1-2, .g-3 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .g-4, .g-2 { grid-template-columns: 1fr; } }

/* ============================================================
   KPI cards
   ============================================================ */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.kpi__icon svg { width: 22px; height: 22px; }
.kpi__label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi__value { font-size: 27px; font-weight: 800; margin-top: 10px; letter-spacing: -.02em; }
.kpi__sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.kpi__delta { font-weight: 700; }
.kpi__delta.up { color: var(--success); }
.kpi__delta.down { color: var(--danger); }
.tint-brand { background: var(--brand-soft); color: var(--brand); }
.tint-green { background: var(--success-soft); color: var(--success); }
.tint-blue { background: var(--info-soft); color: var(--info); }
.tint-amber { background: var(--warning-soft); color: var(--warning); }
.tint-violet { background: var(--violet-soft); color: var(--violet); }

/* ============================================================
   Panel / Card
   ============================================================ */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel__head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel__head h2 { font-size: 15px; }
.panel__head .sub { color: var(--text-3); font-size: 12.5px; font-weight: 400; }
.panel__body { padding: 18px; }
.panel__body.flush { padding: 0; }
.panel + .panel, .grid + .panel, .panel + .grid { margin-top: 18px; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); font-weight: 700; position: sticky; top: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .strong { font-weight: 600; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; color: var(--text-2); font-weight: 500; padding: 9px 0; width: 42%; vertical-align: top; }
.kv td { padding: 9px 0; border-bottom: 1px solid var(--border); }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }

/* ============================================================
   Badges
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.no-dot::before { display: none; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.gray { background: var(--surface-3); color: var(--text-2); }

/* ============================================================
   Buttons
   ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit; transition: .15s; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(249, 115, 22, .3); }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
   Forms
   ============================================================ */
.field { margin-bottom: 15px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); transition: .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { min-height: 96px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; transition: .2s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* Toolbar / filters */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented a { padding: 6px 13px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.segmented a:hover { color: var(--text); }
.segmented a.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }

/* ============================================================
   Modal
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(8, 12, 22, .55); backdrop-filter: blur(3px); animation: fade .18s; }
.modal__card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; animation: pop .2s var(--ease); }
.modal__card.lg { max-width: 720px; }
.modal__head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--surface); }
.modal__head h3 { font-size: 16px; }
.modal__body { padding: 20px; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--surface); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.98); } }

/* ============================================================
   Toast
   ============================================================ */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow-lg); min-width: 280px; max-width: 380px; animation: toastin .3s var(--ease); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast__icon { width: 22px; height: 22px; flex-shrink: 0; }
.toast.success .toast__icon { color: var(--success); }
.toast.error .toast__icon { color: var(--danger); }
.toast.info .toast__icon { color: var(--info); }
.toast__msg { flex: 1; font-size: 13.5px; font-weight: 500; }
.toast.hide { animation: toastout .3s var(--ease) forwards; }
@keyframes toastin { from { opacity: 0; transform: translateX(30px); } }
@keyframes toastout { to { opacity: 0; transform: translateX(30px); } }

/* ============================================================
   Empty state
   ============================================================ */
.empty { text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty__icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); }
.empty__icon svg { width: 28px; height: 28px; }
.empty h3 { color: var(--text-2); font-size: 15px; margin-bottom: 5px; }

/* Timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline__item { position: relative; padding-bottom: 18px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot { position: absolute; left: -26px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }
.timeline__item.done .timeline__dot { border-color: var(--success); background: var(--success); }
.timeline__item.muted .timeline__dot { border-color: var(--border-strong); }
.timeline__title { font-weight: 600; font-size: 14px; }
.timeline__time { color: var(--text-3); font-size: 12.5px; }

/* Misc utilities */
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mt-sm { margin-top: 8px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.gap-sm { gap: 6px; }
.chip-code { display: inline-block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px 9px; font-family: ui-monospace, monospace; font-size: 12.5px; }
.avatar-lg { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, var(--brand), var(--brand-700)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 26px; }
.data-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all; margin-bottom: 8px; user-select: all; }
.hide-mobile { }

/* Pagination */
.pagination { display: flex; gap: 6px; margin: 18px; align-items: center; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13px; }
.pagination a:hover { background: var(--surface-2); color: var(--text); }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .info { border: none; background: none; color: var(--text-3); }

/* Progress bar (stock) */
.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }

/* ============================================================
   Login
   ============================================================ */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(249,115,22,.25), transparent 60%), radial-gradient(1000px 500px at 100% 100%, rgba(37,99,235,.18), transparent 55%), #0b1120; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 34px; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .sidebar__logo { width: 44px; height: 44px; font-size: 24px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }

/* ============================================================
   Mobile
   ============================================================ */
.backdrop { display: none; position: fixed; inset: 0; background: rgba(8,12,22,.5); z-index: 35; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open .backdrop { display: block; }
  .shell.collapsed .sidebar { width: var(--sidebar-w); }
  .hide-mobile { display: none !important; }
  .content { padding: 16px; }
  .menu-toggle-desktop { display: none; }
}
@media (min-width: 901px) { .menu-toggle-mobile { display: none; } }
