/* ShowApp — shared design system (web).
 *
 * Mirrors the app's tokens (src/theme.ts) one-for-one so showapp.app and the
 * iOS/Android app read as the same product: Uber-inspired, monochrome, with
 * periwinkle kept as a functional accent only (links, active/selected, LIVE).
 *
 * Adaptive: light is the default, dark applies via prefers-color-scheme.
 * `data-theme="light|dark"` on <html> forces one, for a future manual toggle.
 *
 * Include via web-head.php. Safe to add to a page before its own inline
 * <style> is removed — page rules come later in the cascade and still win, so
 * migration can happen one page at a time.
 */

/* ── Tokens ───────────────────────────────────────────────────────────── */
:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-hi: #F7F8FA;
  --surface-max: #EEF0F3;
  --surface-alt: #F1F2F4;

  --text: #0A0A0B;
  --text-secondary: #6B7076;
  --text-muted: #9A9EA6;
  --text-faint: #B9BDC5;

  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --fill: rgba(0, 0, 0, 0.04);
  --fill-hi: rgba(0, 0, 0, 0.07);

  /* Monochrome does the primary work. */
  --primary: #0A0A0B;
  --on-primary: #FFFFFF;

  /* Functional accent only. */
  --accent: #3D74E6;
  --on-accent: #FFFFFF;
  --accent-subtle: #EAF1FE;

  --live: #16A34A;
  --success: #16A34A;
  --warning: #B45309;
  --danger: #DC2626;

  --scrim: rgba(0, 0, 0, 0.45);

  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-card: 16px;
  --radius-xl: 20px;
  --radius-pill: 100px;

  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --tabbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0B0B0D;
    --surface: #161619;
    --surface-hi: #1E1E22;
    --surface-max: #28282D;
    --surface-alt: #28282D;

    --text: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.65);
    --text-muted: rgba(255, 255, 255, 0.5);
    --text-faint: rgba(255, 255, 255, 0.35);

    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.20);
    --fill: rgba(255, 255, 255, 0.05);
    --fill-hi: rgba(255, 255, 255, 0.09);

    --primary: #FFFFFF;
    --on-primary: #0B0B0D;

    --accent: #7EB3F7;
    --on-accent: #0B0B0D;
    --accent-subtle: rgba(126, 179, 247, 0.14);

    --live: #22C55E;
    --success: #22C55E;
    --warning: #FBBF24;
    --danger: #EF4444;

    --scrim: rgba(0, 0, 0, 0.6);
  }
}

/* Manual override wins in both directions. */
:root[data-theme='dark'] {
  --bg: #0B0B0D;
  --surface: #161619;
  --surface-hi: #1E1E22;
  --surface-max: #28282D;
  --surface-alt: #28282D;
  --text: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-muted: rgba(255, 255, 255, 0.5);
  --text-faint: rgba(255, 255, 255, 0.35);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);
  --fill: rgba(255, 255, 255, 0.05);
  --fill-hi: rgba(255, 255, 255, 0.09);
  --primary: #FFFFFF;
  --on-primary: #0B0B0D;
  --accent: #7EB3F7;
  --on-accent: #0B0B0D;
  --accent-subtle: rgba(126, 179, 247, 0.14);
  --live: #22C55E;
  --success: #22C55E;
  --warning: #FBBF24;
  --danger: #EF4444;
  --scrim: rgba(0, 0, 0, 0.6);
}

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

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

::selection { background: var(--accent); color: var(--on-accent); }

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

/* ── Type ─────────────────────────────────────────────────────────────── */
.h1 { font-size: 34px; line-height: 38px; font-weight: 700; letter-spacing: -1.3px; margin: 0; }
.h2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.6px; margin: 0; }
.h3 { font-size: 18px; line-height: 24px; font-weight: 600; letter-spacing: -0.3px; margin: 0; }
.body { font-size: 16px; line-height: 24px; letter-spacing: -0.1px; }
.body-sm { font-size: 14px; line-height: 20px; letter-spacing: -0.1px; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.mono { font-family: var(--font-mono); }

/* Uppercase section label — the app's SectionHeader. */
.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin: 0 0 10px;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  line-height: 1.2;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, transform 0.1s;
  text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; }
.btn-block { display: flex; width: 100%; }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { opacity: 0.88; }

.btn-secondary { background: var(--surface-alt); color: var(--text); }
.btn-secondary:hover { background: var(--fill-hi); }

.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--fill); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 9px 14px; font-size: 13px; }

/* Circular icon button — the app's IconButton (Uber's grey back circle). */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.icon-btn:hover { background: var(--fill-hi); }

/* ── Surfaces ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px;
}
.card-tap { cursor: pointer; transition: border-color 0.15s; }
.card-tap:hover { border-color: var(--border-strong); }

/* Tile row — the app's compact 2/3-up action tiles. */
.tile-row { display: flex; gap: 8px; }
.tile {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.tile:hover { border-color: var(--border-strong); }

/* Stat tiles — the Dashboard strip. */
.stat-tile {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
}
.stat-num { font-size: 21px; font-weight: 700; letter-spacing: -0.6px; line-height: 24px; }
.stat-label {
  font-size: 9.5px; font-weight: 600; color: var(--text-muted);
  letter-spacing: 0.4px; text-transform: uppercase; margin-top: 2px;
}

/* ── Chips ────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-live { color: var(--live); background: rgba(34, 197, 94, 0.14); }
.chip-warning { color: var(--warning); background: rgba(245, 158, 11, 0.16); }
.chip-danger { color: var(--danger); background: rgba(239, 68, 68, 0.14); }
.chip-accent { color: var(--accent); background: var(--accent-subtle); }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.input, .textarea, .select {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  line-height: 1.4;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--border-strong);
}
.textarea { min-height: 110px; resize: vertical; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 6px; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.wrap { max-width: 640px; margin: 0 auto; padding: 28px 20px 96px; width: 100%; }
.wrap-wide { max-width: 880px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 10px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }

.divider { height: 1px; background: var(--border); border: 0; margin: 20px 0; }

/* ── Top nav ──────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-logo { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; letter-spacing: -0.4px; }

/* ── Bottom tab bar (web-footer.php) ──────────────────────────────────── */
.web-tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.web-tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1px;
  padding: 0 4px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
.web-tabbar a svg { width: 24px; height: 24px; flex: none; }
/* Active tab is ink, not accent — monochrome, matching the app. */
.web-tabbar a.active { color: var(--text); }
.web-tabbar a:active { opacity: 0.7; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.footer { text-align: center; padding: 28px 20px; color: var(--text-faint); font-size: 12px; }
.footer a { color: var(--text-muted); text-decoration: underline; }

/* ── Sheet / modal ────────────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 900;
  background: var(--scrim);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 901;
  background: var(--surface);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  padding: 10px 20px calc(28px + env(safe-area-inset-bottom));
  max-height: 86vh;
  overflow-y: auto;
}
.sheet-grip {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border-strong);
  margin: 0 auto 14px;
}

/* ── Banners ──────────────────────────────────────────────────────────── */
.banner { border-radius: var(--radius-md); padding: 12px 14px; font-size: 13.5px; margin-bottom: 16px; }
.banner-ok { background: rgba(34, 197, 94, 0.12); color: var(--success); }
.banner-err { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.banner-warn { background: rgba(245, 158, 11, 0.14); color: var(--warning); }

/* ── Utilities ────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.center { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
