/* =====================================================================
   Pre-sign-in pages (base_auth.html) — sign in, register, forgot
   password, magic links, invitations, 2FA, new-browser and session
   checks, SSO and provider errors.

   Layout: two clear halves at ≥1024px — a dark ink brand panel on the
   LEFT (why Lexlegis) and the light form column on the RIGHT (top bar ·
   card · footer). Below 1024px only the form shows. Form colours are
   tokens from app.css so they follow light/dark; the panel is always dark.
   ===================================================================== */

.auth-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--surface);
  color: var(--text);
}
@media (min-width: 1024px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---------- form column ---------- */
.auth-main {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-width: 0;
  padding: 18px 16px 20px;
}
@media (min-width: 640px) { .auth-main { padding: 28px 40px 24px; } }

.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
}
.auth-top__brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.auth-top__brand .auth-card__logo { height: 26px; }
.auth-top__tag {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  color: var(--on-brand-container);
  background: var(--brand-container);
  line-height: 1.2;
}
.auth-top__link {
  font-size: .875rem;
  color: var(--text-muted);
  text-align: right;
}
.auth-top__link a {
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
  white-space: nowrap;
  margin-left: 4px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  transition: background .14s, border-color .14s;
}
.auth-top__link a:hover { background: var(--brand-50); border-color: var(--brand-100); }
@media (max-width: 479px) { .auth-top__hint { display: none; } }

.auth-body {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 0 48px;
}
@media (min-width: 640px) { .auth-body { padding: 56px 0; } }

/* The card is a column, not a box — the page is the surface. */
.auth-card { width: 100%; max-width: 420px; }
.auth-card--wide { max-width: 460px; }

.auth-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  font-size: .8rem;
  color: var(--text-subtle);
}
.auth-foot nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.auth-foot a { color: var(--text-muted); text-decoration: none; }
.auth-foot a:hover { color: var(--text); text-decoration: underline; }
.auth-foot__v1 { font-weight: 600; }

/* ---------- card typography ---------- */
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -6px 0 22px -10px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-pill);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}
.auth-back:hover { color: var(--text); background: var(--state-hover); }

.auth-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--brand);
}

.auth-card h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.75rem, 1.35rem + 1.4vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -.015em;
  margin: 0 0 .5rem;
}
.auth-lead {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.55;
  margin: 0 0 1.75rem;
}
.auth-lead strong, .auth-text strong { color: var(--text); font-weight: 600; }
.auth-text { color: var(--text-muted); font-size: .92rem; line-height: 1.55; margin: 0 0 1.25rem; }
.auth-legal { color: var(--text-subtle); font-size: .78rem; line-height: 1.5; margin: 1.5rem 0 0; }
.auth-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- status tile (sent / expired / blocked / error) ---------- */
.auth-badge {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 20px;
  border-radius: var(--radius-lg);
  font-size: 1.55rem;
  line-height: 1;
  color: var(--brand);
  background: var(--brand-50);
}
.auth-badge--ok   { color: var(--ok);   background: var(--ok-50); }
.auth-badge--warn { color: var(--warn); background: var(--warn-50); }
.auth-badge--err  { color: var(--err);  background: var(--err-50); }
.auth-badge--neutral { color: var(--text-muted); background: var(--bg-tint); }

/* ---------- form controls ---------- */
.auth-card .form-label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.auth-label-row a { font-size: .82rem; font-weight: 600; text-decoration: none; }
.auth-label-row a:hover { text-decoration: underline; }

