/* ════════════════════════════════════════════════════════════
   AUTH PAGES & MODALS
   Login, Register, Forgot Password, Verify OTP
   
   Used by:
     - /login, /register, /forgot-password, /verify-otp standalone pages
     - Modal versions opened from header / interleaved CTAs
   
   Architecture:
     .auth-page          → standalone page wrapper (centered card)
     .auth-modal         → reuses .rqmodal-overlay pattern
     .auth-form          → shared form layout (used in both contexts)
     .auth-otp-entry     → 6-box OTP code input (shared across flows)
   ════════════════════════════════════════════════════════════ */


/* ─── PAGE WRAPPER (standalone /login, /register etc.) ─── */
.auth-page {
  min-height: calc(100vh - 64px);   /* account for header */
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 16px 64px;
  background: var(--color-bg-subtle, var(--color-bg-subtle));
}
.auth-page-inner {
  width: 100%;
  max-width: 440px;
  background: white;
  border: 1px solid var(--color-border-tertiary);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
@media (min-width: 600px) {
  .auth-page-inner {
    padding: 36px 32px;
  }
}

.auth-page-title {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-text-primary);
  letter-spacing: -0.015em;
}
.auth-page-subtitle {
  margin: 0 0 24px;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}


/* ─── SHARED FORM ELEMENTS ─── */
.auth-form {
  display: flex; flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex; flex-direction: column;
  gap: 6px;
}
.auth-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}
.auth-input {
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--color-border-secondary);
  border-radius: 8px;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--color-text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.auth-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 154, 73, 0.12);
}
.auth-input.invalid,
.auth-input-error {
  border-color: var(--orange-dark) !important;
  animation: auth-input-shake 0.4s;
}
@keyframes auth-input-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.auth-field-error {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--orange-dark);
  font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.auth-field-error::before {
  content: '⚠';
  font-size: 0.875rem;
}
.auth-field-hint {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  line-height: 1.4;
}


/* ─── SMART IDENTIFIER INPUT (mobile or email) ─── */
/* Mobile mode: shows +88 prefix chip, accepts digits.
   Email mode: no prefix, accepts text/@.
   Detection: first character; sticky once mode is determined. */
.auth-identifier-wrap {
  display: flex; align-items: stretch;
  background: white;
  border: 1px solid var(--color-border-secondary);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-identifier-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 154, 73, 0.12);
}
.auth-identifier-wrap.invalid {
  border-color: var(--orange-dark);
  animation: auth-input-shake 0.4s;
}

.auth-identifier-prefix {
  display: none;
  align-items: center;
  padding: 0 12px;
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 0.9375rem;
  font-weight: 700;
  border-right: 1px solid var(--color-border-tertiary);
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.auth-identifier-wrap[data-mode="mobile"] .auth-identifier-prefix {
  display: inline-flex;
}

.auth-identifier-input {
  flex: 1;
  border: none !important;
  background: transparent;
  padding: 12px 14px !important;
  font-size: 0.9375rem !important;
  font-family: inherit;
  color: var(--color-text-primary);
  width: 100%;
  min-width: 0;          /* allow shrinking inside flex */
}
.auth-identifier-input:focus { outline: none; }


/* ─── PASSWORD FIELD WITH VISIBILITY TOGGLE ─── */
.auth-password-wrap {
  position: relative;
  display: flex; align-items: stretch;
  background: white;
  border: 1px solid var(--color-border-secondary);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-password-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 154, 73, 0.12);
}
.auth-password-wrap.invalid {
  border-color: var(--orange-dark);
  animation: auth-input-shake 0.4s;
}
.auth-password-input {
  flex: 1;
  border: none !important;
  padding: 12px 14px !important;
  font-size: 0.9375rem !important;
  font-family: inherit;
  background: transparent;
  width: 100%;
  min-width: 0;
}
.auth-password-input:focus { outline: none; }
.auth-password-toggle {
  background: transparent;
  border: none;
  padding: 0 12px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--color-text-tertiary);
  transition: color 0.15s;
  flex-shrink: 0;
}
.auth-password-toggle:hover { color: var(--color-text-primary); }


