/* RaceLive Wireframe Design System — Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #0a1628;
  --surface: #0f2236;
  --surface-2: #122843;
  --border: rgba(255,255,255,0.1);
  --border-dark: rgba(255,255,255,0.18);
  --text-primary: #ffffff;
  --text-secondary: rgba(255,255,255,0.65);
  --text-muted: rgba(255,255,255,0.38);
  --accent: #e8480a;
  --accent-light: rgba(232,72,10,0.12);
  --accent-hover: #ff5e22;
  --success: #22c55e;
  --success-light: rgba(34,197,94,0.12);
  --warning: #f59e0b;
  --warning-light: rgba(245,158,11,0.12);
  --danger: #ef4444;
  --danger-light: rgba(239,68,68,0.12);
  --admin-accent: #e8480a;
  --admin-light: rgba(232,72,10,0.12);
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.6);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.7);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

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

.sidebar {
  width: 240px;
  background: #06101c;
  border-right: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sidebar-logo .logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 14px;
}
.sidebar-logo .logo-text { font-weight: 700; font-size: 16px; color: var(--text-primary); }
.sidebar-logo .logo-text span { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255,255,255,0.28);
  padding: 8px 20px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
  font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active {
  background: rgba(232,72,10,0.15);
  color: #e8480a;
  font-weight: 600;
  border-right: 2px solid #e8480a;
}
.nav-item.active .nav-icon { color: #e8480a; }
.nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--danger);
  color: white; border-radius: 10px; font-size: 10px;
  font-weight: 700; padding: 1px 6px; min-width: 18px; text-align: center;
}

.sidebar-footer { padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.07); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: var(--radius); cursor: pointer;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
}
.user-chip:hover { background: rgba(255,255,255,0.07); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.avatar.admin { background: var(--admin-accent); }
.user-chip-info .name { font-weight: 600; font-size: 13px; color: #fff; }
.user-chip-info .role { font-size: 11px; color: var(--text-muted); }

.main-content { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: 56px; background: #06101c;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; padding: 0 28px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 700; flex: 1; color: #fff; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 28px; flex: 1; }

/* ── Auth layout ── */
.auth-shell { min-height: 100vh; display: flex; background: var(--bg); }
.auth-brand { width: 420px; flex-shrink: 0; background: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: white; }
.auth-brand.admin-brand { background: var(--admin-accent); }
.auth-brand-logo { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.auth-brand-logo span { opacity: .7; }
.auth-brand-tagline { font-size: 14px; opacity: .8; text-align: center; max-width: 280px; }
.auth-form-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 440px; }
.auth-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--text-secondary); margin-bottom: 28px; font-size: 13.5px; }

/* ── Components ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; color: #fff; }
.card-body { padding: 20px; }

.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow);
  cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); border-color: rgba(255,255,255,0.22); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; margin-bottom: 6px; color: #fff; }
.stat-delta { font-size: 12px; color: var(--text-secondary); }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600; border: 1.5px solid transparent; cursor: pointer; transition: all .15s; text-decoration: none; font-family: 'Inter', sans-serif; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 4px 16px rgba(232,72,10,0.35); }
.btn-secondary { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.8); border-color: rgba(255,255,255,0.15); }
.btn-secondary:hover { background: rgba(255,255,255,0.12); color: #fff; }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #f87171; }
.btn-admin { background: var(--admin-accent); color: white; border-color: var(--admin-accent); }
.btn-admin:hover { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(232,72,10,0.35); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; width: 100%; }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }

.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: rgba(255,255,255,0.75); }
.form-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: var(--radius); font-size: 14px; color: #fff;
  background: rgba(255,255,255,0.05); outline: none;
  font-family: 'Inter', sans-serif;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,72,10,0.15); }
.form-input::placeholder { color: rgba(255,255,255,0.25); }
select.form-input { background-color: var(--surface-2); }
select.form-input option, select option { background: var(--surface-2); color: #fff; }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-live { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.25); }
.badge-live::before { content: '●'; margin-right: 5px; font-size: 8px; animation: pulse 1.5s infinite; }
.badge-offline { background: rgba(255,255,255,0.06); color: var(--text-muted); border: 1px solid var(--border); }
.badge-scheduled { background: rgba(232,72,10,0.12); color: #fb923c; border: 1px solid rgba(232,72,10,0.2); }
.badge-completed { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.badge-warning { background: rgba(245,158,11,0.12); color: #fbbf24; }
.badge-success { background: rgba(34,197,94,0.12); color: #4ade80; }
.badge-admin { background: rgba(232,72,10,0.12); color: #fb923c; border: 1px solid rgba(232,72,10,0.2); }
.badge-danger { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-default { background: rgba(255,255,255,0.07); color: var(--text-muted); border: 1px solid var(--border); }
.badge-infra-live { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.03);
}
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; color: var(--text-primary); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: rgba(255,255,255,0.04); }

/* ── Status ── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.green { background: var(--success); }
.status-dot.red { background: var(--danger); animation: pulse 1.5s infinite; }
.status-dot.yellow { background: var(--warning); }
.status-dot.gray { background: rgba(255,255,255,0.3); }

.progress-bar { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.progress-fill.green { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* ── Grid helpers ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Utility ── */
.mb-4{margin-bottom:4px} .mb-8{margin-bottom:8px} .mb-12{margin-bottom:12px} .mb-16{margin-bottom:16px} .mb-20{margin-bottom:20px} .mb-24{margin-bottom:24px}
.mt-4{margin-top:4px} .mt-8{margin-top:8px} .mt-12{margin-top:12px} .mt-16{margin-top:16px} .mt-20{margin-top:20px}
.flex{display:flex} .items-center{align-items:center} .justify-between{justify-content:space-between} .gap-8{gap:8px} .gap-12{gap:12px} .gap-16{gap:16px}
.text-sm{font-size:12px} .text-muted{color:var(--text-muted)} .text-secondary{color:var(--text-secondary)} .text-accent{color:var(--accent)} .font-bold{font-weight:700} .font-semibold{font-weight:600}

