/* Console additions.
 *
 * glass.css owns the design system — colours, .glass, .btn, table.data, .field,
 * .kpi, .admin-shell and the rest. Nothing here restates any of that. This file
 * is only the pieces the super-admin sections introduced: the grouped sidebar,
 * status chips, the permission grid, the campaign composer and the audit trail.
 *
 * Every colour resolves through a glass.css custom property, so both themes and
 * the theme toggle keep working without a single override here.
 */

/* --- the sign-in gate ---------------------------------------------------- */
/* Used only by admin/login.html and admin/two_factor.html, which stand alone
 * rather than extending either base template. Centred, narrow, and carrying no
 * storefront chrome at all. */

.console-gate {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 1rem;
  padding: 2rem 1.25rem;
}

.console-gate-card { width: min(420px, 100%); }

.console-gate-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.console-gate h1 {
  font-size: 1.55rem;
  margin: 0 0 0.4rem;
}

.console-gate .console-gate-note {
  margin: 1rem 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ink-faint);
  text-align: center;
}

.console-gate-foot {
  text-align: center;
  font-size: 0.78rem;
  margin: 0;
}
.console-gate-foot a { color: var(--ink-faint); }
.console-gate-foot a:hover { color: var(--accent); }

/* --- sidebar grouping ---------------------------------------------------- */

.nav-group-label {
  margin: 1.15rem 0 0.3rem;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.admin-nav a { display: flex; align-items: center; gap: 0.55rem; }

.nav-glyph {
  display: inline-block;
  width: 1em;
  text-align: center;
  opacity: 0.75;
  flex: none;
}
.admin-nav a.is-active .nav-glyph { opacity: 1; }

.role-chip {
  display: inline-block;
  margin-top: 0.3rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
}
.role-chip.role-superadmin {
  color: var(--amber-500);
  border-color: rgba(213, 154, 60, 0.4);
}

.warn-link { color: var(--amber-500); font-weight: 600; }

/* --- state chips --------------------------------------------------------- */
/* One vocabulary for "what is this thing doing right now", used by promotions,
 * campaigns and subscriptions alike. Same word means the same colour anywhere
 * in the console. */

.state {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
  white-space: nowrap;
}
.state::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.state-live, .state-sent, .state-active {
  color: var(--mint-500); border-color: rgba(63, 174, 144, 0.35);
}
.state-scheduled, .state-sending, .state-draft {
  color: var(--accent); border-color: rgba(91, 138, 196, 0.35);
}
.state-paused, .state-expired, .state-cancelled, .state-exhausted {
  color: var(--ink-faint);
}
.state-failed, .state-alert {
  color: var(--rose-500); border-color: rgba(200, 90, 90, 0.35);
}

/* --- overview: what is waiting ------------------------------------------- */

.waiting-list { display: grid; gap: 0.5rem; }

.waiting-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  color: var(--ink);
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.waiting-row:hover { background: var(--hairline-soft); transform: translateX(2px); }

.waiting-count {
  min-width: 2.1rem;
  padding: 0.1rem 0.45rem;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  flex: none;
}

/* --- permission grid ----------------------------------------------------- */

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.1rem;
}

.perm-group { display: grid; gap: 0.35rem; align-content: start; }

.perm-group > h4 {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* The whole row is the hit target, not just the 13px box. */
.perm {
  display: flex;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.perm:hover { background: var(--hairline-soft); }
.perm input { margin-top: 0.2rem; flex: none; }
.perm-label { font-size: 0.85rem; font-weight: 500; display: block; }
.perm-blurb { font-size: 0.72rem; color: var(--ink-faint); line-height: 1.4; }

.perm.is-locked { opacity: 0.5; cursor: not-allowed; }
.perm.is-locked .perm-blurb { font-style: italic; }

/* --- campaign composer --------------------------------------------------- */

.compose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 1000px) { .compose-grid { grid-template-columns: 1fr; } }

.compose-body {
  min-height: 340px;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.85rem;
  line-height: 1.65;
  resize: vertical;
}

/* The preview is the recipient's document, not ours — it carries its own
 * light-background styling inline, so it is framed rather than restyled. */
.email-preview {
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
  background: #f1f5f9;
}
.email-preview iframe { display: block; width: 100%; height: 460px; border: 0; }

.merge-chip {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  margin: 0 0.15rem 0.25rem 0;
  border-radius: 5px;
  border: 1px solid var(--hairline);
  background: var(--hairline-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  cursor: pointer;
}
.merge-chip:hover { border-color: var(--accent); color: var(--accent); }

/* The send box. Deliberately the most visually serious thing in the console —
 * it is the one action nothing else here can undo. */
.danger-zone {
  border: 1px solid rgba(200, 90, 90, 0.4);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  background: rgba(200, 90, 90, 0.05);
}
.danger-zone h3 { margin: 0 0 0.4rem; font-size: 0.95rem; color: var(--rose-500); }

.btn-danger { --btn-bg: var(--rose-500); --btn-fg: #fff; }

/* --- audit trail --------------------------------------------------------- */

.audit-row { display: grid; gap: 0.15rem; }
.audit-action {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--accent);
}
.audit-diff {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--ink-faint);
  word-break: break-word;
}
.audit-diff del { color: var(--rose-500); text-decoration: none; }
.audit-diff ins { color: var(--mint-500); text-decoration: none; }

tr.sev-alert td { background: rgba(200, 90, 90, 0.06); }

/* --- recovery codes ------------------------------------------------------ */
/* Shown exactly once. Monospaced and widely spaced because they get copied by
 * hand into a password manager more often than anyone admits. */

.code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}
.code-grid code {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px dashed var(--hairline);
  background: var(--hairline-soft);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-align: center;
}

.qr-block {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.qr-block canvas, .qr-block .qr-fallback {
  border-radius: 10px;
  border: 1px solid var(--hairline);
  padding: 0.75rem;
  background: #fff;
}

/* --- mailbox ------------------------------------------------------------- */
/* Inbound mail is rendered as pre-wrapped plain text, never as the sender's
 * HTML — see the comment in admin/mail_thread.html for why that is a security
 * decision and not a styling one. The consequence is that this rule has to do
 * all the work a mail client's renderer would otherwise do. */

.mail-body {
  margin: 0;
  font: 400 0.9rem/1.65 var(--font);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;   /* a pasted tracking URL must not widen the page */
  max-height: 40rem;
  overflow-y: auto;
}

/* --- push enrolment ------------------------------------------------------ */

.push-status { margin: 0.5rem 0 0; min-height: 1.2em; }
.push-status-ok   { color: var(--accent); }
.push-status-warn { color: var(--amber-500); }
