/* Mr Barber Auth — V2 authentication page styles.
 * Built on the dashboard design system (tokens.css + blocks.css + app-shell.css).
 * Used for: /login/ V2 standalone page (all auth views).
 * Rules: token colors only (no raw hex), dashboard proportions for fields/buttons,
 *        3-step wizard + OTP + social login + pending views. */

/* ================================================================
   AUTH PAGE LAYOUT (centered full-height, dashboard surface)
   ================================================================ */

.mrb-auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--mrb-gap-lg);
  padding: var(--mrb-gap-lg);
  background: var(--mrb-bg);
}

/* Auth card on a distinct surface with a border + soft depth so it reads as
   a card floating on the page background (uses dashboard tokens only). */
.mrb-auth-page .mrb-auth-card {
  width: 100%;
  max-width: 400px;
  padding: var(--mrb-gap-lg);
  background: var(--mrb-surface);
  border: 1px solid var(--mrb-border);
  border-radius: var(--mrb-radius);
  box-shadow: var(--mrb-shadow-md);
}

/* ================================================================
   BRAND MARK (reuses dashboard logo styling)
   ================================================================ */

.mrb-auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--mrb-gap-sm);
}

.mrb-auth-brand__mark,
.mrb-auth-brand__badge {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--mrb-logo-color, var(--mrb-brand-accent));
}

.mrb-auth-brand__badge {
  border-radius: var(--mrb-radius-sm);
  background: color-mix(in srgb, var(--mrb-brand-accent) 14%, var(--mrb-surface));
  font-weight: var(--mrb-font-weight-bold);
  color: var(--mrb-text-primary);
  font-size: var(--mrb-font-size-lg);
}

.mrb-auth-brand__title {
  font-size: var(--mrb-font-size-lg);
  font-weight: var(--mrb-font-weight-semibold);
  color: var(--mrb-text-primary);
  margin: 0;
}

/* ================================================================
   AUTH CARD HEAD / NOTICES
   ================================================================ */

.mrb-auth-card__title {
  font-size: var(--mrb-font-size-xl);
  font-weight: var(--mrb-font-weight-semibold);
  color: var(--mrb-text-primary);
  margin: 0 0 var(--mrb-gap-sm);
}

.mrb-auth-card__subtitle {
  font-size: var(--mrb-font-size-sm);
  color: var(--mrb-text-secondary);
  margin: 0 0 var(--mrb-gap-lg);
}

/* ================================================================
   INLINE ALERTS (static, inside card — NOT the floating blocks.css toast)
   ================================================================ */

.mrb-auth-alerts {
  display: flex;
  flex-direction: column;
  gap: var(--mrb-gap-sm);
  margin-bottom: var(--mrb-gap);
}

.mrb-auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--mrb-radius-sm);
  font-size: var(--mrb-font-size-sm);
  color: var(--mrb-text-primary);
  line-height: 1.4;
  border: 1px solid;
}

.mrb-auth-alert--error {
  background: var(--mrb-danger-bg);
  border-color: color-mix(in srgb, var(--mrb-danger) 30%, transparent);
  color: var(--mrb-danger);
}

.mrb-auth-alert--success {
  background: var(--mrb-success-bg);
  border-color: color-mix(in srgb, var(--mrb-success) 30%, transparent);
  color: var(--mrb-success);
}

.mrb-auth-alert--warning {
  background: var(--mrb-warning-bg);
  border-color: color-mix(in srgb, var(--mrb-warning) 30%, transparent);
  color: var(--mrb-warning);
}

.mrb-auth-alert__icon {
  flex-shrink: 0;
  font-size: var(--mrb-font-size-lg);
  line-height: 1;
  margin-top: 1px;
}

.mrb-auth-alert__text {
  flex: 1;
  min-width: 0;
}

/* ================================================================
   FORM (compact, dashboard-proportioned)
   ================================================================ */

.mrb-auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--mrb-gap);
}

.mrb-auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mrb-auth-field label {
  font-size: var(--mrb-font-size-sm);
  font-weight: var(--mrb-font-weight-medium);
  color: var(--mrb-text-primary);
}

.mrb-auth-field input,
.mrb-auth-field select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--mrb-border);
  border-radius: var(--mrb-radius-sm);
  font-size: var(--mrb-font-size-sm);
  font-family: var(--mrb-font-family);
  color: var(--mrb-text-primary);
  background: var(--mrb-surface);
  transition: border-color var(--mrb-transition-fast), box-shadow var(--mrb-transition-fast);
  outline: none;
}

.mrb-auth-field input:focus,
.mrb-auth-field select:focus {
  border-color: var(--mrb-brand-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mrb-brand-accent) 18%, transparent);
}

