/*
 * The sign-in pages (two_factor/_base.html and everything that extends it:
 * sign-in, two-step verification set-up, backup tokens, disable, and the
 * password reset pages), styled like the React app: Inter, the purple and
 * lime tokens of frontend/src/index.css, white cards on a pale page, 6px
 * controls, a visible focus ring. Bootstrap stays underneath (the packaged
 * two_factor templates use its classes); this file only restyles them.
 */
:root {
  --auth-font: "Inter Variable", "Helvetica Neue", Arial, sans-serif;
  --auth-brand-950: #1e0f36;
  --auth-brand-900: #2c174f;
  --auth-brand-800: #402371;
  --auth-brand-700: #5a3a99;
  --auth-brand-600: #6f4ec4;
  --auth-brand-200: #ddd3f2;
  --auth-brand-100: #ece7f8;
  --auth-brand-50: #f6f3fc;
  --auth-sun-500: #b0d52e;
  --auth-slate-50: #f8fafc;
  --auth-slate-200: #e2e8f0;
  --auth-slate-300: #cbd5e1;
  --auth-slate-500: #64748b;
  --auth-slate-600: #475569;
  --auth-slate-700: #334155;
  --auth-slate-900: #0f172a;
  --auth-red-50: #fef2f2;
  --auth-red-200: #fecaca;
  --auth-red-700: #b91c1c;
  --auth-red-800: #991b1b;
  --auth-green-50: #ecfdf5;
  --auth-green-200: #a7f3d0;
  --auth-green-800: #065f46;
  --auth-amber-50: #fffbeb;
  --auth-amber-200: #fde68a;
  --auth-amber-800: #92400e;
  --auth-focus: 0 0 0 2px #fff, 0 0 0 4px var(--auth-brand-600);
}

/* ---- Page ------------------------------------------------------------- */
body.auth-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--auth-font);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--auth-slate-700);
  background:
    linear-gradient(180deg, var(--auth-brand-50) 0, var(--auth-brand-50) 220px, var(--auth-slate-50) 220px);
  font-variant-numeric: tabular-nums;
}
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 48px 16px 24px;
}
.auth-logo {
  display: block;
  height: 56px;
  width: auto;
  margin: 0 auto 28px;
}
.auth-column {
  width: 100%;
  max-width: 440px;
}
.auth-card {
  background: #fff;
  border: 1px solid var(--auth-slate-200);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(64, 35, 113, 0.08);
  padding: 28px;
  color: var(--auth-slate-700);
  overflow-wrap: anywhere;
}
.auth-footer {
  margin-top: auto;
  padding-top: 32px;
  font-size: 0.75rem;
  color: var(--auth-slate-500);
  text-align: center;
}
@media (max-width: 575.98px) {
  .auth-page { padding-top: 28px; }
  .auth-logo { height: 44px; margin-bottom: 20px; }
  .auth-card { padding: 20px; }
}

/* ---- Type ------------------------------------------------------------- */
.auth-card h1,
.auth-card .h4 {
  font-size: 1.3125rem;          /* 21px, the app's page title */
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--auth-slate-900);
  margin: 0 0 8px;
}
.auth-card h2,
.auth-card h3 {
  font-size: 0.9375rem;          /* 15px, the app's card title */
  font-weight: 600;
  color: var(--auth-slate-900);
  margin: 20px 0 6px;
}
.auth-card p { margin: 0 0 12px; }
.auth-card > p:first-of-type,
.auth-card .text-muted {
  color: var(--auth-slate-600) !important;
}
.auth-card hr {
  border: 0;
  border-top: 1px solid var(--auth-slate-200);
  opacity: 1;
  margin: 20px 0;
}
.auth-card ul { padding-left: 1.1rem; }

/* ---- Links ------------------------------------------------------------ */
.auth-body a {
  color: var(--auth-brand-700);
  text-decoration: none;
  border-radius: 4px;
}
.auth-body a:hover { text-decoration: underline; }
.auth-body a:focus-visible,
.auth-body button:focus-visible,
.auth-body input:focus-visible,
.auth-body select:focus-visible,
.auth-body .btn:focus-visible {
  outline: none;
  box-shadow: var(--auth-focus);
}

/* ---- Fields ----------------------------------------------------------- */
.auth-card .form-label,
.auth-card label {
  display: inline-block;
  font-weight: 500;
  color: var(--auth-slate-700);
  margin-bottom: 6px;
}
.auth-card .form-control,
.auth-card .form-select,
.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="tel"],
.auth-card input[type="number"],
.auth-card select {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--auth-slate-900);
  background: #fff;
  border: 1px solid var(--auth-slate-300);
  border-radius: 6px;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.auth-card .form-control:focus,
