/* Admin Dashboard — Styles
   Uses A-GLOW design tokens for visual consistency with A-Play.
   Dark industrial command-center aesthetic. */

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

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Screen reader only ---- */
.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;
}

/* ---- Focus ring — never suppressed ---- */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

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

/* ====================================================================
   LOGIN SCREEN
   ==================================================================== */

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-6);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(75, 108, 226, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(240, 180, 41, 0.04) 0%, transparent 50%),
    var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  padding: var(--sp-10);
}

.login-header {
  text-align: center;
  margin-bottom: var(--sp-8);
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-raised);
  border: 1px solid var(--border-dim);
  border-radius: var(--r-pill);
  padding: var(--sp-1) var(--sp-4) var(--sp-1) var(--sp-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--sp-5);
}

.login-badge .dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.login-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: var(--sp-2);
}

/* ---- Form elements ---- */
.form-group {
  margin-bottom: var(--sp-5);
}

.form-label {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.form-input {
  width: 100%;
  height: 44px;
  background: var(--bg-raised);
  border: 1px solid var(--border-dim);
  border-radius: var(--r-md);
  padding: 0 var(--sp-4);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color var(--motion-fast) var(--motion-ease);
}

.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: var(--border-active); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 44px;
  padding: 0 var(--sp-6);
  border: none;
  border-radius: var(--r-lg);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--motion-fast) var(--motion-ease);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--text-on-accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-dim);
  box-shadow: var(--shadow-hover);
}

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-overlay);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0 var(--sp-3);
  height: 36px;
  font-size: 13px;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-raised);
}

/* ---- Error/success messages ---- */
.msg-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  color: var(--danger);
  margin-bottom: var(--sp-4);
}

.msg-success {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  color: var(--success);
  margin-bottom: var(--sp-4);
}

/* ---- TOTP setup ---- */
.totp-setup {
  text-align: center;
}

.totp-qr {
  display: block;
  margin: var(--sp-4) auto;
  border-radius: var(--r-md);
  border: 2px solid var(--border-mid);
}

.totp-secret-key {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-gold);
  background: var(--bg-raised);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  word-break: break-all;
  margin: var(--sp-3) 0 var(--sp-5);
}

/* ====================================================================
   DASHBOARD SHELL
   ==================================================================== */

.dashboard {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--sp-6);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-dim);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.topbar-brand {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-separator {
  width: 1px;
  height: 20px;
  background: var(--border-mid);
}

.topbar-section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.topbar-session {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.topbar-role {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  background: var(--bg-raised);
  border: 1px solid rgba(240, 180, 41, 0.2);
  border-radius: var(--r-pill);
  padding: 2px 8px;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-dim);
  padding: var(--sp-4) 0;
  overflow-y: auto;
}

.sidebar-section {
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
}

.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 var(--sp-3);
  margin-bottom: var(--sp-2);
}

.sidebar-nav {
  list-style: none;
  padding: 0 var(--sp-2);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-3);
  background: none;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--motion-fast) var(--motion-ease);
  text-align: left;
}

.sidebar-nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
}

.sidebar-nav-item[aria-current="page"] {
  color: var(--text-primary);
  background: var(--bg-raised);
  border-left: 2px solid var(--accent);
  font-weight: 500;
}

.sidebar-nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav-item[aria-current="page"] .nav-icon {
  opacity: 1;
}

/* ---- Main content area ---- */
.main-content {
  padding: var(--sp-8);
  overflow-y: auto;
  max-height: calc(100vh - 56px);
}

.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-8);
}

/* ---- Cards ---- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-6);
  margin-bottom: var(--sp-5);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ---- Stat grid ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: box-shadow var(--motion-hover) var(--motion-ease);
}

.stat-card:hover { box-shadow: var(--shadow-hover); }

.stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.stat-value.accent { color: var(--accent); }
.stat-value.gold { color: var(--accent-gold); }
.stat-value.success { color: var(--success); }
.stat-value.danger { color: var(--danger); }

.stat-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: var(--sp-1);
}

/* ---- Data tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-mid);
}

.data-table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-dim);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: var(--bg-raised);
  color: var(--text-primary);
}

/* ---- Tags / badges ---- */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

.tag-online {
  color: var(--success);
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.tag-offline {
  color: var(--text-muted);
  background: var(--bg-raised);
  border: 1px solid var(--border-dim);
}

.tag-admin {
  color: var(--accent-gold);
  background: rgba(240, 180, 41, 0.1);
  border: 1px solid rgba(240, 180, 41, 0.2);
}

.tag-danger {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.tag-child {
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(75, 108, 226, 0.2);
}

/* ---- Status indicator ---- */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: var(--sp-2);
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-8);
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--sp-4);
  opacity: 0.3;
}

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Section placeholder ---- */
.section-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-mid);
  border-radius: var(--r-lg);
  padding: var(--sp-8);
  text-align: center;
}

.section-placeholder-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.section-placeholder-text {
  font-size: 14px;
  color: var(--text-muted);
}

/* ---- Uptime display ---- */
.uptime {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
}

/* ---- Live region ---- */
#live-region {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .main-content {
    padding: var(--sp-4);
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ====================================================================
   PHASE 5B ADDITIONS
   ==================================================================== */

/* ---- Game cards grid ---- */
.game-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.game-card { padding: var(--sp-5); }

.game-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.game-stat { text-align: center; }

.game-stat-val {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.game-stat-lbl {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Maintenance values ---- */
.maint-val {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

.maint-actions {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ---- Inline forms (ban, etc.) ---- */
.inline-form-row {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  flex-wrap: wrap;
}

.inline-form-row .form-group {
  min-width: 140px;
}

/* ---- Search bar ---- */
.search-bar {
  margin-bottom: var(--sp-5);
}

/* ---- User detail card ---- */
.user-detail-card {
  margin-top: var(--sp-5);
  border-left: 3px solid var(--accent);
}

/* ---- Clickable table rows ---- */
.user-row:hover td {
  background: var(--bg-raised);
  cursor: pointer;
}

.user-row:focus-visible {
  outline: none;
}

.user-row:focus-visible td {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ---- Responsive for Phase 5B ---- */
@media (max-width: 768px) {
  .game-cards-grid {
    grid-template-columns: 1fr;
  }
  .inline-form-row {
    flex-direction: column;
  }
  .inline-form-row .form-group {
    width: 100%;
  }
  .game-card-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
