/* pages.css — the only stylesheet for the remaining server-rendered pages
   (login, changelog, 403/404/500). Hand-written, no framework: Bootstrap and
   Font Awesome were removed when the SPA migration retired the other Jinja
   pages. Tokens mirror frontend/src/index.css so these pages match the app. */

@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Roboto+Slab:wght@400;700;800&display=swap");

:root {
  color-scheme: light;
  --background: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: rgba(0, 29, 59, 0.12);
  --border-strong: rgba(0, 29, 59, 0.18);
  --text: #102541;
  --text-muted: #54657d;
  --brand-blue: #0060a0;
  --brand-blue-strong: #004f83;
  --brand-navy: #001d3b;
  --critical: #9c2f24;
  --critical-soft: rgba(184, 57, 43, 0.12);
  --success: #3a6b2a;
  --success-soft: rgba(212, 228, 188, 0.42);
  --shadow-md: 0 24px 48px rgba(0, 29, 59, 0.08);
  --font-heading: "Roboto Slab", Georgia, serif;
  --font-body: "Roboto", system-ui, sans-serif;
  --radius: 0.375rem;
}

.dark {
  color-scheme: dark;
  --background: #071522;
  --surface: #0e2138;
  --surface-soft: #102744;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #edf4ff;
  --text-muted: #bbcadf;
  --brand-blue: #4fa5dd;
  --brand-blue-strong: #74bbea;
  --critical: #ff9d8f;
  --critical-soft: rgba(255, 120, 100, 0.16);
  --success: #cdeaa8;
  --success-soft: rgba(212, 228, 188, 0.16);
}

* {
  box-sizing: border-box;
}

/* Match the SPA's viewport setup (frontend/src/index.css) so the transition
   between these Jinja pages (login, changelog, errors) and the SPA does not
   shift with the scrollbar: the track stays pinned open, at the same width
   the SPA styles it to (0.78rem vs the 15px browser default). */
html {
  overflow-y: scroll;
  scrollbar-gutter: stable both-edges;
}

html::-webkit-scrollbar {
  width: 0.78rem;
  height: 0.78rem;
}

html::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(0, 96, 160, 0.34);
  background-clip: padding-box;
}

html.dark::-webkit-scrollbar-thumb {
  background: rgba(79, 165, 221, 0.42);
  background-clip: padding-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--background);
}

main.page {
  flex: 1;
  width: 100%;
  max-width: 54rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 800;
  letter-spacing: -0.01em;
}

a {
  color: var(--brand-blue);
}

a:hover {
  color: var(--brand-blue-strong);
}

/* ── Flash messages ─────────────────────────────────────────────────── */

.flash {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  font-size: 14px;
  background: var(--surface-soft);
}

.flash--danger {
  background: var(--critical-soft);
  color: var(--critical);
  border-color: transparent;
}

.flash--success {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

/* ── Buttons (shared) ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.btn--primary {
  background: var(--brand-blue);
  color: #ffffff;
}

.btn--primary:hover {
  background: var(--brand-blue-strong);
  color: #ffffff;
}

.btn--outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn--outline:hover {
  background: var(--surface-soft);
  color: var(--text);
}

/* ── Login ──────────────────────────────────────────────────────────── */

.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.login-card {
  width: 100%;
  max-width: 22.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  text-align: center;
}

.login-card .logo {
  height: 40px;
  width: auto;
  margin: 0 auto 1.25rem;
}

.login-card h1 {
  font-size: 1.35rem;
  margin: 0 0 1.25rem;
  color: var(--text);
}

.login-field {
  text-align: left;
  margin-bottom: 0.85rem;
}

.login-field label {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.login-field input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.login-field input:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 1px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
  font-size: 14px;
  color: var(--text-muted);
}

.login-remember input {
  accent-color: var(--brand-blue);
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.login-card--wide {
  max-width: 26rem;
}

.login-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

/* qrcode's SvgPathImage draws black-on-transparent; keep it on a white tile so
   it stays scannable on the dark theme. */
.qr-frame {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  width: 12rem;
  height: 12rem;
  margin: 0 auto 1rem;
}

.qr-frame svg {
  width: 100%;
  height: 100%;
  display: block;
}

.totp-secret {
  display: inline-block;
  margin-top: 0.35rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.5rem;
  font-size: 14px;
  letter-spacing: 0.05em;
  user-select: all;
}

.or-separator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 14px;
}

.or-separator::before,
.or-separator::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

/* ── Error pages ────────────────────────────────────────────────────── */

.error-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.25rem;
}

.error-code {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 5rem;
  line-height: 1;
  margin: 0 0 0.75rem;
  color: var(--brand-blue);
}

.error-title {
  font-size: 1.3rem;
  margin: 0 0 0.4rem;
  color: var(--text);
}

.error-detail {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.error-wrap .btn {
  width: auto;
  padding-inline: 1.5rem;
}

/* ── Changelog ──────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.6rem;
  margin: 0;
  color: var(--text);
}

.page-header .logo {
  height: 28px;
  width: auto;
}

.markdown-body h2 {
  font-size: 1.35rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.markdown-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.markdown-body ul {
  padding-left: 1.4rem;
}

.markdown-body li {
  margin-bottom: 0.25rem;
}

.markdown-body code {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

.loading-note {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 0;
}

/* ── Footer ─────────────────────────────────────────────────────────── */

footer.page-footer {
  border-top: 1px solid var(--border);
  padding: 0.9rem 1.25rem;
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

footer.page-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer.page-footer a:hover {
  color: var(--brand-blue);
}

/* ── Theme-aware logo ───────────────────────────────────────────────────
   Blue logotype on light surfaces, white on dark (brand rule: match the
   logo to its background). Last in the file so it wins the display battle
   against the per-page .logo layout rules above. */

.logo--light {
  display: block;
}

.logo--dark {
  display: none;
}

.dark .logo--light {
  display: none;
}

.dark .logo--dark {
  display: block;
}
