/* ── MyNest Auth Pages (Login / Signup) ─────────────────────────────────── */

@import url('mynest-prompt.css');

:root {
  --auth-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --auth-bg-start: var(--brand-teal-dark, #2c5e7a);
  --auth-bg-end: var(--brand-green-dark, #3e5f3e);
  --auth-surface: #ffffff;
  --auth-text: var(--brand-text, #1e293b);
  --auth-text-muted: var(--brand-text-muted, #64748b);
  --auth-label: #334155;
  --auth-border: var(--brand-border, #d8e4e8);
  --auth-border-focus: var(--brand-teal, #4a89a4);
  --auth-input-bg: var(--brand-surface-alt, #eef4f6);
  --auth-primary: var(--brand-teal-dark, #2c5e7a);
  --auth-primary-dark: #1e4254;
  --auth-accent: var(--brand-orange, #d67a52);
  --auth-accent-dark: var(--brand-orange-dark, #b8633f);
  --auth-success: var(--brand-green, #5e8a62);
  --auth-error: #dc2626;
  --auth-warning: var(--brand-yellow, #e8b05d);
  --auth-radius: 14px;
  --auth-radius-sm: 10px;
  --auth-shadow: 0 24px 48px rgba(44, 94, 122, 0.18);
  --auth-ring: 0 0 0 3px rgba(74, 137, 164, 0.15);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.auth-page {
  font-family: var(--auth-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--auth-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.06) 0%, transparent 40%),
    linear-gradient(135deg, var(--auth-bg-start) 0%, var(--auth-bg-end) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  padding: 24px 16px;
}

/* Back button */
.back-button {
  position: fixed;
  top: 20px;
  left: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  color: var(--auth-label);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--auth-radius-sm);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

.back-button:hover {
  background: #fff;
  color: var(--auth-primary);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.16);
}

.auth-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 520px;
  padding: 56px 0 32px;
}

.auth-card {
  position: relative;
  background: var(--auth-surface);
  padding: 48px 32px 32px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--auth-shadow);
  width: 100%;
  max-width: 420px;
}

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

/* Header / branding */
.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  margin: -72px auto 18px;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.22));
}

.auth-title {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--auth-text);
  line-height: 1.25;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--auth-text-muted);
  line-height: 1.5;
  max-width: 320px;
  margin: 0 auto;
}

.auth-google-wrap {
  display: flex;
  justify-content: center;
  margin-top: 8px;
  margin-bottom: 4px;
  min-height: 44px;
}

.auth-google-wrap > div {
  width: 100% !important;
  max-width: 100%;
}

.auth-google-error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--auth-error);
  text-align: center;
}

.auth-google-row {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  position: relative;
}

.auth-google-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-sm);
  background: #fff;
  color: var(--auth-text);
  font-family: var(--auth-font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.auth-google-custom:hover {
  border-color: var(--auth-border-focus);
  box-shadow: var(--auth-ring);
}

.auth-google-custom:focus-visible {
  outline: none;
  box-shadow: var(--auth-ring);
}

.auth-google-custom-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-google-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.role-picker-group.is-invalid .role-picker-label {
  color: var(--auth-error);
}

.role-picker-group.is-invalid .role-option-card {
  border-color: rgba(220, 38, 38, 0.45);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--auth-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--auth-border);
}

.auth-divider span {
  white-space: nowrap;
}

.auth-role-first {
  margin-bottom: 4px;
}

/* Form layout */
.auth-form {
  text-align: left;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label,
.role-picker-label {
  display: block;
  margin-bottom: 7px;
  color: var(--auth-label);
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  text-transform: none;
}

.form-group input:not([type="radio"]) {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--auth-border);
  border-radius: var(--auth-radius-sm);
  font-family: var(--auth-font);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--auth-text);
  background: var(--auth-input-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-group input:not([type="radio"]):hover {
  border-color: #cbd5e1;
  background: #fff;
}

.form-group input:not([type="radio"]):focus {
  outline: none;
  border-color: var(--auth-border-focus);
  box-shadow: var(--auth-ring);
  background: #fff;
}

.form-group input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.form-group input.otp-input {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 14px 16px;
}

.terms-agree-group {
  margin-bottom: 16px;
}

.terms-agree {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  font-weight: 500;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--auth-text-muted, #64748b);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.terms-agree input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--brand-teal-dark, #2c5e7a);
  cursor: pointer;
}

.terms-agree a {
  color: var(--brand-teal-dark, #2c5e7a);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.terms-agree a:hover {
  color: var(--brand-orange, #d67a52);
}

.terms-agree-group.is-invalid .terms-agree {
  color: #b91c1c;
}

.terms-agree-group.is-invalid {
  outline: 1px solid rgba(185, 28, 28, 0.35);
  outline-offset: 6px;
  border-radius: 8px;
}

/* Password field */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  padding-right: 48px !important;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.2s ease, background 0.2s ease;
  outline: none;
  line-height: 0;
  z-index: 2;
}

.password-toggle svg {
  width: 20px;
  height: 20px;
}

.password-toggle:hover {
  color: var(--auth-primary);
  background: rgba(37, 99, 235, 0.08);
}

.password-toggle:focus-visible {
  box-shadow: var(--auth-ring);
  color: var(--auth-primary);
}

.password-toggle.is-visible {
  color: var(--auth-accent);
}

.password-strength {
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 1.125rem;
}

.password-strength:empty {
  display: none;
}

.strength-weak { color: var(--auth-error); }
.strength-medium { color: var(--auth-warning); }
.strength-strong { color: var(--auth-success); }

/* Role picker */
.role-picker-group {
  margin-bottom: 20px;
}

.role-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.role-option {
  cursor: pointer;
  margin: 0;
}

.role-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.role-option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 88px;
  padding: 16px 12px;
  border: 1.5px solid var(--auth-border);
  border-radius: var(--auth-radius-sm);
  background: var(--auth-input-bg);
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.role-option-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--auth-text);
  letter-spacing: -0.02em;
}

.role-option-desc {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--auth-text-muted);
  line-height: 1.35;
}

.role-option:hover .role-option-card {
  border-color: #93c5fd;
  background: #fff;
}

.role-option input:focus-visible + .role-option-card {
  border-color: var(--auth-primary);
  box-shadow: var(--auth-ring);
}

.role-option input:checked + .role-option-card {
  border-color: var(--auth-primary);
  background: linear-gradient(180deg, #eff6ff 0%, #fff 100%);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.14);
  transform: translateY(-1px);
}

.role-option input:checked + .role-option-card .role-option-title {
  color: var(--auth-primary-dark);
}

/* Turnstile */
.turnstile-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 68px;
  margin-bottom: 8px !important;
  padding: 12px;
  background: var(--auth-input-bg);
  border: 1.5px dashed var(--auth-border);
  border-radius: var(--auth-radius-sm);
}

/* OTP section */
.otp-group {
  padding: 16px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: var(--auth-radius-sm);
  margin-bottom: 16px;
}

.otp-hint {
  display: block;
  margin-top: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #166534;
  line-height: 1.45;
}

.otp-timer {
  margin-top: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--auth-text-muted);
  text-align: center;
}