.mrb-auth-field input::placeholder {
  color: var(--mrb-text-faint);
}

.mrb-auth-field__strength {
  height: 3px;
  border-radius: var(--mrb-radius-pill);
  background: var(--mrb-surface-2);
  overflow: hidden;
  margin-top: 2px;
}

.mrb-auth-field__strength-bar {
  height: 100%;
  width: 0%;
  border-radius: var(--mrb-radius-pill);
  transition: width var(--mrb-transition), background var(--mrb-transition);
}

.mrb-auth-field__strength-bar--weak { width: 33%; background: var(--mrb-danger); }
.mrb-auth-field__strength-bar--fair { width: 66%; background: var(--mrb-warning); }
.mrb-auth-field__strength-bar--strong { width: 100%; background: var(--mrb-success); }

.mrb-auth-pass-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Inner wrapper is exactly the input's height, so the toggle button positioned
   inside it at top:50% lands precisely on the middle of the input box (not on
   the middle of the label+input wrapper, which pushed the eye outside the box). */
.mrb-auth-input-wrap {
  position: relative;
  display: block;
}

/* Keep password text clear of the eye toggle and, in RTL, mirror the padding. */
.mrb-auth-input-wrap input {
  padding-right: 40px;
}

[dir="rtl"] .mrb-auth-input-wrap input {
  padding-right: 12px;
  padding-left: 40px;
}

.mrb-auth-input-wrap .mrb-auth-field__strength {
  margin-top: 6px;
}

.mrb-auth-toggle-pass {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 4px;
  width: 34px;
  height: 34px;
  border-radius: var(--mrb-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  color: var(--mrb-text-faint);
  cursor: pointer;
  line-height: 0;
}

/* Keep the icon glyph centered inside the 34px hit box regardless of its
   intrinsic span size (MRB_Theme::icon wraps it in a .mrb-icon span). */
.mrb-auth-toggle-pass .mrb-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

[dir="rtl"] .mrb-auth-toggle-pass {
  right: auto;
  left: 4px;
}

.mrb-auth-toggle-pass:hover,
.mrb-auth-toggle-pass:focus-visible {
  color: var(--mrb-text-primary);
  background: var(--mrb-surface-hover);
}

/* Pressed state: highlight the eye-off icon that shows the password is visible. */
.mrb-auth-toggle-pass--active {
  color: var(--mrb-brand-accent);
}

/* ================================================================
   PASSKEY "RECOMMENDED" BADGE
   ================================================================ */
/* Small pill pinned inside the social buttons to signal a method attribute
   ("Recommended" / "Fast"). Kept compact so it doesn't crowd the button, on
   mobile especially. */
.mrb-auth-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  margin-inline-start: 4px;
  border-radius: var(--mrb-radius-pill);
  font-size: var(--mrb-font-size-xs);
  font-weight: var(--mrb-font-weight-bold);
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

/* Same "positive/confirmed" green palette for both "Recommended" (passkey) and
   "Fast" (Google) so the badges read consistently rather than as two alerts. */
.mrb-auth-badge--fast {
  background: var(--mrb-status-confirmed-bg);
  color: var(--mrb-status-confirmed);
}

/* ================================================================
   LOGIN MODE TOGGLE (email/code  <->  password, in-place)
   ================================================================ */
/* The small caption that tells the user a code will be emailed to them. */
.mrb-auth-field__hint {
  display: block;
  margin-top: 6px;
  font-size: var(--mrb-font-size-sm);
  color: var(--mrb-text-muted);
}

/* The "Sign in with password / Use a one-time code" row under the submit. */
.mrb-auth-toggle-mode {
  margin: var(--mrb-gap-sm) 0 0;
  text-align: center;
}

/* Reuse the link look but keep it a plain text-capable button. */
.mrb-auth-toggle-mode .mrb-auth-link {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--mrb-font-family);
  cursor: pointer;
}

.mrb-auth-toggle-mode .mrb-auth-link:hover,
.mrb-auth-toggle-mode .mrb-auth-link:focus-visible {
  text-decoration: underline;
}

/* ================================================================
   OTP INPUT (6-digit)
   ================================================================ */

.mrb-auth-otp {
  display: flex;
  gap: var(--mrb-gap-sm);
  justify-content: flex-start;
  /* Codes are digits: always type/read left-to-right, even on the RTL Arabic
     page (user report 2026-10-03: on the login TOTP step the boxes mirrored,
     so the first typed digit landed in the RIGHTMOST box). Also fixes the
     emailed-code step, which shares this container. */
  direction: ltr;
}