/* ─── ACTION BUTTONS ─── */
.auth-submit {
  width: 100%;
  padding: 13px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.15s, transform 0.05s;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.auth-submit:hover { background: var(--green-dark); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit:disabled {
  background: var(--color-border-secondary);
  color: var(--color-text-tertiary);
  cursor: not-allowed;
  transform: none;
}
.auth-submit .icon { font-size: 1rem; }

/* Loading state — submit button shows spinner */
.auth-submit[data-loading="true"] {
  pointer-events: none;
  position: relative;
  color: transparent;
}
.auth-submit[data-loading="true"]::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  top: 50%; left: 50%;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: auth-spin 0.6s linear infinite;
}
@keyframes auth-spin {
  to { transform: rotate(360deg); }
}


/* ─── DIVIDER ("or") ─── */
.auth-divider {
  display: flex; align-items: center;
  gap: 12px;
  margin: 4px 0;
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border-tertiary);
}


/* ─── SOCIAL LOGIN BUTTONS ─── */
.auth-social {
  display: flex; flex-direction: column;
  gap: 8px;
}
.auth-social-btn {
  width: 100%;
  padding: 11px 14px;
  background: white;
  border: 1px solid var(--color-border-secondary);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text-primary);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.auth-social-btn:hover {
  background: var(--color-bg-subtle, var(--color-bg-subtle));
  border-color: var(--color-text-secondary);
}
.auth-social-btn-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: inline-flex;
}
.auth-social-btn-icon svg {
  width: 100%; height: 100%;
}


/* ─── FOOTER LINKS ROW ─── */
.auth-footer-links {
  display: flex; flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}
.auth-footer-links a {
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 600;
}
.auth-footer-links a:hover { text-decoration: underline; }
.auth-footer-link-row {
  display: flex; align-items: center; justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}


/* ─── TERMS CHECKBOX ─── */
.auth-terms {
  display: flex; align-items: flex-start;
  gap: 10px;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}
.auth-terms input[type="checkbox"] {
  width: 18px; height: 18px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--green);
  cursor: pointer;
}
.auth-terms label {
  cursor: pointer;
}
.auth-terms a {
  color: var(--green-dark);
  font-weight: 600;
  text-decoration: none;
}
.auth-terms a:hover { text-decoration: underline; }


/* ─── CLOUDFLARE TURNSTILE WRAPPER ─── */
/* Keeps Turnstile widget styled consistently inside our forms */
.auth-captcha {
  display: flex; justify-content: center;
  margin: 4px 0;
  min-height: 65px;
}
.auth-captcha-placeholder {
  /* Demo placeholder; real Turnstile widget replaces this */
  width: 300px;
  padding: 14px 16px;
  background: #F9F9F9;
  border: 1px solid #E0E0E0;
  border-radius: 4px;
  display: flex; align-items: center; gap: 12px;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}
.auth-captcha-placeholder-check {
  width: 22px; height: 22px;
  border: 2px solid #C0C0C0;
  border-radius: 3px;
  flex-shrink: 0;
}


/* ─── ERROR/INFO BANNERS ─── */
.auth-banner {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.8125rem;
  line-height: 1.5;
  display: flex; align-items: flex-start;
  gap: 10px;
}
.auth-banner-icon {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1.4;
}
.auth-banner-error {
  background: var(--orange-light);
  color: var(--orange-dark);
  border: 1px solid var(--orange-light);
}
.auth-banner-error .auth-banner-icon { color: var(--orange-dark); }
.auth-banner-info {
  background: var(--green-light);
  color: var(--green-dark);
  border: 1px solid var(--green-light);
}
.auth-banner-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid var(--color-warning-border);
}


/* ════════════════════════════════════════════════════════
   OTP ENTRY UI — used inside register & forgot-password flows
   AND in standalone /verify-otp if backend redirects there.
   ════════════════════════════════════════════════════════ */
.auth-otp {
  display: flex; flex-direction: column;
  gap: 18px;
}

.auth-otp-header {
  text-align: center;
}
.auth-otp-icon {
  font-size: 2.25rem;
  line-height: 1;
  margin-bottom: 8px;
}
.auth-otp-title {
  margin: 0 0 6px;
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--color-text-primary);
}
.auth-otp-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}
.auth-otp-target {
  font-weight: 700;
  color: var(--color-text-primary);
}

