/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --border: #222222;
  --border-2: #2a2a2a;
  --gold: #c9a84c;
  --gold-dim: rgba(201,168,76,0.15);
  --gold-border: rgba(201,168,76,0.25);
  --white: #ffffff;
  --muted: rgba(255,255,255,0.5);
  --muted-2: rgba(255,255,255,0.25);
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 10px;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--white);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Auth / Login ─────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(201,168,76,0.06) 0%, transparent 70%), var(--bg);
  padding: 2rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.auth-logo p {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.auth-card label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.auth-card input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--white);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.auth-card input:focus { border-color: var(--gold); }

.auth-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: #fca5a5;
  margin-top: 1rem;
  display: none;
}

/* ── Layout ───────────────────────────────────── */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h2 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.sidebar-logo p {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}

.sidebar-nav a:hover { color: var(--white); background: rgba(255,255,255,0.03); }
.sidebar-nav a.active { color: var(--gold); border-left-color: var(--gold); background: var(--gold-dim); }

.sidebar-nav .nav-icon { font-size: 1rem; width: 18px; text-align: center; }

.sidebar-section {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 1rem 1.25rem 0.4rem;
}

.sidebar-bottom {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-bottom a {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}

.sidebar-bottom a:hover { color: var(--white); }

/* ── Main Content ─────────────────────────────── */
.admin-main {
  overflow-y: auto;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-topbar h1 {
  font-size: 1rem;
  font-weight: 600;
}

.event-select {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  color: var(--white);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}

.event-select:focus { border-color: var(--gold); }

.admin-content {
  padding: 2rem;
}

/* ── Stat Cards ───────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card .label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
}

.stat-card .value.gold { color: var(--gold); }
.stat-card .value.green { color: var(--green); }

.stat-card .sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Table ────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.table-header h2 { font-size: 0.9rem; font-weight: 600; }

.search-input {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  color: var(--white);
  font-size: 0.82rem;
  outline: none;
  width: 220px;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--gold); }
.search-input::placeholder { color: var(--muted-2); }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

tbody td {
  padding: 0.8rem 1.25rem;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}

.ticket-id-cell {
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}

/* ── Badges ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-green { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.badge-yellow { background: rgba(234,179,8,0.12); color: #facc15; border: 1px solid rgba(234,179,8,0.2); }
.badge-red { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-gray { background: rgba(255,255,255,0.06); color: var(--muted); border: 1px solid var(--border-2); }
.badge-gold { background: var(--gold-dim); color: var(--gold); border: 1px solid var(--gold-border); }

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gold);
  color: #0a0a0a;
}

.btn-primary:hover { background: #e0bc5a; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-2);
}

.btn-ghost:hover { color: var(--white); border-color: var(--border-2); background: rgba(255,255,255,0.04); }

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.2);
}

.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.72rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.9rem; border-radius: 10px; }

/* ── Form ─────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  color: var(--white);
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--gold); }

.form-group select option { background: #111; }

/* ── Card ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--white);
}

/* ── Scanner ──────────────────────────────────── */
.scanner-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

#reader {
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border-2);
}

.scan-result {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  text-align: center;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.scan-result.show { opacity: 1; pointer-events: all; }
.scan-result.success { background: rgba(34,197,94,0.95); }
.scan-result.already { background: rgba(234,179,8,0.95); }
.scan-result.invalid { background: rgba(239,68,68,0.95); }

.scan-result .icon { font-size: 5rem; margin-bottom: 1rem; }
.scan-result .result-name { font-size: 2rem; font-weight: 700; color: #fff; margin-bottom: 0.5rem; }
.scan-result .result-type { font-size: 1rem; color: rgba(255,255,255,0.8); margin-bottom: 0.25rem; }
.scan-result .result-time { font-size: 0.85rem; color: rgba(255,255,255,0.6); }

/* ── Recent list ──────────────────────────────── */
.recent-list { display: flex; flex-direction: column; gap: 0.5rem; }

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.recent-item:last-child { border-bottom: none; }
.recent-item .r-name { font-weight: 500; }
.recent-item .r-meta { color: var(--muted); font-size: 0.72rem; }
.recent-item .r-time { color: var(--muted-2); font-size: 0.7rem; white-space: nowrap; }

/* ── Action row ───────────────────────────────── */
.action-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Toast ────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 0.82rem;
  color: var(--white);
  z-index: 200;
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.25s;
  max-width: 320px;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.toast-success { border-color: rgba(34,197,94,0.3); }
.toast.toast-error { border-color: rgba(239,68,68,0.3); }

/* ── Modal ────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 0.95rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.25rem; line-height: 1; }
.modal-close:hover { color: var(--white); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -220px; top: 0; bottom: 0; z-index: 40; transition: left 0.25s; }
  .sidebar.open { left: 0; }
  .admin-content { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .mobile-menu-btn { display: flex; }
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  color: var(--white);
  cursor: pointer;
  font-size: 1rem;
}

.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }
.text-muted { color: var(--muted); }
.text-gold { color: var(--gold); }
.mono { font-family: monospace; letter-spacing: 0.05em; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
