/*
 * Auth pages (Prompt 03): log in, sign up, password, verify email, 2FA, Google sign-up.
 * Prefix au-. Tokens only. Also restyles the legacy inner classes (auth-*, form-group)
 * inside .au-main so pages that were not rebuilt still match.
 */

body.au-body { background: var(--bg); color: var(--text); }
.au-body a:hover { text-decoration: none; }
[hidden] { display: none !important; }

.au {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

/* Brand panel */
.au-side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  padding: 40px 56px;
  background: var(--surface-1);
  border-right: 1px solid var(--line);
}
.au-side__copy { display: flex; flex-direction: column; gap: 36px; max-width: 440px; }
.au-side__headline {
  margin: 0;
  font-size: clamp(2rem, 1.2rem + 1.4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--text);
  text-wrap: balance;
}
.au-side__list { display: flex; flex-direction: column; gap: 22px; margin: 0; padding: 0; list-style: none; }
.au-side__list li { display: flex; gap: 14px; align-items: flex-start; }
.au-side__list strong { display: block; font-size: 1rem; font-weight: 600; color: var(--text); }
.au-side__list li > span > span { display: block; font-size: 0.9375rem; line-height: 1.5; color: var(--text-2); }
.au-side__copyright { margin: 0; font-size: 0.8125rem; color: var(--text-3); }

/* Form column */
.au-main { display: flex; flex-direction: column; min-width: 0; }
.au-main__top { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 20px 32px 0; }
.au-main__logo { display: none; margin-right: auto; }
.au-main__body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 32px 56px; }
.au-form-wrap { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 20px; }
.au-form-wrap.is-wide { max-width: 440px; }

.au-main .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.au-main .theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.au-main .theme-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }

@media (max-width: 899.98px) {
  .au { grid-template-columns: minmax(0, 1fr); }
  .au-side { display: none; }
  .au-main__logo { display: inline-flex; }
  .au-main__top { padding: 16px 20px 0; }
  .au-main__body { align-items: flex-start; padding: 28px 20px 48px; }
}

/* Headings */
.au-head { display: flex; flex-direction: column; gap: 8px; }
.au-title { margin: 0; font-size: 2rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; color: var(--text); }
.au-sub { margin: 0; font-size: 1rem; line-height: 1.5; color: var(--text-2); }
.au-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
}
.au-back:hover { color: var(--text); }
.au-back:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-control-sm); }

.au-form { display: flex; flex-direction: column; gap: 18px; margin: 0; }
.au-field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.au-link { font-size: 0.875rem; font-weight: 600; color: var(--brand-text); }
.au-link:hover { color: var(--brand-text-hover); }
.au-link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-control-sm); }

.au-check { display: flex; align-items: center; gap: 10px; font-size: 0.9375rem; color: var(--text-2); cursor: pointer; }
.au-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }

.au-form .ui-btn { width: 100%; }
.au-form .ui-btn--lg,
.au-form-wrap > .ui-btn { width: 100%; }

.au-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--text-3);
}
.au-divider::before,
.au-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.au-google { width: 100%; }
.au-google svg { width: 18px; height: 18px; }
.au-google .g-blue { fill: #4285F4; }
.au-google .g-green { fill: #34A853; }
.au-google .g-yellow { fill: #FBBC05; }
.au-google .g-red { fill: #EA4335; }

.au-foot { margin: 4px 0 0; text-align: center; font-size: 0.9375rem; line-height: 1.6; color: var(--text-2); }
.au-foot a { display: inline-block; font-weight: 700; color: var(--brand-text); }
.au-foot a:hover { color: var(--brand-text-hover); }
.au-help { margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--text-3); text-align: center; }
.au-legal { margin: 0; font-size: 0.875rem; line-height: 1.55; color: var(--text-2); }
.au-legal a { color: var(--brand-text); font-weight: 600; }

/* Alerts */
.au-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  border: 1px solid;
  font-size: 0.875rem;
  line-height: 1.5;
}
.au-alert p,
.au-alert ul { margin: 0; }
.au-alert ul { padding-left: 1.1rem; }
.au-alert--error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-text); }
.au-alert--ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }

/* Passkey status (set by passkeys.js) */
.au-passkey-status { margin: 8px 0 0; font-size: 0.875rem; text-align: center; color: var(--text-2); }
.au-passkey-status.auth-error { color: var(--danger-text); background: none; border: 0; padding: 0; }

