/* ========================================================================
   DNSai Auth Pages — Login, Register, Forgot Password, Reset Password
   Standalone pages (not inside base.html nav shell).
   Uses CSS vars from theme.css.
   ======================================================================== */

/* --- Page Layout ---
   Standalone form (no shared nav/footer): the block owns the viewport.
   `box-sizing: border-box` matters — there is no global border-box reset, so
   without it `min-height: 100vh` + padding made the page taller than the
   viewport and forced a scrollbar.

   Padding is deliberately asymmetric (32 top / 56 bottom). Geometrically
   centred content reads as sitting too low; biasing it ~12px upward is the
   standard optical correction. */
.auth-page {
  box-sizing: border-box;
  min-height: 100vh; /* fallback for browsers without dvh */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 56px;
  font-family: 'Inter', 'Open Sans', 'Roboto', sans-serif;
}

/* --- Shared-shell variant ---
   Set `class="... auth-body"` on <body> when the page includes public_nav.html
   + public_footer.html. The body then owns the full height and .auth-page
   simply fills the space left between the (in-flow, sticky) nav and the
   footer — so the card centres honestly, with no padding-top compensation.

   Higher specificity than the .auth-page rules in the media queries below,
   so the min-height override holds at every width regardless of source order. */
body.auth-body {
  box-sizing: border-box;
  min-height: 100vh; /* fallback */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body.auth-body .auth-page {
  flex: 1 0 auto;
  min-height: 0;
}

/* The nav and footer are fixed-size bookends; only .auth-page absorbs slack.
   Without this, a tall form could squeeze the 64px nav in the column flex. */
body.auth-body > .landing-nav,
body.auth-body > .landing-footer {
  flex: 0 0 auto;
}

/* --- Brand Header --- */
.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand img {
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 30px var(--glow-primary)) drop-shadow(0 0 12px var(--glow-secondary));
}

.auth-brand h1 {
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 1px;
  margin: 0 0 4px;
}

.auth-brand h1 .bold { font-weight: 700; }
.auth-brand h1 .thin { font-weight: 300; }

.auth-brand p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* --- Card --- */
.auth-card {
  /* Without this, `width:100%` + 32px side padding + 1px border made the card
     385px wide inside a 375px phone viewport, giving every auth page a
     horizontal scrollbar. There is no global border-box reset. */
  box-sizing: border-box;
  width: 100%;
  max-width: 420px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: var(--card-shadow);
}

.auth-card h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 24px;
  text-align: center;
}

/* --- Form --- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-form input {
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  box-sizing: border-box;
}

.auth-form input:focus {
  border-color: var(--border-input-focus);
  box-shadow: var(--input-focus-shadow);
  outline: none;
}

.auth-form input.input-error {
  border-color: var(--color-error);
}

.auth-form .form-hint {
  font-size: 12px;
  color: var(--text-dimmed);
}

/* --- Password strength bar --- */
.password-strength {
  height: 4px;
  border-radius: 2px;
  background-color: var(--border-default);
  overflow: hidden;
  margin-top: 4px;
}

