/* Layout + components for the platform prototype. Uses only tokens.css variables. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: var(--leading-tight); color: var(--text-primary); }
h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: var(--text-lg); font-weight: 600; }
h3 { font-size: var(--text-base); font-weight: 600; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 4px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── App shell ─────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--bg-sidebar) 259px, var(--border) 259px, var(--border) 260px, transparent 260px); }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text-primary); font-weight: 700; font-size: var(--text-lg); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 50%; background: var(--color-gradient); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 18px; height: 18px; }

.shop-switch {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-surface); color: var(--text-primary);
  font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; width: 100%;
}
.shop-switch:hover { border-color: var(--border-strong); }
.shop-switch .shop-name { font-weight: 600; display: block; }
.shop-switch .shop-meta { color: var(--text-muted); font-size: var(--text-xs); display: block; }
.shop-switch .chev { margin-left: auto; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 14px 12px 6px; font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500;
}
.nav a span:not(.soon) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a svg { width: 18px; height: 18px; flex: none; color: var(--text-muted); }
.nav a:hover { background: var(--bg-muted); color: var(--text-primary); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--color-primary-a10); color: var(--color-primary); font-weight: 600; }
.nav a[aria-current="page"] svg { color: var(--color-primary); }
/* A shortcut into a page (e.g. Reindex products → My shop), shown under its page. */
.nav a.nav-sub { padding-left: 30px; font-size: var(--text-xs); }
.nav a.nav-sub svg { width: 15px; height: 15px; }
.nav .soon { margin-left: auto; font-size: 10px; font-weight: 600; color: var(--text-muted); background: var(--bg-muted); padding: 1px 6px; border-radius: 99px; }
/* Setup's progress ("3/7") while the shop is not set up yet. */
.nav a .nav-pill { margin-left: auto; flex: none; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--color-primary-a10); color: var(--color-primary); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 12px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: var(--text-sm); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-purple-tint); color: var(--color-primary); display: grid; place-items: center; font-weight: 700; font-size: var(--text-xs); flex: none; }
.user-row .who { min-width: 0; }
.user-row .who b { display: block; font-weight: 600; }
.user-row .who span { display: block; color: var(--text-muted); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.theme-toggle {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text-secondary);
  font: inherit; font-size: var(--text-sm); font-weight: 500; cursor: pointer; text-align: left;
}
.theme-toggle:hover { background: var(--bg-muted); color: var(--text-primary); }
.theme-toggle svg { width: 18px; height: 18px; color: var(--text-muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.scrim { display: none; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 32px; min-height: 68px;
  border-bottom: 1px solid var(--border); background: var(--bg-surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar .crumb { color: var(--text-muted); font-size: var(--text-sm); }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }

.content { padding: 32px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head .lede { color: var(--text-secondary); margin-top: 6px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Components ────────────────────────────────────────────── */
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 24px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px 0; }
.card-head .sub { color: var(--text-muted); font-size: var(--text-sm); }
.card-head .end { margin-left: auto; }
.card-body { padding: 16px 24px 24px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius);
  font: inherit; font-size: var(--text-sm); font-weight: 600; line-height: 1.25;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--color-gradient); color: var(--text-on-brand); box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3); }
.btn-primary:hover { background: var(--color-gradient-hover); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-muted); }
.btn-ghost { background: transparent; color: var(--text-link); padding-left: 8px; padding-right: 8px; }
.btn-ghost:hover { background: var(--color-primary-a10); }
.btn-sm { padding: 6px 12px; font-size: var(--text-xs); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--color-success-light); color: var(--color-success-text); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning-text); }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger-text); }
.badge-info { background: var(--color-info-light); color: var(--color-info-text); }
.badge-brand { background: var(--color-primary-a10); color: var(--color-primary); }
.badge-neutral { background: var(--bg-muted); color: var(--text-secondary); }

