/* Admin portal — layered on top of site.css so /admin shares the same dark
   crimson/blood design system as the rest of radio.launchpad.dad instead of
   looking like a bolted-on tool. Only the bits site.css doesn't already
   have (forms, tables, status pills, flash banners) live here. */

.admin-shell { padding: 48px 0 80px; }

.admin-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.admin-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
}
.admin-header .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
/* Solid background, not just a coral text color — the page's blurred
   crimson/coral atmosphere blobs (site.css .field) sit behind everything,
   and coral text with no backing was reading as an unreadable pink smear
   wherever a blob happened to drift underneath it. */
.admin-header .who .id-pill {
  color: var(--white);
  background: rgba(226, 55, 68, 0.22);
  border: 1px solid rgba(255, 122, 110, 0.4);
  border-radius: 100px;
  padding: 4px 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.admin-card {
  border-radius: 20px;
  padding: 1px;
  background: linear-gradient(155deg, rgba(242,227,225,0.35), rgba(226,55,68,0.30) 45%, rgba(255,122,110,0.35) 75%, rgba(242,227,225,0.18));
  margin-bottom: 20px;
}
.admin-card-inner {
  border-radius: 19px;
  padding: 24px 26px 26px;
  background: rgba(20, 7, 8, 0.78);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}
.admin-card-inner h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
}
.admin-card-inner .hint {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--muted);
}

.admin-card.flash {
  background: linear-gradient(155deg, rgba(255,122,110,0.6), rgba(226,55,68,0.55) 50%, rgba(255,184,77,0.4));
}
.admin-card.flash .admin-card-inner { background: rgba(26, 8, 9, 0.85); }

/* ---------- form controls ---------- */
.admin-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.admin-field label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.admin-input,
input[type="text"].admin-input,
input[type="email"].admin-input,
input[type="password"].admin-input,
input[type="number"].admin-input {
  font: inherit;
  font-size: 14.5px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  outline: none;
  transition: border-color .2s ease, background .2s ease;
  /* Tells the browser to render its own native chrome (the number
     spinner arrows, autofill highlight, etc.) in a dark-appropriate
     palette instead of the stark light-mode default it'd otherwise use
     regardless of the page's own dark styling. */
  color-scheme: dark;
}
textarea.admin-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
}
.admin-input:focus {
  border-color: rgba(226,55,68,0.65);
  background: rgba(226, 55, 68, 0.06);
}

.admin-form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.admin-form-row .admin-field { flex: 1 1 220px; margin-bottom: 0; }

/* Custom checkbox — a native one renders as a stark light-mode square
   regardless of color-scheme, so it's fully reskinned rather than just
   tinted. */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  position: relative;
  transition: border-color .2s ease, background .2s ease;
}
input[type="checkbox"]:hover:not(:disabled) { border-color: rgba(255,122,110,0.55); }
input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--crimson), var(--crimson-deep));
  border-color: rgba(255,122,110,0.6);
}
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(226,55,68,0.6);
  outline-offset: 2px;
}
input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.admin-btn {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white);
  background: linear-gradient(135deg, var(--crimson), var(--crimson-deep));
  border: 1px solid rgba(255,122,110,0.4);
  border-radius: 10px;
  padding: 11px 20px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.admin-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(226,55,68,0.35); }
.admin-btn:active { transform: translateY(0); }
.admin-btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--silver);
}
.admin-btn.ghost:hover { color: var(--white); background: rgba(226,55,68,0.12); box-shadow: none; }
.admin-btn.danger {
  background: transparent;
  border: 1px solid rgba(255,122,110,0.35);
  color: var(--coral);
  padding: 6px 12px;
  font-size: 11px;
}
.admin-btn.danger:hover { background: rgba(226,55,68,0.14); box-shadow: none; }

/* ---------- pagination ---------- */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--silver);
}
.admin-pagination a {
  color: var(--white);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 14px;
  transition: background .15s ease, color .15s ease;
}
.admin-pagination a:hover { background: rgba(226,55,68,0.12); }
.admin-pagination .disabled {
  color: var(--silver);
  opacity: 0.35;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: default;
}

/* ---------- key reveal ---------- */
.key-reveal {
  display: block;
  word-break: break-all;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--white);
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,122,110,0.3);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
}

.qr-reveal {
  display: inline-block;
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-top: 14px;
}
.qr-reveal svg {
  display: block;
  width: 180px;
  height: 180px;
}

/* ---------- table ---------- */
.admin-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--silver);
}
.admin-table th {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.admin-table code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--coral);
}
.admin-table tr.is-revoked td { color: var(--muted); text-decoration: line-through; }

.admin-pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 100px;
}
.admin-pill.active { color: var(--coral); border: 1px solid rgba(255,122,110,0.5); }
.admin-pill.revoked { color: var(--muted); border: 1px solid var(--line); }

.admin-empty { color: var(--muted); font-size: 13.5px; margin: 10px 0 0; }

/* ---------- users list (dashboard) ---------- */
.admin-search {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 0 16px;
}
.admin-users-table { width: 100%; border-collapse: collapse; }
.admin-users-table th, .admin-users-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--silver);
}
.admin-users-table th {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.admin-users-table tr:last-child td { border-bottom: none; }
.admin-users-table tr:hover td { background: rgba(226, 55, 68, 0.05); }
.admin-users-table .email-cell { color: var(--white); font-weight: 600; }
.admin-users-table .key-count { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.admin-users-table .key-count .active-n { color: var(--coral); font-weight: 600; }
.admin-users-table .manage-link {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--coral);
}
.admin-users-table .manage-link:hover { text-decoration: underline; }
.admin-users-table tr.no-match { display: none; }

.admin-back-link {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  margin-bottom: 16px;
}
.admin-back-link:hover { color: var(--white); }

/* ---------- login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card { width: 100%; max-width: 340px; }
.login-card .brand {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.login-card .brand .led {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--crimson);
  box-shadow: 0 0 8px var(--crimson), 0 0 16px rgba(226,55,68,0.7);
  animation: pulse 2.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .login-card .brand .led { animation: none; } }
.login-card .subtitle { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.login-error {
  font-size: 13px;
  color: var(--coral);
  background: rgba(226,55,68,0.12);
  border: 1px solid rgba(255,122,110,0.35);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

/* ---------- usage dashboard ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  border-radius: 16px;
  padding: 16px 18px;
  background: rgba(20, 7, 8, 0.78);
  border: 1px solid var(--line);
}
.stat-card .stat-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-card .stat-value {
  margin-top: 6px;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--white);
}
.stat-card .stat-value.cost { color: var(--coral); }
.stat-card .stat-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.usage-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  margin-top: 10px;
}
.usage-chart .bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.usage-chart .bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--coral), var(--crimson-deep));
}
.usage-chart .bar-day {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- responsive ---------- */
/* The mobile nav toggle itself (.site-nav .toggle / .links.is-open) is
   already defined in site.css and shared by every page, admin included —
   these are the admin-only follow-ups: wide tables need a scroll container
   instead of overflowing the viewport, and the shell/cards can afford to
   give some of their desktop padding back on a small screen. */
@media (max-width: 640px) {
  .admin-shell { padding: 28px 0 56px; }
  .admin-header { gap: 10px; margin-bottom: 24px; }
  .admin-header h1 { font-size: 1.25rem; }
  .admin-card-inner { padding: 18px 16px 20px; }

  /* display:block lets a <table> scroll horizontally on its own — the
     internal row/cell layout is unaffected, so this needs no template
     changes, just this rule. */
  .admin-table, .admin-users-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
}