.otp-timer.is-expired {
  color: var(--auth-error);
}

.form-group input.is-valid {
  border-color: var(--auth-success);
  background: #fff;
}

.form-group input.is-invalid {
  border-color: var(--auth-error);
  background: #fff;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--auth-radius-sm);
  background: linear-gradient(135deg, var(--auth-primary) 0%, var(--auth-primary-dark) 100%);
  color: #fff;
  font-family: var(--auth-font);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  margin-top: 6px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.85;
}

.btn-primary--accent {
  background: linear-gradient(135deg, var(--auth-accent) 0%, var(--auth-accent-dark) 100%);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.btn-primary--accent:hover:not(:disabled) {
  box-shadow: 0 8px 22px rgba(124, 58, 237, 0.4);
}

/* Footer links */
.auth-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--auth-border);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--auth-text-muted);
  text-align: center;
  line-height: 1.6;
}

.auth-footer a {
  color: var(--auth-accent);
  text-decoration: none;
  font-weight: 700;
}

.auth-footer a:hover {
  color: var(--auth-accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.forgot-password {
  margin-top: 14px;
  text-align: center;
  font-size: 0.875rem;
}

.forgot-password a {
  color: var(--auth-text-muted);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease;
}

.forgot-password a:hover {
  color: var(--auth-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Password reset flow - step indicator */
.auth-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
}

.auth-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
  color: var(--auth-text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  left: calc(50% + 18px);
  width: calc(100% - 36px);
  height: 2px;
  background: var(--auth-border);
  z-index: 0;
}

.auth-step--active {
  color: var(--auth-primary);
}

.auth-step--active .auth-step-num {
  background: var(--auth-primary);
  color: #fff;
  border-color: var(--auth-primary);
}

.auth-step--done {
  color: var(--auth-success);
}

.auth-step--done .auth-step-num {
  background: var(--auth-success);
  color: #fff;
  border-color: var(--auth-success);
}

.auth-step--done:not(:last-child)::after {
  background: var(--auth-success);
}

.auth-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--auth-input-bg);
  border: 2px solid var(--auth-border);
  position: relative;
  z-index: 1;
}

.auth-step-label {
  text-align: center;
  line-height: 1.2;
}

/* Info callout */
.auth-info-box {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--auth-input-bg);
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-sm);
  padding: 12px 14px;
  margin-bottom: 20px;
  font-size: 0.8125rem;
  color: var(--auth-text-muted);
  line-height: 1.5;
}

.auth-info-box svg {
  flex-shrink: 0;
  color: var(--auth-primary);
  margin-top: 1px;
}

.auth-info-box strong {
  color: var(--auth-text);
  font-weight: 600;
}

/* Inline form messages */
.form-message {
  border-radius: var(--auth-radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
}

.form-message--success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.form-message--error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.form-message--warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Alerts */
.message {
  border-radius: var(--auth-radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
}

.error-message {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.success-message,
.message.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.message.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.message.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.spinner,
.loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  border-top-color: #fff;
  animation: auth-spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 520px) {
  .auth-container {
    padding: 48px 0 24px;
  }

  .auth-card,
  .auth-card--wide {
    padding: 28px 22px 26px;
    border-radius: 16px;
  }

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

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

  .auth-step-label {
    font-size: 0.58rem;
  }

  .auth-info-box {
    font-size: 0.78rem;
    padding: 10px 12px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .role-picker {
    grid-template-columns: 1fr;
  }

  .role-option-card {
    flex-direction: row;
    justify-content: flex-start;
    min-height: auto;
    padding: 14px 16px;
    gap: 14px;
    text-align: left;
  }

  .role-option-text {
    align-items: flex-start;
  }

  .back-button {
    top: 12px;
    left: 12px;
    padding: 8px 12px;
    font-size: 0.8125rem;
  }
}

@media (max-width: 360px) {
  .auth-card {
    padding: 24px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .btn-primary:hover:not(:disabled),
  .role-option input:checked + .role-option-card {
    transform: none;
  }
}

@media (prefers-contrast: high) {
  .auth-card {
    border: 2px solid #000;
  }

  .form-group input:not([type="radio"]) {
    border-width: 2px;
  }
}
