/* Tap N Roll Backroom — shared brand tokens & components.
   Copy this file into each app's public/ folder, or symlink during build. */

:root {
  /* Legacy hex tokens — keep for compatibility with .tnr-* components below
     and any inline styles that already read them. These are the visual
     source of truth for the Portal look. */
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f242d;
  --surface-3: #262d38;
  --border: #2a313d;
  --border-strong: #3a4250;
  --text: #e7ecf3;
  --text-dim: #9aa3b2;
  --text-mute: #6b7280;
  --accent: #ff5a3c;
  --accent-2: #ffb648;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);

  /* Universal HSL tokens — read by every SPA's Tailwind theme.extend so that
     bg-background / bg-card / bg-primary / border-border etc. resolve to the
     same Portal palette everywhere. Each channel is `H S% L%` (no `hsl()`
     wrapper) so Tailwind's `hsl(var(--x) / <alpha-value>)` can inject alpha.
     Hex equivalents in comments match the legacy tokens above. */
  --background: 220 15% 8%;              /* #0f1115  matches --bg */
  --foreground: 214 27% 93%;             /* #e7ecf3  matches --text */
  --card: 220 15% 12%;                   /* #171a21  matches --surface */
  --card-foreground: 214 27% 93%;
  --card-border: 219 14% 20%;            /* #2a313d  matches --border */
  --popover: 220 15% 12%;
  --popover-foreground: 214 27% 93%;
  --popover-border: 219 14% 20%;
  --primary: 11 100% 62%;                /* #ff5a3c  matches --accent */
  --primary-foreground: 0 0% 100%;
  --primary-border: 11 100% 62%;
  --secondary: 220 14% 15%;              /* #1f242d  matches --surface-2 */
  --secondary-foreground: 214 27% 93%;
  --secondary-border: 219 14% 20%;
  --muted: 220 14% 17%;                  /* #262d38  matches --surface-3 */
  --muted-foreground: 216 12% 66%;       /* #9aa3b2  matches --text-dim */
  --muted-border: 219 14% 20%;
  /* Note: shadcn's `accent` slot is intentionally NOT declared here — the
     legacy hex `--accent: #ff5a3c` above is the single source of truth for
     the accent color, and Tailwind configs below map `accent` to `--primary`
     instead (same value) so `bg-primary` and `bg-accent` render identically. */
  --destructive: 0 84% 60%;              /* #ef4444  matches --danger */
  --destructive-foreground: 0 0% 100%;
  --destructive-border: 0 84% 60%;
  --success-hsl: 142 71% 45%;            /* #22c55e  matches --success */
  --warning-hsl: 38 92% 50%;             /* #f59e0b  matches --warning */
  --info-hsl: 217 91% 60%;               /* #3b82f6  matches --info */
  --border-hsl: 219 14% 20%;             /* #2a313d  matches --border */
  --input: 220 14% 15%;                  /* #1f242d  form-input surface */
  --ring: 11 100% 62%;                   /* accent — focus ring */

  /* Chart palette — accent orange + amber + supporting cool/warm hues so
     charts read cleanly on the Portal-dark background. */
  --chart-1: 11 100% 62%;                /* #ff5a3c  primary */
  --chart-2: 39 100% 64%;                /* #ffb648  amber */
  --chart-3: 217 91% 60%;                /* info blue */
  --chart-4: 142 71% 45%;                /* success green */
  --chart-5: 271 91% 65%;                /* violet */

  /* Sidebar (used by Analytics + a couple of internal tools). */
  --sidebar-background: 220 15% 10%;
  --sidebar-foreground: 214 27% 93%;
  --sidebar-primary: 11 100% 62%;
  --sidebar-primary-foreground: 0 0% 100%;
  --sidebar-accent: 220 14% 15%;
  --sidebar-accent-foreground: 214 27% 93%;
  --sidebar-border: 219 14% 20%;
  --sidebar-ring: 11 100% 62%;

  /* Radius scale — Tailwind `rounded-lg/md/sm` resolve to these. */
  --radius: 14px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Neutralize any per-app `.dark` toggle: the whole suite is dark by default,
   and the shared palette above IS the dark palette. If an app opts into
   Tailwind's `darkMode: 'class'`, applying `class="dark"` should be a no-op. */
.dark {
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

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

/* ---------- Shared topbar ---------- */
.tnr-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,90,60,0.08), transparent);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.tnr-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}

.tnr-brand a { color: inherit; text-decoration: none; }
.tnr-brand-mark { font-size: 22px; }
.tnr-brand-sub { color: var(--accent-2); font-weight: 600; }

.tnr-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tnr-nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
}
.tnr-nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tnr-nav-link.active { background: var(--surface-2); color: var(--text); }

/* Pending-count badge on a nav item (e.g. Redemptions). */
.tnr-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  vertical-align: middle;
}

.tnr-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tnr-user-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
}

.tnr-user-role {
  background: rgba(247, 147, 26, 0.12);
  border: 1px solid rgba(247, 147, 26, 0.35);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tnr-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.tnr-logout:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Layout ---------- */
.tnr-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.tnr-page-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.tnr-page-sub {
  color: var(--text-dim);
  margin: 0 0 24px;
}

/* ---------- Card ---------- */
.tnr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.tnr-card-title {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 12px;
}

/* ---------- Forms ---------- */
.tnr-field { margin-bottom: 14px; }
.tnr-label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.tnr-input, .tnr-select, .tnr-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.tnr-input:focus, .tnr-select:focus, .tnr-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,90,60,0.15);
}
.tnr-textarea { resize: vertical; min-height: 80px; }

/* ---------- Buttons ---------- */
.tnr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s;
}
.tnr-btn:hover { filter: brightness(1.1); }
.tnr-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tnr-btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.tnr-btn-secondary:hover { background: var(--surface-3); filter: none; }

.tnr-btn-danger { background: var(--danger); }

/* ---------- Table ---------- */
.tnr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tnr-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.tnr-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.tnr-table tr:hover td { background: var(--surface-2); }

/* ---------- Badges ---------- */
.tnr-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tnr-badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.tnr-badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.tnr-badge-info { background: rgba(59,130,246,0.15); color: var(--info); }
.tnr-badge-mute { background: var(--surface-3); color: var(--text-dim); }

/* ---------- Footer ---------- */
.tnr-footer {
  border-top: 1px solid var(--border);
  padding: 18px 28px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text-mute);
  font-size: 12px;
  flex-wrap: wrap;
}
.tnr-footer-sep { opacity: 0.4; }

/* ---------- Empty state ---------- */
.tnr-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}
.tnr-empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ---------- Toast ---------- */
.tnr-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 100;
  animation: tnr-toast-in 0.2s ease;
}
@keyframes tnr-toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 640px) {
  .tnr-container { padding: 20px 16px 60px; }
  .tnr-nav { display: none; }
}