.mrb-auth-otp input {
  width: 48px;
  height: 52px;
  text-align: center;
  font-size: var(--mrb-font-size-xl);
  font-weight: var(--mrb-font-weight-semibold);
  font-family: var(--mrb-font-mono);
  border: 1px solid var(--mrb-border);
  border-radius: var(--mrb-radius-sm);
  background: var(--mrb-surface);
  color: var(--mrb-text-primary);
  outline: none;
  transition: border-color var(--mrb-transition-fast), box-shadow var(--mrb-transition-fast);
}

.mrb-auth-otp input:focus {
  border-color: var(--mrb-brand-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mrb-brand-accent) 18%, transparent);
}

.mrb-auth-otp input.filled {
  border-color: var(--mrb-brand-accent);
  background: color-mix(in srgb, var(--mrb-brand-accent) 6%, var(--mrb-surface));
}

.mrb-auth-otp-hint {
  font-size: var(--mrb-font-size-xs);
  color: var(--mrb-text-muted);
  margin-top: var(--mrb-gap-sm);
  text-align: center;
}

/* "Resend code" — a plain inline link, NOT a button. Reset all button chrome
   so it reads as a link, and give it a distinct (brand) color. */
.mrb-auth-resend-link {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--mrb-font-size-xs);
  font-weight: var(--mrb-font-weight-semibold);
  color: var(--mrb-brand-accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--mrb-brand-accent) 45%, transparent);
  text-underline-offset: 3px;
}

.mrb-auth-resend-link:hover {
  color: var(--mrb-brand-accent);
  text-decoration-color: currentColor;
}

.mrb-auth-resend-link:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mrb-auth-otp-hint--resend {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ================================================================
   OTP <-> PASSWORD IN-PLACE SWAP (login flow)
   The .mrb-auth-mode--password class on the form toggles which box is
   visible. We use display rules (NOT the [hidden] attribute) because
   .mrb-auth-otp, .mrb-auth-steps and .mrb-auth-otp-hint (which covers both
   the "we sent a code" hint and the resend hint) all set display:flex, which
   overrides the UA [hidden] rule.
   ================================================================ */

.mrb-auth-password-swap {
  display: none;
}

.mrb-auth-form.mrb-auth-mode--password .mrb-auth-otp,
.mrb-auth-form.mrb-auth-mode--password .mrb-auth-steps,
.mrb-auth-form.mrb-auth-mode--password .mrb-auth-otp-hint {
  display: none;
}

.mrb-auth-form.mrb-auth-mode--password .mrb-auth-password-swap {
  display: block;
}

/* Only one swap link is visible at a time. */
#mrb_otp_use_code {
  display: none;
}
.mrb-auth-form.mrb-auth-mode--password #mrb_otp_use_password {
  display: none;
}
.mrb-auth-form.mrb-auth-mode--password #mrb_otp_use_code {
  display: inline-block;
}

/* ================================================================
   TOTP LOGIN STEP (SECURITY-PAGE-PLAN Phase 5) — backup-code swap and
   the emergency email link. Same in-place mode pattern as the password
   swap above; visibility is driven by the [hidden] attribute from JS.
   ================================================================ */

/* Mr Barber TOTP backup field — used for the 10-char backup code entry
   on the login_totp step. Variants: none (single field). */