.password-strength-fill {
  height: 100%;
  border-radius: 2px;
  width: 0;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.password-strength-fill.weak { width: 25%; background-color: var(--color-error); }
.password-strength-fill.fair { width: 50%; background-color: var(--color-warning); }
.password-strength-fill.good { width: 75%; background-color: var(--color-info); }
.password-strength-fill.strong { width: 100%; background-color: var(--color-success); }

.password-strength-text {
  font-size: 11px;
  margin-top: 4px;
  color: var(--text-dimmed);
}

.password-strength-text.weak { color: var(--color-error); }
.password-strength-text.fair { color: var(--color-warning); }
.password-strength-text.good { color: var(--color-info); }
.password-strength-text.strong { color: var(--color-success); }

/* --- Password requirements checklist --- */
.password-reqs {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.password-reqs li {
  font-size: 11px;
  color: var(--text-dimmed);
  padding-left: 18px;
  position: relative;
}

.password-reqs li::before {
  content: "\2717";
  position: absolute;
  left: 0;
  color: var(--text-dimmed);
  font-size: 11px;
}

.password-reqs li.met {
  color: var(--color-success);
}

.password-reqs li.met::before {
  content: "\2713";
  color: var(--color-success);
}

/* --- Buttons --- */
.auth-btn {
  width: 100%;
  padding: 13px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: box-shadow 0.3s ease, background 0.3s ease;
  color: #ffffff;
  background: var(--brand-gradient);
  margin-top: 4px;
}

.auth-btn:hover {
  background: var(--brand-gradient-hover);
  box-shadow: var(--btn-hover-shadow);
}

.auth-btn:disabled {
  background: var(--color-disabled-bg);
  color: var(--color-disabled-text);
  cursor: not-allowed;
  box-shadow: none;
}

.auth-btn.auth-btn-secondary {
  background: var(--btn-secondary-gradient);
}

.auth-btn.auth-btn-secondary:hover {
  opacity: 0.9;
}

/* --- Links row --- */
.auth-links {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-links a {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.auth-links a:hover {
  text-decoration: underline;
}

.auth-links .divider {
  margin: 0 8px;
  color: var(--border-default);
}

/* --- Error / Success Messages --- */
.auth-message {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
  text-align: center;
  margin-bottom: 8px;
}

.auth-message.error {
  display: block;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

.auth-message.success {
  display: block;
  background: rgba(0, 200, 83, 0.1);
  border: 1px solid rgba(0, 200, 83, 0.3);
  color: var(--color-success);
}

.auth-message.info {
  display: block;
  background: rgba(64, 168, 255, 0.1);
  border: 1px solid rgba(64, 168, 255, 0.3);
  color: var(--color-info);
}

/* --- OAuth2 Consent Screen --- */
.oauth-app-name {
  font-size: 15px;
  text-align: center;
  margin: 0 0 18px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.oauth-scopes {
  margin: 0 0 18px;
  padding: 14px 18px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: 8px;
}

.oauth-scopes p {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.oauth-scopes ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.oauth-scopes li {
  font-size: 13px;
  color: var(--text-primary);
  padding: 6px 0;
  border-bottom: 1px solid var(--border-default);
}

.oauth-scopes li:last-child {
  border-bottom: none;
}

.oauth-scopes li::before {
  content: "\2713  ";
  color: var(--color-success);
  font-weight: 700;
}

.oauth-user-info {
  font-size: 13px;
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 18px;
}

.oauth-buttons {
  display: flex;
  gap: 12px;
}

.oauth-buttons .auth-btn {
  flex: 1;
}

.oauth-buttons .auth-btn-secondary {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
}

.oauth-buttons .auth-btn-secondary:hover {
  background: var(--bg-hover);
  opacity: 1;
}

/* --- 2FA Section --- */
.twofa-section {
  display: none;
  text-align: center;
}

.twofa-section p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 18px;
}

.twofa-section .form-group {
  max-width: 220px;
  margin: 0 auto;
}

.twofa-section input {
  text-align: center;
  font-size: 20px;
  letter-spacing: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* --- Spinner for loading state --- */
.auth-btn .btn-spinner {
  display: none;
}

.auth-btn.loading .btn-text {
  display: none;
}

.auth-btn.loading .btn-spinner {
  display: inline;
}

/* --- Mode toggle (small, in corner) --- */
.auth-mode-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
}

/* --- Footer --- */
.auth-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-placeholder);
  line-height: 1.8;
}

.auth-footer-links {
  margin-top: 6px;
}

.auth-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.auth-footer-links a:hover {
  color: var(--link-color);
  text-decoration: underline;
}

.auth-footer-links .divider {
  margin: 0 8px;
  color: var(--border-default);
}

/* --- Success State (full card replacement) --- */
/* --- Registration Success Modal --- */
.reg-success-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11000;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}

.reg-success-overlay.visible {
  display: flex;
}

.reg-success-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.reg-success-icon {
  font-size: 48px;
  margin-bottom: 12px;
  line-height: 1;
}

.reg-success-modal h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px;
}

.reg-success-modal p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 8px;
}

.reg-success-detail {
  font-size: 13px !important;
  color: var(--text-muted) !important;
  margin-bottom: 24px !important;
}

.reg-success-actions {
  margin-bottom: 20px;
}

.reg-success-actions .dnsai-modal-btn-primary {
  display: inline-block;
  padding: 11px 36px;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.reg-success-resend {
  font-size: 13px;
  color: var(--text-muted);
}

.reg-resend-btn {
  background: none;
  border: none;
  color: var(--link, var(--brand-cyan));
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.reg-resend-btn:hover {
  opacity: 0.8;
}

.reg-resend-btn:disabled {
  opacity: 0.5;
  cursor: default;
  text-decoration: none;
}

/* --- Responsive --- */
@media (max-width: 767px) {
  /* flex-start, not center: the register form is tall enough to overflow a
     phone viewport, and centring would clip its top. */
  .auth-page {
    padding: 24px 16px 32px;
    justify-content: flex-start;
    min-height: calc(100vh - env(safe-area-inset-bottom, 0px));
    min-height: -webkit-fill-available;
    min-height: 100dvh;
  }

  .auth-brand {
    margin-bottom: 20px;
  }

  .auth-brand img {
    width: 44px;
    height: 44px;
    margin-bottom: 8px;
  }

  .auth-brand h1 {
    font-size: 24px;
  }

  .auth-brand p {
    font-size: 13px;
  }

  .auth-card {
    padding: 24px 20px;
    border-radius: 12px;
    max-width: 100%;
  }

  .auth-card h2 {
    font-size: 18px;
    margin-bottom: 18px;
  }

  .auth-form {
    gap: 14px;
  }

  /* 16px prevents iOS Safari auto-zoom on focus */
  .auth-form input {
    font-size: 16px;
    padding: 12px 14px;
    border-radius: 8px;
  }

  .auth-form label {
    font-size: 13px;
  }

  .auth-btn {
    font-size: 16px;
    padding: 14px 20px;
    border-radius: 8px;
    margin-top: 6px;
  }

  .twofa-section input {
    font-size: 22px;
  }

  .auth-links {
    margin-top: 16px;
    font-size: 14px;
  }

  .auth-footer {
    margin-top: 20px;
    font-size: 11px;
  }

  .auth-footer-links {
    margin-top: 4px;
  }

  .auth-message {
    font-size: 14px;
  }

  .reg-success-modal {
    padding: 28px 20px 24px;
  }
}

.auth-success {
  /* Revealed by forgot_password.js / reset_password.js, which set
     display:block once the request succeeds. Without this default the success
     panel rendered alongside the form on page load. */
  display: none;
  text-align: center;
  padding: 12px 4px 4px;
}

.auth-success .success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 4px auto 20px;
  border-radius: 50%;
  color: var(--color-info);
  background-color: color-mix(in srgb, currentColor 14%, transparent);
  font-size: 38px;
  line-height: 1;
}

.auth-success h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px;
}

.auth-success p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 24px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 380px) {
  .auth-page {
    padding: 16px 12px 24px;
  }

  .auth-card {
    padding: 20px 16px;
  }

  .auth-brand h1 {
    font-size: 22px;
  }

  .auth-brand img {
    width: 40px;
    height: 40px;
  }

  .auth-success .success-icon {
    width: 64px;
    height: 64px;
    font-size: 32px;
  }
}