/* ── Mobile / Responsive ── */

/* Hamburger toggle — hidden on desktop */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 22px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* Full-screen overlay when sidebar is open on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 150;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.sidebar-open .sidebar-overlay { display: block; }

@media (max-width: 768px) {
  /* Sidebar: off-canvas drawer */
  .sidebar {
    transform: translateX(-260px);
    transition: transform 0.25s ease;
    z-index: 200;
    width: 260px;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Main content: full width, no left offset */
  .main-content { margin-left: 0; }

  /* Show hamburger */
  .sidebar-toggle { display: flex; }

  /* Topbar: tighter padding */
  .topbar { padding: 0 14px; gap: 10px; height: 52px; }
  .topbar-title { font-size: 14px; }
  .topbar-actions { gap: 6px; flex-wrap: nowrap; }
  /* Shrink/hide topbar text labels on very small screens if needed */
  .topbar-actions .btn-sm { padding: 5px 10px; font-size: 11px; }

  /* Page body: less padding */
  .page-body { padding: 16px; }

  /* Auth layout: stack vertically */
  .auth-shell { flex-direction: column; }
  .auth-brand {
    width: 100%;
    min-height: 0;
    padding: 24px 20px;
    flex-direction: row;
    gap: 16px;
    align-items: center;
    justify-content: flex-start;
  }
  .auth-brand-logo { font-size: 22px; margin-bottom: 0; }
  .auth-brand-tagline { display: none; }
  .auth-form-panel { padding: 24px 16px; align-items: stretch; }
  .auth-card { padding: 28px 20px; max-width: 100%; }

  /* Grid helpers: collapse to single column */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Form rows: stack */
  .form-row { grid-template-columns: 1fr; }

  /* Tables: allow horizontal scroll */
  .table-wrap, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }

  /* Tabs: scroll horizontally */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab { white-space: nowrap; }

  /* Buttons: touch-friendly */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .btn-lg { min-height: 48px; }

  /* Stat cards */
  .stat-value { font-size: 26px; }

  /* OTP inputs: slightly smaller */
  .otp-input { width: 42px; height: 52px; font-size: 20px; }
  .otp-row { gap: 8px; }

  /* Cards: reduce padding */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
}

@media (max-width: 480px) {
  .page-body { padding: 12px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .auth-card { padding: 20px 16px; }
  .stat-value { font-size: 22px; }
  .badge { font-size: 10px; padding: 2px 8px; }
  /* Stack topbar actions below title on very small screens if they overflow */
  .topbar-actions .btn span { display: none; }
}

/* ── Wireframe annotation ── */
.wf-note { font-size: 11px; color: rgba(255,255,255,0.25); font-style: italic; border-left: 3px solid rgba(255,255,255,0.1); padding-left: 8px; margin-top: 6px; }
.wf-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.05); border: 1px dashed rgba(255,255,255,0.15); border-radius: var(--radius-sm); padding: 2px 6px; display: inline-block; }

/* ── Page header ── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; color: #fff; }
.page-header .subtitle { color: var(--text-secondary); font-size: 13.5px; }

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 15px; top: 28px; bottom: 0; width: 2px; background: rgba(255,255,255,0.08); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; z-index: 1; }
.timeline-dot.green { background: rgba(34,197,94,0.15); color: #4ade80; }
.timeline-dot.blue { background: rgba(232,72,10,0.12); color: #fb923c; }
.timeline-dot.gray { background: rgba(255,255,255,0.06); border: 2px solid rgba(255,255,255,0.12); }
.timeline-content { flex: 1; padding-top: 6px; }
.timeline-content .title { font-weight: 600; font-size: 13.5px; color: #fff; }
.timeline-content .time { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Chart placeholder ── */
.chart-area { background: rgba(255,255,255,0.03); border-radius: var(--radius); border: 1px dashed rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--text-muted); font-size: 13px; }
.chart-area .chart-icon { font-size: 28px; opacity: .4; }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 2px solid rgba(255,255,255,0.08); margin-bottom: 20px; }
.tab { padding: 10px 18px; font-size: 13.5px; font-weight: 500; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab:hover { color: #fff; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── OTP ── */
.otp-row { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }
.otp-input {
  width: 52px; height: 60px;
  border: 2px solid rgba(255,255,255,0.15); border-radius: var(--radius);
  font-size: 24px; font-weight: 700; text-align: center; outline: none;
  background: rgba(255,255,255,0.05); color: #fff;
}
.otp-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,72,10,0.2); }

/* ── Event cards (user dashboard) ── */
.event-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s;
}
.event-card:hover { box-shadow: var(--shadow-md); border-color: rgba(255,255,255,0.2); }
.event-card-thumb {
  height: 120px; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px; position: relative;
}
.play-icon { position: absolute; bottom: 12px; right: 12px; font-size: 28px; opacity: .6; }
.event-card-body { padding: 14px; }
.event-card-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; color: #fff; }
.event-card-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); }
