/* ——— مراحل ورود — انیمیشن نرم ——— */
.auth-steps-viewport {
  position: relative;
  min-height: 11rem;
}

.auth-step {
  display: block;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.985);
  pointer-events: none;
  position: absolute;
  inset: 0;
  width: 100%;
  transition:
    opacity 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.38s;
}

.auth-step.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  position: relative;
}

.auth-step.auth-step--exit {
  opacity: 0;
  transform: translateY(-8px) scale(0.985);
}

/* ——— سوییچ پیامک / رمز ——— */
.auth-mode-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 1.15rem;
  border-radius: 14px;
  background: var(--bg-alt, #eef3ef);
  border: 1px solid var(--line, #e0e8e2);
}

.auth-mode-switch__btn {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 0.55rem 0.5rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted, #5c6560);
  cursor: pointer;
  border-radius: 11px;
  transition: color 0.28s ease;
}

.auth-mode-switch__btn.is-active,
.auth-mode-switch__btn[aria-selected="true"] {
  color: var(--brand, #81B061);
}

.auth-mode-switch__btn:hover:not(.is-active) {
  color: var(--text, #1a2420);
}

.auth-mode-switch__indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 11px;
  background: var(--surface-strong, #fff);
  box-shadow: 0 2px 12px rgba(129, 176, 97, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.auth-box.auth-mode--password .auth-mode-switch__indicator {
  transform: translateX(-100%);
}

/* ——— فیلدها ——— */
.auth-field {
  display: grid;
  gap: 0.4rem;
}

.auth-field__label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted, #5c6560);
}

.auth-field__input {
  width: 100%;
  min-height: 50px;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--line, #d8e0da);
  border-radius: 14px;
  background: var(--surface-strong, #fff);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text, #1a2420);
  transition:
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    background 0.25s ease;
}

.auth-field__input::placeholder {
  color: #6d7a72;
}

.auth-field__input:hover {
  border-color: color-mix(in srgb, var(--brand, #81B061) 35%, var(--line) 65%);
}

.auth-field__input:focus {
  outline: none;
  border-color: var(--brand, #81B061);
  box-shadow: 0 0 0 4px rgba(129, 176, 97, 0.14);
}

/* ——— رمز عبور — انیمیشن باز شدن ——— */
.auth-password-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
  transition:
    grid-template-rows 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.32s ease,
    margin-top 0.35s ease;
}

.auth-password-wrap.is-visible {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 0.75rem;
}

.auth-password-wrap__inner {
  overflow: hidden;
}

.auth-password-field {
  position: relative;
  display: flex;
  align-items: stretch;
}

.auth-field__input--password {
  padding-inline-start: 3rem;
  padding-inline-end: 0.9rem;
}

.auth-password-toggle {
  position: absolute;
  inset-inline-start: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(129, 176, 97, 0.08);
  color: var(--brand, #81B061);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease, transform 0.2s ease;
}

.auth-password-toggle:hover {
  background: rgba(129, 176, 97, 0.16);
  transform: translateY(-50%) scale(1.04);
}

.auth-password-toggle-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-password-toggle-icon--show {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.auth-password-toggle-icon--hide {
  opacity: 0;
  transform: scale(0.55) rotate(-18deg);
  pointer-events: none;
}

.auth-password-toggle.is-revealed .auth-password-toggle-icon--show {
  opacity: 0;
  transform: scale(0.55) rotate(18deg);
}

.auth-password-toggle.is-revealed .auth-password-toggle-icon--hide {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.auth-form--login {
  gap: 0;
}

.auth-form--login .auth-submit-btn {
  margin-top: 1.1rem;
}

/* ——— OTP ——— */
.auth-otp-row {
  position: relative;
}

.auth-otp-autofill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0.001;
  z-index: 2;
  caret-color: transparent;
  color: transparent;
  background: transparent;
}

.auth-otp-digit {
  position: relative;
  z-index: 3;
}

.auth-step-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.auth-otp-hint {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted, #5c6560);
  margin: 0 0 1rem;
  line-height: 1.65;
}

.auth-mobile-inline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.4rem;
  vertical-align: middle;
}

.auth-mobile-inline strong {
  color: var(--text, #1a2420);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.auth-step-switch {
  margin: 0.85rem 0 0;
  text-align: center;
}

.auth-page {
  width: min(520px, calc(100% - 1.5rem));
  margin: 1rem auto 3rem;
}

.auth-lead {
  color: var(--text-muted, #5c6560);
  font-size: 0.92rem;
  margin: 0 0 1rem;
  line-height: 1.55;
}

.auth-error {
  background: #fff3f2;
  border: 1px solid #f2d1cd;
  color: var(--danger, #b42318);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.auth-lockout {
  text-align: center;
}

.auth-box .btn-primary,
.auth-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 0.8rem 1.25rem;
  border: none;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-family: var(--font-display, IRANSans, Vazirmatn, Tahoma, sans-serif);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(129, 176, 97, 0.28);
  transition:
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.22s ease,
    opacity 0.2s ease;
}

.auth-box .btn-primary:hover:not(:disabled),
.auth-submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(129, 176, 97, 0.35);
}

.auth-box .btn-primary:active:not(:disabled),
.auth-submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.auth-box .btn-primary:disabled:not(.is-loading),
.auth-submit-btn:disabled:not(.is-loading) {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* دکمه در حال پردازش — اسپینر + نوار پیشرفت + کم‌رنگ */
.auth-submit-btn {
  position: relative;
  overflow: hidden;
  gap: 0.45rem;
}

.auth-submit-btn.is-loading,
.auth-submit-btn.is-loading:disabled {
  opacity: 0.62;
  cursor: wait;
  pointer-events: none;
  transform: none;
  box-shadow: 0 6px 18px rgba(129, 176, 97, 0.18);
  background: linear-gradient(145deg, rgba(129, 176, 97, 0.82), rgba(36, 112, 51, 0.82));
}

.auth-submit-btn.is-loading .auth-btn__label {
  opacity: 0.9;
}

.auth-btn__progress {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.45);
  transform: scaleX(0);
  transform-origin: right center;
  opacity: 0;
  pointer-events: none;
}

.auth-submit-btn.is-loading .auth-btn__progress {
  opacity: 1;
  animation: auth-btn-progress 1.1s ease-in-out infinite;
}

@keyframes auth-btn-progress {
  0% {
    transform: scaleX(0);
    transform-origin: right center;
  }
  45% {
    transform: scaleX(0.75);
    transform-origin: right center;
  }
  55% {
    transform-origin: left center;
  }
  100% {
    transform: scaleX(0);
    transform-origin: left center;
  }
}

.auth-submit-btn .auth-btn__spinner {
  width: 0.82rem;
  height: 0.82rem;
  border-width: 1.5px;
}

.auth-btn__spinner {
  display: none;
  flex-shrink: 0;
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-btn-spin 0.65s linear infinite;
}

.auth-submit-btn.is-loading .auth-btn__spinner,
.auth-resend-btn.is-loading .auth-btn__spinner--inline {
  display: inline-block;
}

.auth-btn__spinner--inline {
  width: 0.9rem;
  height: 0.9rem;
  border-width: 1.5px;
  border-color: rgba(129, 176, 97, 0.25);
  border-top-color: var(--brand, #81B061);
  vertical-align: middle;
  margin-inline-end: 0.35rem;
}

.auth-resend-btn.is-loading {
  opacity: 0.55;
  cursor: wait;
  pointer-events: none;
}

.auth-resend-btn.is-loading .auth-btn__label {
  opacity: 0.85;
}

@keyframes auth-btn-spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-otp-row--shake {
  animation: auth-otp-shake 0.42s ease;
}

@keyframes auth-otp-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-otp-row--shake {
    animation: none;
  }

  .auth-btn__spinner,
  .auth-submit-btn.is-loading .auth-btn__progress {
    animation: none;
  }

  .auth-submit-btn.is-loading .auth-btn__progress {
    transform: scaleX(0.55);
    opacity: 0.5;
  }
}

.auth-resend-line {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted, #5c6560);
  min-height: 1.4rem;
}

.auth-resend-countdown strong {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text, #1a2420);
}

.auth-text-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--brand, #81B061);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.auth-text-link:hover:not(:disabled) {
  color: var(--brand-hover, #719552);
}

.auth-text-link:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  text-decoration: none;
}

.auth-edit-mobile {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: none;
  border: none;
  padding: 0.1rem 0.2rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand, #81B061);
  cursor: pointer;
  transition: color 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.auth-edit-mobile:hover {
  color: var(--brand-hover, #719552);
}

.auth-form--otp {
  gap: 1rem;
}

.auth-otp-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.auth-otp-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.auth-otp-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  direction: ltr;
}

.auth-form--otp .auth-otp-digit {
  flex: 0 0 3.1rem;
  width: 3.1rem;
  height: 3.5rem;
  padding: 0;
  box-sizing: border-box;
  border: 2px solid var(--line, #d8e0da);
  border-radius: 14px;
  background: var(--surface-strong, #fff);
  color: var(--text, #1a2420);
  font-family: var(--font-en, system-ui, sans-serif);
  font-size: 1.45rem;
  font-weight: 700;
  text-align: center;
  line-height: 3.5rem;
  caret-color: var(--brand, #81B061);
  transition:
    border-color 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.28s ease,
    box-shadow 0.28s ease,
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  -moz-appearance: textfield;
  appearance: none;
}

.auth-form--otp .auth-otp-digit::-webkit-outer-spin-button,
.auth-form--otp .auth-otp-digit::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.auth-form--otp .auth-otp-digit.is-active {
  border-color: var(--brand, #81B061);
  box-shadow: 0 0 0 4px rgba(129, 176, 97, 0.18);
  transform: translateY(-2px) scale(1.03);
}

.auth-form--otp .auth-otp-digit.is-filled {
  border-color: var(--brand, #81B061);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 18px rgba(129, 176, 97, 0.28);
  transform: translateY(-1px);
}

.auth-form--otp .auth-otp-digit.is-filled.is-active {
  box-shadow:
    0 0 0 4px rgba(129, 176, 97, 0.2),
    0 6px 18px rgba(129, 176, 97, 0.28);
}

.auth-form--otp .auth-otp-digit.is-error {
  border-color: #c0392b;
  background: #fff5f4;
  color: #c0392b;
  animation: auth-otp-shake 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes auth-otp-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@media (max-width: 380px) {
  .auth-otp-row { gap: 0.4rem; }
  .auth-form--otp .auth-otp-digit {
    flex: 0 0 2.65rem;
    width: 2.65rem;
    height: 3.1rem;
    font-size: 1.25rem;
    line-height: 3.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-step,
  .auth-mode-switch__indicator,
  .auth-password-wrap,
  .auth-form--otp .auth-otp-digit {
    transition: none;
  }
}