.auth-card .form-control,
.auth-card .form-select {
  min-height: 48px;
  padding-left: 14px;
  border-radius: var(--radius);
  border-color: var(--border-strong);
  background-color: var(--surface);
  color: var(--text);
  font-size: .97rem;
  transition: border-color .14s, box-shadow .14s;
}
.auth-card .form-control::placeholder { color: var(--text-faint); }
.auth-card .form-control:hover:not(:focus):not(:disabled),
.auth-card .form-select:hover:not(:focus) { border-color: var(--text-subtle); }
.auth-card .form-control:focus,
.auth-card .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
.auth-card .form-control:disabled,
.auth-card .form-control[readonly][disabled] {
  background: var(--bg-tint);
  color: var(--text-muted);
}
.auth-card .input-group > .form-control { border-radius: 0 var(--radius) var(--radius) 0; }
.auth-card .input-group > .input-group-text {
  min-height: 48px;
  border-radius: var(--radius) 0 0 var(--radius);
  border-color: var(--border-strong);
  background: var(--bg-tint);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.auth-card .form-check-input { width: 1.1em; height: 1.1em; margin-top: .2em; }
.auth-card .form-check-label { color: var(--text-muted); font-size: .9rem; }
.auth-card .text-danger { color: var(--err) !important; }
.auth-card .alert { border-radius: var(--radius); font-size: .9rem; }
.auth-card .alert ul { margin: 0; padding-left: 1rem; }

/* Field-level error message (server + client) */
.auth-card .text-danger.small {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-top: 6px !important;
  font-size: .82rem;
}

/* Buttons: pill, tall, one primary per screen. */
.auth-card .btn {
  min-height: 48px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: .95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.auth-card .btn-sm,
.auth-card .btn-link { min-height: 0; font-weight: 500; }
.auth-card .btn-outline-secondary {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface);
}
.auth-card .btn-outline-secondary:hover {
  color: var(--text);
  background: var(--state-hover);
  border-color: var(--text-subtle);
}
.auth-card .sso-btn { border-radius: var(--radius-pill); min-height: 48px; }
.auth-card .sso-btn--quiet { box-shadow: none; }
.auth-card .sso-btn .bi { font-size: 1.05rem; color: var(--text-muted); }

.auth-actions { display: grid; gap: 10px; }
.auth-actions--2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 380px) { .auth-actions--2 { grid-template-columns: 1fr; } }

/* Centered row of quiet secondary links under the main action. */
.auth-alt {
  margin: 1.5rem 0 0;
  text-align: center;
  font-size: .9rem;
  color: var(--text-muted);
}
.auth-alt a { font-weight: 600; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }
.auth-alt .last-used-pill { margin-left: 6px; vertical-align: middle; }

/* ---------- password field (eye toggle + caps-lock hint) ---------- */
.pw-input { position: relative; }
.pw-input > input.form-control { padding-right: 3rem; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.pw-toggle:hover { color: var(--text); background: var(--state-hover); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.pw-toggle__eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .pw-toggle__eye { display: none; }
.pw-toggle[aria-pressed="true"] .pw-toggle__eye-off { display: inline-block; }

.auth-capslock {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--warn);
}
.auth-capslock[hidden] { display: none; }

/* ---------- info note / numbered steps ---------- */
.auth-note {
  margin: 1.5rem 0 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-soft);
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.auth-note__title { font-weight: 600; color: var(--text); margin-bottom: 6px; }
.auth-note ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.auth-note li { display: flex; gap: 8px; align-items: flex-start; }
.auth-note li .bi { color: var(--text-subtle); margin-top: 1px; flex: 0 0 auto; }
.auth-note--plain { background: transparent; }

.auth-steps {
  list-style: none;
  counter-reset: auth-step;
  margin: 0 0 1.5rem;
  padding: 0;
  display: grid;
  gap: 12px;
}
.auth-steps li {
  counter-increment: auth-step;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
  font-size: .92rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.auth-steps li::before {
  content: counter(auth-step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: .8rem;
  font-weight: 600;
  color: var(--on-brand-container);
  background: var(--brand-container);
}
.auth-steps li strong { color: var(--text); font-weight: 600; display: block; }

/* ---------- device / session card ---------- */
.auth-device {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  margin: 0 0 1.5rem;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.auth-device__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-tint);
  color: var(--text-muted);
  font-size: 1.15rem;
}
.auth-device__label { font-size: .75rem; color: var(--text-subtle); margin-bottom: 2px; }
.auth-device__name  { font-weight: 600; font-size: .93rem; }
.auth-device__meta  { font-size: .8rem; color: var(--text-subtle); font-family: var(--font-mono); }
.auth-device__aside { text-align: right; font-size: .8rem; color: var(--text-subtle); }
.auth-device details { grid-column: 1 / -1; }
.auth-device summary { font-size: .78rem; color: var(--text-subtle); cursor: pointer; }
.auth-device__ua { font-family: var(--font-mono); font-size: .75rem; color: var(--text-subtle); word-break: break-all; margin-top: 6px; }

/* Email address chip ("Signed in as …", "Sent to …"). */
.auth-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 1.5rem;
}
.auth-chip__avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-container);
  color: var(--on-brand-container);
  font-size: .8rem;
  flex: 0 0 auto;
}
.auth-chip__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Small v1 callout (signup). */
.auth-callout {
  display: flex;
  gap: 10px;
  margin-top: 1.5rem;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.auth-callout .bi { color: var(--text-subtle); margin-top: 1px; }
.auth-callout a { font-weight: 600; text-decoration: none; white-space: nowrap; }

/* OTP code input inside the auth shell. */
.auth-card .otp-input {
  font-size: 1.35rem;
  letter-spacing: .45em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* ---------- brand panel ---------- */
.auth-aside { display: none; }
@media (min-width: 1024px) {
  /* Panel is second in the markup (form first for screen readers and
     mobile) but sits on the left. */
  .auth-aside { display: block; order: -1; }
}
.auth-panel {
  position: sticky;
  top: 0;
  height: 100dvh;
  min-height: 640px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: clamp(36px, 4.5vw, 72px);
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  background:
    radial-gradient(720px 480px at 0% 0%, rgba(43,74,203,.34), transparent 62%),
    radial-gradient(640px 520px at 100% 100%, rgba(43,74,203,.22), transparent 60%),
    #0e1120;
}
/* Faint ruled-paper texture — a nod to the legal pad, kept very quiet. */
.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: repeating-linear-gradient(180deg, transparent 0 31px, rgba(255,255,255,.025) 31px 32px);
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.auth-panel__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.16);
  font-size: .78rem;
  font-weight: 600;
  color: #dce4fb;
}
.auth-panel__eyebrow i { font-size: .9rem; }
.auth-panel h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.3rem, 1.2rem + 2.3vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -.02em;
  margin: 20px 0 16px;
  max-width: 15ch;
  color: #fff;
}
/* Two-tone headline, as on lexlegis.ai: second line in cobalt (lifted
   so it reads on the dark panel). */