.auth-card .form-select:focus,
.auth-card input:focus,
.auth-card select:focus {
  outline: none;
  border-color: var(--auth-brand-600);
  box-shadow: 0 0 0 3px rgba(111, 78, 196, 0.25);
}
.auth-card .form-control.is-invalid,
.auth-card [aria-invalid="true"] {
  border-color: var(--auth-red-700);
  background-image: none;
  padding-right: 12px;
}
.auth-card .form-control.is-invalid:focus,
.auth-card [aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.2);
}
.auth-card .form-text,
.auth-card .helptext {
  display: block;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--auth-slate-600);
}
.auth-card .form-text ul { margin: 4px 0 0; }
.auth-card .invalid-feedback,
.auth-card .field-error,
.auth-card ul.errorlist {
  display: block;
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--auth-red-700);
}
.auth-card ul.errorlist { list-style: none; padding: 0; }
.auth-card .form-check { display: flex; gap: 8px; align-items: flex-start; padding-left: 0; }
.auth-card .form-check-input { float: none; margin: 3px 0 0; width: 16px; height: 16px; }
.auth-card .form-check-input:checked { background-color: var(--auth-brand-800); border-color: var(--auth-brand-800); }
.auth-card fieldset legend { float: none; width: auto; font-size: 0.875rem; font-weight: 500; }
/* Django's RadioSelect puts the input's attrs on its wrapper too. */
.auth-card div.form-check-input {
  width: auto; height: auto; margin: 0; background: none; border: 0; border-radius: 0;
  appearance: none; -webkit-appearance: none;
}
.auth-card div.form-check-input > div { margin-bottom: 4px; }
.auth-card div.form-check-input input[type="radio"] { margin-right: 6px; }
/* Package forms rendered as_table / as_p (disable, backup tokens). */
.auth-card table { width: 100%; margin-bottom: 12px; }
.auth-card table th,
.auth-card table td { display: block; padding: 0; text-align: left; }
.auth-card table th { padding-bottom: 6px; }

/* ---- Buttons ---------------------------------------------------------- */
.auth-card .btn,
.auth-body .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: 6px;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.auth-body .btn:hover { text-decoration: none; }
.auth-body .btn-primary {
  background: var(--auth-brand-800);
  border-color: var(--auth-brand-800);
  color: #fff;
}
.auth-body .btn-primary:hover,
.auth-body .btn-primary:active {
  background: var(--auth-brand-900);
  border-color: var(--auth-brand-900);
  color: #fff;
}
.auth-body .btn-secondary,
.auth-body .btn-outline-secondary,
.auth-body .btn-info {
  background: #fff;
  border-color: var(--auth-slate-300);
  color: var(--auth-slate-700);
}
.auth-body .btn-secondary:hover,
.auth-body .btn-outline-secondary:hover,
.auth-body .btn-info:hover {
  background: var(--auth-slate-50);
  border-color: var(--auth-slate-300);
  color: var(--auth-slate-900);
}
.auth-body .btn-outline-primary {
  background: #fff;
  border-color: var(--auth-brand-200);
  color: var(--auth-brand-800);
}
.auth-body .btn-outline-primary:hover {
  background: var(--auth-brand-50);
  border-color: var(--auth-brand-700);
  color: var(--auth-brand-900);
}
.auth-body .btn-danger {
  background: var(--auth-red-700);
  border-color: var(--auth-red-700);
  color: #fff;
}
.auth-body .btn-danger:hover { background: var(--auth-red-800); border-color: var(--auth-red-800); }
.auth-body .btn-success {
  background: var(--auth-sun-500);
  border-color: var(--auth-sun-500);
  color: var(--auth-brand-950);
}
.auth-body .btn-link {
  background: none;
  border-color: transparent;
  color: var(--auth-brand-700);
  font-weight: 500;
}
.auth-body .btn-link:hover { text-decoration: underline; color: var(--auth-brand-900); }
.auth-body .btn-block,
.auth-body .w-100 { width: 100%; }
.auth-body .btn-sm { min-height: 32px; padding: 4px 12px; }
.auth-body .float-right { float: none !important; }
.auth-body .btn:disabled { opacity: 0.6; }
.auth-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}
.auth-stack { display: grid; gap: 8px; margin-top: 16px; }
@media (max-width: 575.98px) {
  .auth-actions { flex-direction: column-reverse; align-items: stretch; }
  .auth-actions .btn { width: 100%; }
}

/* ---- Alerts and messages ---------------------------------------------- */
.auth-body .alert {
  border-radius: 6px;
  border: 1px solid;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 0.875rem;
}
.auth-body .alert-danger,
.auth-body .alert-error { background: var(--auth-red-50); border-color: var(--auth-red-200); color: var(--auth-red-800); }
.auth-body .alert-success { background: var(--auth-green-50); border-color: var(--auth-green-200); color: var(--auth-green-800); }
.auth-body .alert-warning { background: var(--auth-amber-50); border-color: var(--auth-amber-200); color: var(--auth-amber-800); }
.auth-body .alert-info { background: var(--auth-brand-50); border-color: var(--auth-brand-200); color: var(--auth-brand-900); }
.auth-body .alert .btn-close { padding: 12px; }

/* ---- Pieces of particular pages ---------------------------------------- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--auth-slate-500);
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--auth-slate-200); }
.auth-card img[alt="QR Code"] {
  display: block;
  margin: 8px auto 12px;
  max-width: 100%;
  padding: 8px;
  border: 1px solid var(--auth-slate-200);
  border-radius: 8px;
}
.auth-tokens {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0 !important;
  margin: 12px 0 16px;
}
.auth-tokens li {
  padding: 8px 10px;
  border: 1px dashed var(--auth-slate-300);
  border-radius: 6px;
  background: var(--auth-slate-50);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9375rem;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--auth-slate-900);
}
.auth-status {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.auth-status-on { background: var(--auth-green-50); color: var(--auth-green-800); }
.auth-status-off { background: var(--auth-amber-50); color: var(--auth-amber-800); }
