/* Auth pages — login, signup, forgot password (City Of the Great King) */

.auth-page {
  margin: 0;
  min-height: 100vh;
  font-family: var(--theme-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 16px;
  line-height: 1.55;
  color: var(--theme-text, #1b2a1e);
  background: var(--theme-bg-subtle, #f4fbf5);
  background-image:
    radial-gradient(ellipse 120% 80% at 0% 0%, rgba(46, 125, 50, 0.09), transparent 52%),
    radial-gradient(ellipse 100% 60% at 100% 100%, rgba(46, 125, 50, 0.06), transparent 48%);
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--theme-border-subtle, #e0ebe1);
  position: sticky;
  top: 0;
  z-index: 10;
}

.auth-topbar--centered {
  justify-content: center;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 1.28rem;
  line-height: 1.2;
  color: var(--theme-primary, #2e7d32);
  text-decoration: none;
  letter-spacing: -0.02em;
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
}

.auth-brand .site-brand-logo {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 50%;
}

.auth-brand:hover {
  color: var(--theme-primary-hover, #1b5e20);
}

.auth-topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-toplink {
  font-size: 0.9rem;
  font-weight: 500;
  color: #424242;
  text-decoration: none;
}

.auth-toplink:hover {
  color: var(--theme-primary, #2e7d32);
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.07),
    0 24px 48px -12px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 2rem 2rem 1.75rem;
}

.auth-card--wide {
  max-width: 520px;
}

.auth-card-header {
  margin-bottom: 1.5rem;
}

.auth-title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--theme-text, #1b2a1e);
}

.auth-subtitle {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--theme-text-muted, #546e56);
}

.auth-alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.45;
}

.auth-alert--error {
  background: #ffebee;
  color: #b71c1c;
  border: 1px solid #ffcdd2;
}

.auth-alert--success {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #c8e6c9;
}

.auth-alert--warning {
  background: #fff8e1;
  color: #e65100;
  border: 1px solid #ffe082;
}

.auth-alert--info {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #90caf9;
}

.auth-form-group {
  margin-bottom: 1.125rem;
  min-width: 0;
}

.auth-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #37474f;
  margin-bottom: 0.375rem;
}

.auth-input {
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  display: block;
  padding: 0.65rem 0.875rem;
  font-size: 1rem;
  border: 1px solid #cfd8dc;
  border-radius: 10px;
  background: #fafafa;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.auth-input:hover {
  border-color: #b0bec5;
  background: #fff;
}

.auth-input:focus {
  outline: none;
  border-color: var(--theme-primary, #2e7d32);
  background: #fff;
  box-shadow: 0 0 0 3px var(--theme-nav-hover, rgba(46, 125, 50, 0.15));
}

.auth-input::placeholder {
  color: #9e9e9e;
}

/* Keep auth inputs inside card bounds even with inherited/global rules. */
.auth-card form .auth-input {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.auth-input--otp {
  text-align: center;
  font-size: 1.35rem;
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
  padding-left: 1rem;
  padding-right: 1rem;
}

.auth-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.auth-row .auth-form-group {
  flex: 1;
  min-width: 130px;
  margin-bottom: 0;
}

/* Signup name fields: first/middle/last/suffix in a balanced 2x2 layout. */
.auth-row--quad {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.auth-row--quad .auth-form-group {
  min-width: 0;
}

.auth-row-wrap {
  margin-bottom: 1.125rem;
}

@media (max-width: 620px) {
  .auth-row--quad {
    grid-template-columns: 1fr;
  }
}

.auth-hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: #757575;
  line-height: 1.4;
}

.auth-btn-primary {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, var(--theme-primary-light, #43a047) 0%, var(--theme-primary, #2e7d32) 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--theme-shadow, 0 2px 4px rgba(27, 94, 32, 0.2));
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.auth-btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.35);
}

.auth-btn-primary:active {
  transform: translateY(1px);
}

a.auth-btn-primary {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 8rem;
  box-sizing: border-box;
}

.auth-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #eceff1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.auth-footer--center {
  justify-content: center;
  text-align: center;
}

.auth-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--theme-primary, #2e7d32);
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-link-muted {
  color: #757575;
}

.auth-link-muted:hover {
  color: #424242;
}

.auth-link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--theme-primary, #2e7d32);
  cursor: pointer;
  text-decoration: underline;
}

.auth-link-btn:hover {
  color: var(--theme-primary-hover, #1b5e20);
}

/* Override global button hover so resend link stays readable. */
.auth-page .auth-link-btn,
.auth-page .auth-link-btn:hover,
.auth-page .auth-link-btn:focus,
.auth-page .auth-link-btn:active {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.auth-page .auth-link-btn:hover,
.auth-page .auth-link-btn:focus {
  text-decoration: underline;
}

.auth-link-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-email-banner {
  padding: 1rem 1.125rem;
  background: linear-gradient(135deg, var(--theme-bg-wash, #e8f5e9) 0%, #f1f8f4 100%);
  border-radius: 10px;
  border: 1px solid var(--theme-border, #c8e6c9);
  margin-bottom: 1.25rem;
}

.auth-email-banner strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--theme-primary, #2e7d32);
  margin-bottom: 0.25rem;
}

.auth-email-banner span {
  font-size: 0.95rem;
  color: #1565c0;
  word-break: break-all;
}

.auth-steps {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.auth-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: #e0e0e0;
}

.auth-step--active {
  background: linear-gradient(90deg, var(--theme-primary-light, #43a047), var(--theme-primary, #2e7d32));
}

.auth-step--complete {
  background: #81c784;
}

.auth-resend-row {
  margin-top: 1rem;
  text-align: center;
}

.auth-resend-status {
  display: none;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Password toggle inside auth cards */
.auth-page .password-wrapper {
  width: 100%;
}

.auth-page .password-toggle {
  color: #78909c;
}

.auth-page .password-toggle:hover {
  color: var(--theme-primary, #2e7d32);
}

@media (max-width: 768px) {
  .auth-brand {
    font-size: 1.12rem;
  }

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

/* Narrow phones: keep the same visual language as desktop (card, OTP, titles).
   Only tweak spacing that affects safe-area / tap targets, not the “verification look”. */
@media (max-width: 480px) {
  .auth-topbar {
    padding: 0.875rem max(1rem, env(safe-area-inset-right, 0px)) 0.875rem max(1rem, env(safe-area-inset-left, 0px));
  }

  .auth-main {
    padding: 1.5rem max(1rem, env(safe-area-inset-right, 0px)) max(2rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
    align-items: center;
    justify-content: center;
  }

  .auth-card,
  .auth-card--wide {
    padding: 2rem 2rem 1.75rem;
    border-radius: 16px;
    box-shadow:
      0 4px 6px -1px rgba(0, 0, 0, 0.07),
      0 24px 48px -12px rgba(0, 0, 0, 0.12);
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .auth-subtitle {
    font-size: 0.9375rem;
  }

  .auth-input--otp {
    font-size: 1.35rem;
    letter-spacing: 0.35em;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .auth-email-banner {
    padding: 1rem 1.125rem;
  }

  .auth-steps {
    margin-bottom: 1.25rem;
  }
}