.auth-panel__accent { color: #8fa3f7; }
.auth-panel__lead { color: rgba(231,235,250,.74); font-size: 1.05rem; line-height: 1.55; max-width: 44ch; margin: 0; }

/* Capability list (default panel): numbered, hairline-ruled, no
   ornament — reads like a contents page, not a sales card. */
.auth-panel__features {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 52ch;
  border-top: 1px solid rgba(255,255,255,.12);
}
.auth-panel__features li {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.auth-panel__num {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: #8fa3f7;
  padding-top: 3px;
}
.auth-panel__features strong { display: block; color: #fff; font-weight: 600; font-size: .98rem; margin-bottom: 2px; }
.auth-panel__features span:not(.auth-panel__num) { color: rgba(231,235,250,.70); font-size: .88rem; line-height: 1.5; }

.auth-panel__surfaces { display: flex; flex-wrap: wrap; gap: 8px; }
.auth-panel__surface {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .8rem;
  color: #e7ebfa;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
}

/* Benefit / reassurance list on the panel. */
.auth-panel__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; max-width: 46ch; }
.auth-panel__list li { display: grid; grid-template-columns: 40px 1fr; gap: 14px; align-items: start; }
.auth-panel__list .bi {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  font-size: 1.1rem;
  color: #dce4fb;
}
.auth-panel__list strong { display: block; color: #fff; font-weight: 600; font-size: .98rem; margin-bottom: 2px; }
.auth-panel__list span { color: rgba(231,235,250,.72); font-size: .88rem; line-height: 1.5; }

.auth-panel__foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: .8rem;
  color: rgba(231,235,250,.65);
}
.auth-panel__foot a { color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap; }
.auth-panel__foot a:hover { text-decoration: underline; }

/* Short screens: tighten the list before anything overflows. */
@media (min-width: 1024px) and (max-height: 800px) {
  .auth-panel__features li { padding: 10px 0; }
  .auth-panel__features span:not(.auth-panel__num) { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .auth-card { animation: auth-in .32s cubic-bezier(.2,.7,.2,1) both; }
  @keyframes auth-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