.mrb-totp-backup-input {
  width: 100%;
  height: 48px;
  text-align: center;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-size: 16px;
  font-weight: 600;
  border: 1.5px solid var(--mrb-border, #e2e8f0);
  border-radius: 12px;
  background: var(--mrb-surface, #fff);
  color: var(--mrb-text-primary, #0f172a);
}
.mrb-totp-backup-input:focus {
  outline: none;
  border-color: var(--mrb-primary, #6d28d9);
}

/* The emergency form is a bare inline link — no card chrome. */
.mrb-totp-emergency-form {
  margin: 8px 0 0;
  text-align: center;
}
.mrb-totp-emergency-link {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

/* ================================================================
   BUTTONS (map to the shared .mrb-btn system — compact 40px)
   ================================================================ */

.mrb-auth-form .mrb-btn,
.mrb-auth-form button[type="submit"] {
  width: 100%;
  height: 40px;
  justify-content: center;
}

.mrb-auth-action {
  margin-top: var(--mrb-gap-sm);
}

/* ================================================================
   STEP INDICATOR (3-step wizard)
   ================================================================ */

.mrb-auth-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--mrb-gap-sm);
  margin-bottom: var(--mrb-gap-lg);
}

.mrb-auth-step {
  height: 4px;
  width: 28px;
  border-radius: var(--mrb-radius-pill);
  background: var(--mrb-surface-2);
  transition: background var(--mrb-transition), width var(--mrb-transition);
}

.mrb-auth-step--active {
  width: 44px;
  background: var(--mrb-brand-accent);
}

.mrb-auth-step--done {
  background: var(--mrb-brand-accent);
}

/* ================================================================
   SOCIAL LOGIN (divider + buttons using .mrb-btn--ghost)
   ================================================================ */

.mrb-auth-divider {
  display: flex;
  align-items: center;
  gap: var(--mrb-gap);
  margin: var(--mrb-gap-lg) 0;
  color: var(--mrb-text-faint);
  font-size: var(--mrb-font-size-xs);
}

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

.mrb-auth-social {
  display: flex;
  flex-direction: column;
  gap: var(--mrb-gap-sm);
}

.mrb-auth-social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--mrb-gap-sm);
  height: 40px;
  padding: 0 var(--mrb-gap);
  border: 1px solid var(--mrb-border);
  border-radius: var(--mrb-radius-sm);
  background: var(--mrb-surface);
  color: var(--mrb-text-primary);
  font-family: var(--mrb-font-family);
  /* font-size-md matches the 1rem base inherited by <button> (see the
     .mrb-theme button reset in tokens.css), so anchor-styled social buttons
     render at the same size as their <button> siblings. */
  font-size: var(--mrb-font-size-md);
  font-weight: var(--mrb-font-weight-semibold);
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  transition: background var(--mrb-transition-fast), border-color var(--mrb-transition-fast);
}

.mrb-auth-social-btn:hover:not(:disabled) {
  background: var(--mrb-surface-hover);
  border-color: var(--mrb-border-strong);
}

.mrb-auth-social-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.mrb-auth-social-btn .mrb-icon {
  font-size: var(--mrb-font-size-lg);
}

/* ================================================================
   LINKS / FOOTNOTES
   ================================================================ */

.mrb-auth-link {
  font-size: var(--mrb-font-size-sm);
  color: var(--mrb-brand-accent);
  text-decoration: none;
  font-weight: var(--mrb-font-weight-medium);
}

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

.mrb-auth-footnote {
  text-align: center;
  font-size: var(--mrb-font-size-sm);
  color: var(--mrb-text-secondary);
  margin-top: var(--mrb-gap);
}

.mrb-auth-footer {
  text-align: center;
  font-size: var(--mrb-font-size-xs);
  color: var(--mrb-text-faint);
}

/* ================================================================
   PENDING / INFO (logout, pending, forgot-sent, magic)
   ================================================================ */

.mrb-auth-pending {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--mrb-gap-sm);
  padding: var(--mrb-gap) 0;
}

.mrb-auth-pending__icon {
  font-size: 40px;
  line-height: 1;
  color: var(--mrb-brand-accent);
  display: inline-flex;
  margin-bottom: var(--mrb-gap-sm);
}

.mrb-auth-pending__title {
  font-size: var(--mrb-font-size-lg);
  font-weight: var(--mrb-font-weight-semibold);
  color: var(--mrb-text-primary);
  margin: 0;
}

.mrb-auth-pending__text {
  font-size: var(--mrb-font-size-sm);
  color: var(--mrb-text-secondary);
  margin: 0 0 var(--mrb-gap);
  max-width: 320px;
}

/* Action button inside pending/info views (centered, not full-width) */
.mrb-auth-pending .mrb-auth-action {
  width: 100%;
  max-width: 280px;
  margin-top: var(--mrb-gap-sm);
}

.mrb-auth-pending .mrb-auth-action .mrb-btn {
  width: 100%;
}

/* ================================================================
   SPINNER
   ================================================================ */

.mrb-auth-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid color-mix(in srgb, var(--mrb-brand-accent) 25%, transparent);
  border-top-color: var(--mrb-brand-accent);
  border-radius: 50%;
  animation: mrb-spin 0.6s linear infinite;
  margin: var(--mrb-gap) 0;
}

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

/* ================================================================
   BUTTON LOADING STATE
   When a submit/verify button is clicked, auth-core.js adds this class to
   show a disabled, semi-transparent state (label stays visible) until the
   request resolves. The not-allowed cursor signals that the button is locked.
   ================================================================ */

.mrb-auth-btn--loading {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1023px) {
  .mrb-auth-page {
    padding: 0;
    min-height: 100svh;
    justify-content: flex-start;
  }

  .mrb-auth-page .mrb-auth-card {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    min-height: 100svh;
    padding: var(--mrb-gap);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .mrb-auth-otp {
    width: 100%;
    min-width: 0;
    gap: 4px;
    justify-content: stretch;
  }

  .mrb-auth-otp input {
    flex: 1;
    width: auto;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
  }
}