.grid { display: grid; gap: 24px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

.stat { padding: 20px 22px; }
.stat .label { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500; }
.stat .value { font-size: var(--text-3xl); font-weight: 700; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat .delta { margin-top: 6px; font-size: var(--text-xs); color: var(--text-muted); }
.delta-up { color: var(--color-success-text); font-weight: 600; }
.delta-down { color: var(--color-danger-text); font-weight: 600; }

.info-tip { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--text-muted); font-size: 10px; font-weight: 700; cursor: help; }

/* Status hero */
.status-hero {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 24px 28px; border-radius: var(--radius-xl);
  background: var(--bg-hero); color: #fff; box-shadow: var(--shadow-lg);
}
.status-hero .pulse { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(16, 185, 129, 0.18); flex: none; }
.status-hero .pulse span { width: 18px; height: 18px; border-radius: 50%; background: var(--color-success); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.25); }
.status-hero h2 { color: #fff; font-size: var(--text-xl); font-weight: 700; }
.status-hero p { color: rgba(255, 255, 255, 0.72); font-size: var(--text-sm); margin-top: 4px; }
.status-hero .facts { display: flex; gap: 28px; flex-wrap: wrap; margin-left: auto; }
.status-hero .fact b { display: block; font-size: var(--text-lg); font-weight: 700; color: #fff; }
.status-hero .fact span { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.65); }
.status-hero .btn-light { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.status-hero .btn-light:hover { background: rgba(255, 255, 255, 0.18); }

/* Checklist */
.progress { height: 8px; border-radius: 99px; background: var(--bg-muted); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--color-gradient); }
.checklist { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.checklist li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: var(--radius); }
.checklist li.next { background: var(--bg-purple-tint); }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; margin-top: 1px; }
.checklist .done .tick { background: var(--color-success); color: #fff; }
.checklist .todo .tick { border: 2px solid var(--border-strong); }
.checklist .next .tick { border-color: var(--color-primary); }
.checklist .tick svg { width: 13px; height: 13px; }
.checklist .t { font-size: var(--text-sm); font-weight: 600; }
.checklist .done .t { color: var(--text-muted); text-decoration: line-through; font-weight: 500; }
.checklist .d { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.checklist .go { margin-left: auto; align-self: center; }

/* Chart */
.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: var(--text-xs); color: var(--text-muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Tables / lists */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 0 0 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .q { font-weight: 500; }
.bar-cell { width: 34%; padding-left: 16px !important; }
.minibar { height: 6px; border-radius: 99px; background: var(--bg-muted); overflow: hidden; }
.minibar span { display: block; height: 100%; background: var(--chart-bar); border-radius: inherit; }

.tip-card { display: flex; gap: 14px; padding: 16px; border-radius: var(--radius-lg); background: var(--bg-purple-tint); border: 1px solid var(--color-primary-a20); }
.tip-card .ico { width: 36px; height: 36px; border-radius: var(--radius); background: var(--bg-surface); display: grid; place-items: center; color: var(--color-primary); flex: none; }
.tip-card .ico svg { width: 18px; height: 18px; }
.tip-card b { font-size: var(--text-sm); display: block; }
.tip-card p { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }

.kv { display: flex; flex-direction: column; gap: 12px; font-size: var(--text-sm); }
.kv div { display: flex; justify-content: space-between; gap: 12px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

.stack { display: flex; flex-direction: column; gap: 24px; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.row { display: flex; align-items: center; gap: 10px; }

.proto-tag { font-size: var(--text-xs); font-weight: 600; color: var(--color-secondary); background: var(--bg-purple-tint); border: 1px dashed var(--color-primary-a20); padding: 3px 10px; border-radius: 99px; }
.proto-note {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  max-width: 280px; padding: 10px 14px; border-radius: var(--radius);
  background: #1E1B4B; color: #E0E7FF; font-size: var(--text-xs); box-shadow: var(--shadow-lg);
}
.proto-note b { color: #fff; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 20; }
  .menu-btn { display: inline-flex; padding: 8px; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-primary); border-radius: var(--radius); cursor: pointer; }
  .menu-btn svg { width: 20px; height: 20px; }
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px; gap: 16px; }
  .status-hero { padding: 20px; }
  .status-hero .facts { margin-left: 0; gap: 20px; }
  .card-pad, .card-body { padding-left: 16px; padding-right: 16px; }
  .card-head { padding-left: 16px; padding-right: 16px; }
  .proto-note { display: none; }
}

@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 14px; }
  .stat .value { font-size: var(--text-2xl); }
  .page-head .actions { margin-left: 0; width: 100%; }
  .bar-cell { display: none; }
  .topbar .hide-sm { display: none; }
}