.auth-otp-edit-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 600;
}
.auth-otp-edit-link:hover { text-decoration: underline; }


/* ─── 6-BOX OTP CODE INPUT ─── */
.auth-otp-boxes {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  margin: 2px 0;
}
@media (max-width: 380px) {
  .auth-otp-boxes { gap: 6px; }
}
.auth-otp-box {
  width: 44px; height: 52px;
  text-align: center;
  background: white;
  border: 1.5px solid var(--color-border-secondary);
  border-radius: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  /* Hide spinner on type=number */
  -moz-appearance: textfield;
}
.auth-otp-box::-webkit-outer-spin-button,
.auth-otp-box::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
@media (max-width: 380px) {
  .auth-otp-box { width: 38px; height: 46px; font-size: 1.0625rem; }
}
.auth-otp-box:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 154, 73, 0.15);
  background: white;
}
.auth-otp-box.filled {
  border-color: var(--green);
  background: var(--green-light);
}
.auth-otp-box.invalid {
  border-color: var(--orange-dark);
  background: var(--orange-light);
}

.auth-otp-error {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--orange-dark);
  font-weight: 600;
}


/* ─── COUNTDOWN + RESEND ROW ─── */
.auth-otp-timer {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}
.auth-otp-timer-time {
  font-weight: 700;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
.auth-otp-timer-expired {
  color: var(--orange-dark);
}

.auth-otp-resend {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}
.auth-otp-resend-disabled {
  color: var(--color-text-tertiary);
}
.auth-otp-resend-btn {
  background: transparent;
  border: none;
  color: var(--green-dark);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  text-decoration: underline;
}
.auth-otp-resend-btn:disabled {
  color: var(--color-text-tertiary);
  cursor: not-allowed;
  text-decoration: none;
}
.auth-otp-resend-btn:hover:not(:disabled) { text-decoration: none; }
.auth-otp-resend-divider {
  margin: 0 6px;
  color: var(--color-border-secondary);
}


/* ─── RATE-LIMITED LOCKOUT BANNER ─── */
.auth-locked {
  text-align: center;
  padding: 24px 16px;
}
.auth-locked-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}
.auth-locked-title {
  margin: 0 0 8px;
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--color-text-primary);
}
.auth-locked-msg {
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}
.auth-locked-countdown {
  font-weight: 700;
  color: var(--orange-dark);
  font-variant-numeric: tabular-nums;
}


/* ════════════════════════════════════════════════════════
   AUTH MODAL — reuses .rqmodal-overlay pattern from product page
   ════════════════════════════════════════════════════════ */
.auth-modal .rqmodal-sheet {
  max-width: 420px;
}
.auth-modal-body {
  padding: 0 20px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-modal-header {
  padding: 14px 20px 6px;
  border-bottom: 1px solid var(--color-border-tertiary);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.auth-modal-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--color-text-primary);
}
.auth-modal-close {
  width: 32px; height: 32px;
  background: transparent;
  border: none;
  color: var(--color-text-tertiary);
  font-size: 1.125rem;
  cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.auth-modal-close:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}
.auth-modal-body .auth-form {
  padding-top: 18px;
}


/* Hide page-only or modal-only elements when in opposite context */
.auth-modal .auth-page-title,
.auth-modal .auth-page-subtitle { display: none; }


/* ════════════════════════════════════════════════════════
   STATE TRANSITIONS — show/hide form vs OTP entry vs locked
   inside the same container. Driven by data attribute on form.
   ════════════════════════════════════════════════════════ */
[data-auth-state="form"] .auth-otp,
[data-auth-state="form"] .auth-locked,
[data-auth-state="otp"] .auth-form-fields,
[data-auth-state="otp"] .auth-locked,
[data-auth-state="locked"] .auth-form-fields,
[data-auth-state="locked"] .auth-otp {
  display: none !important;
}


/* ════════════════════════════════════════════════════════
   SUCCESS / TRANSITION STATES
   ════════════════════════════════════════════════════════ */
.auth-success {
  text-align: center;
  padding: 24px 0;
}
.auth-success-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 12px;
}
.auth-success-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text-primary);
}
.auth-success-msg {
  margin: 0 0 18px;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}