/* Wizard progress: auth-register-wizard.js toggles .is-active / .is-current on each item */
.au-steps { position: relative; padding-bottom: 28px; }
.au-steps__bars { display: grid; grid-template-columns: repeat(var(--au-steps, 3), minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.au-steps__bar { display: block; height: 4px; border-radius: var(--radius-pill); background: var(--surface-3); transition: background-color 0.2s ease; }
.au-steps__bars li.is-active .au-steps__bar { background: var(--brand); }
.au-steps__label {
  display: none;
  position: absolute;
  left: 0;
  bottom: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.au-steps__bars li.is-current .au-steps__label { display: block; }

/* Role chips (radio buttons styled as chips) */
.au-roles { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.au-roles__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.au-role { position: relative; display: flex; }
.au-role input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.au-role span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface-1);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  color: var(--text-2);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.au-role:hover span { background: var(--surface-2); color: var(--text); }
.au-role input:checked + span { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-text); font-weight: 600; }
.au-role input:focus-visible + span { box-shadow: var(--focus-ring); }
@media (max-width: 619.98px) {
  .au-roles__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.au-actions { display: flex; gap: 10px; }
.au-actions .ui-btn { flex: 1; width: auto; }

/* reCAPTCHA: badge hidden (Google allows this when the attribution text is shown) */
.has-recaptcha .grecaptcha-badge { visibility: hidden; }
.au-recaptcha { margin: 8px 0 0; font-size: 0.75rem; line-height: 1.5; text-align: center; color: var(--text-3); }
.au-recaptcha a { color: var(--text-2); text-decoration: underline; }

/* ===== Legacy inner classes, for auth pages not rebuilt (verify email, 2FA, Google sign-up) ===== */
.au-main .auth-subtitle { margin: 0; font-size: 1rem; line-height: 1.5; color: var(--text-2); }
.au-main .auth-help { margin: 0; font-size: 0.875rem; color: var(--text-3); }
.au-main .auth-error {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-control);
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 0.875rem;
}
.au-main .auth-status {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--ok-line);
  border-radius: var(--radius-control);
  background: var(--ok-bg);
  color: var(--ok-text);
  font-size: 0.875rem;
}
.au-main .auth-form { display: flex; flex-direction: column; gap: 18px; margin: 0; }
.au-main .form-group { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.au-main .form-group > label,
.au-main .password-input label,
.au-main .phone-input label { font-size: 0.875rem; font-weight: 600; color: var(--text); margin: 0; }
.au-main .auth-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.au-main .auth-form select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface-1);
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  box-shadow: none;
}
.au-main .auth-form input[readonly] { background: var(--surface-2); color: var(--text-2); }
.au-main .auth-form input:not([type="checkbox"]):not([type="radio"]):focus,
.au-main .auth-form select:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
.au-main .phone-input .iti { width: 100%; }
.au-main .phone-input .iti input { padding-left: 52px; }
.au-main .iti__country-list { background: var(--surface-1); color: var(--text); border-color: var(--line); }
.au-main .iti__country.iti__highlight { background: var(--surface-2); }
.au-main .iti__dial-code { color: var(--text-3); }
.au-main .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.au-main .btn-primary { background: var(--brand); color: var(--on-brand); }
.au-main .btn-primary:hover { background: var(--brand-hover); }
.au-main .btn-secondary,
.au-main .btn-outline { background: transparent; border-color: var(--line-strong); color: var(--text); }
.au-main .btn-secondary:hover,
.au-main .btn-outline:hover { background: var(--surface-2); }
.au-main .btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.au-main .auth-wizard-actions { display: flex; gap: 10px; }
.au-main .auth-wizard-actions .btn { flex: 1; }
.au-main .auth-actions,
.au-main .auth-footer { margin: 0; text-align: center; font-size: 0.9375rem; color: var(--text-2); }
.au-main .auth-actions a,
.au-main .auth-footer a { font-weight: 700; color: var(--brand-text); }
.au-main .auth-form--secondary { margin-top: -8px; }

/* Role picker: dropdown once JS wires select to radios; chip grid stays for no-JS fallback */
.au-roles__select { display: none; }
.au-roles.is-enhanced .au-roles__grid { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.au-roles.is-enhanced .au-roles__select { display: flex; }
.au-roles { position: relative; }
