/* صفحه احراز هویت — حس موبایل اپلیکیشن */

body.auth-page {
  cursor: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.auth-page .cursor-dot,
body.auth-page .cursor-ring {
  display: none;
}

body.auth-page .interactive {
  cursor: pointer;
}

body.auth-page::before {
  display: none;
}

/* پس‌زمینه ثابت موبایل */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.auth-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.32) saturate(0.35) contrast(1.05);
}

.auth-bg__shade {
  position: absolute;
  inset: 0;
  background: var(--bg-shade);
}

/* نوار پیشرفت مراحل */
.auth-progress {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  height: 3px;
  z-index: 10001;
  background: rgba(var(--ink-rgb), 0.05);
}

.auth-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  transform-origin: right center;
  transition: transform 0.35s ease;
  box-shadow: 0 0 10px var(--gold);
}

/* محتوای اصلی */
.auth-main {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1.125rem 0;
  max-width: 480px;
  margin: 0 auto;
}

.auth-step {
  display: none;
  width: 100%;
  max-width: 520px;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.auth-step.is-active {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-bottom: 2rem;
}

.auth-step .scene-meta {
  opacity: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.68rem;
  margin-bottom: 0.75rem;
}

.auth-step .scene-meta__chapter {
  color: var(--gold);
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(var(--gold-rgb), 0.35);
  border-radius: 999px;
}

.auth-step .scene-meta__label {
  color: rgba(var(--ink-rgb), 0.45);
}

.auth-step .scene-meta::after {
  display: none;
}

.auth-step .scene-heading {
  opacity: 1;
  margin-bottom: 0.5rem;
  font-size: clamp(1.25rem, 5vw, 1.55rem);
  font-weight: 800;
  line-height: 1.4;
}

.auth-step .scene-sub {
  opacity: 1;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
  color: rgba(var(--ink-rgb), 0.58);
  line-height: 1.7;
  max-width: 22rem;
}

/* کارت فرم */
.auth-card {
  width: 100%;
  background: rgba(var(--ink-rgb), 0.04);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(var(--ink-rgb), 0.1);
  border-radius: 24px;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  position: relative;
  overflow: hidden;
}

.auth-card:has(.jalali-date-field.is-open) {
  overflow: visible;
  z-index: 5;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--gold), var(--purple));
}

.auth-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(var(--gold-rgb), 0.08), transparent 60%);
  pointer-events: none;
}

.auth-form {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  text-align: right;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.auth-label {
  font-size: 0.85rem;
  color: rgba(var(--ink-rgb), 0.65);
  font-weight: 500;
}

.auth-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  background: rgba(var(--ink-rgb), 0.06);
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
  direction: ltr;
  text-align: center;
  letter-spacing: 0.08em;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input:focus {
  outline: none;
  border-color: rgba(var(--gold-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--gold-rgb), 0.12);
}

.auth-input::placeholder {
  color: rgba(var(--ink-rgb), 0.3);
  letter-spacing: 0;
}

.auth-input--error {
  border-color: rgba(255, 80, 80, 0.6);
}

/* دیت‌پیکر شمسی */
.jalali-date-field {
  position: relative;
}

.jalali-date-input {
  padding-left: 2.75rem;
  cursor: pointer;
}

.jalali-date-trigger {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(var(--gold-rgb), 0.12);
  color: var(--gold-light);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.jalali-date-trigger:hover {
  background: rgba(var(--gold-rgb), 0.22);
  color: var(--gold);
}

.jalali-date-field.is-open .jalali-date-trigger {
  background: rgba(var(--gold-rgb), 0.28);
}

.jalali-picker {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  left: 0;
  z-index: 50;
  padding: 0.85rem;
  border-radius: 16px;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  background: rgba(12, 16, 28, 0.98);
  backdrop-filter: blur(24px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.jalali-picker__head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.jalali-picker__selects {
  flex: 1;
  display: flex;
  gap: 0.35rem;
}

.jalali-picker__dropdown {
  position: relative;
  flex: 1;
  min-width: 0;
}

.jalali-picker__dropdown-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  background: rgba(var(--ink-rgb), 0.06);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.jalali-picker__dropdown-btn:hover,
.jalali-picker__dropdown.is-open .jalali-picker__dropdown-btn {
  border-color: rgba(var(--gold-rgb), 0.45);
  background: rgba(var(--ink-rgb), 0.1);
}

.jalali-picker__dropdown-btn svg {
  flex-shrink: 0;
  opacity: 0.65;
  transition: transform 0.2s;
}

.jalali-picker__dropdown.is-open .jalali-picker__dropdown-btn svg {
  transform: rotate(180deg);
}

.jalali-picker__dropdown-menu {
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  left: 0;
  z-index: 60;
  max-height: 11rem;
  overflow-y: auto;
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  background: #12182a;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.jalali-picker__dropdown-menu[hidden] {
  display: none;
}

.jalali-picker__dropdown-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(var(--ink-rgb), 0.88);
  font-family: inherit;
  font-size: 0.82rem;
  text-align: right;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.jalali-picker__dropdown-item:hover {
  background: rgba(var(--gold-rgb), 0.15);
  color: var(--gold-light);
}

.jalali-picker__dropdown-item.is-active {
  background: rgba(var(--gold-rgb), 0.22);
  color: var(--gold-light);
  font-weight: 600;
}

.jalali-picker__dropdown-menu::-webkit-scrollbar {
  width: 5px;
}

.jalali-picker__dropdown-menu::-webkit-scrollbar-thumb {
  background: rgba(var(--ink-rgb), 0.18);
  border-radius: 999px;
}

.jalali-picker__nav {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(var(--ink-rgb), 0.1);
  border-radius: 8px;
  background: rgba(var(--ink-rgb), 0.04);
  color: rgba(var(--ink-rgb), 0.75);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.jalali-picker__nav:hover {
  border-color: rgba(var(--gold-rgb), 0.4);
  color: var(--gold-light);
}

.jalali-picker__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
  margin-bottom: 0.35rem;
}

.jalali-picker__weekdays span {
  text-align: center;
  font-size: 0.72rem;
  color: rgba(var(--ink-rgb), 0.4);
  padding: 0.15rem 0;
}

.jalali-picker__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
}

.jalali-picker__day {
  aspect-ratio: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(var(--ink-rgb), 0.85);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.jalali-picker__day:hover:not(.jalali-picker__day--empty) {
  background: rgba(var(--gold-rgb), 0.18);
  color: var(--gold-light);
}

.jalali-picker__day.is-selected {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--deep);
  font-weight: 700;
}

.jalali-picker__day--empty {
  pointer-events: none;
}

.auth-hint {
  font-size: 0.78rem;
  color: rgba(var(--ink-rgb), 0.4);
  text-align: center;
  line-height: 1.5;
}

.auth-error {
  font-size: 0.8rem;
  color: #ff6b6b;
  text-align: center;
  min-height: 0;
  margin: 0;
}

.auth-error:empty {
  display: none;
}

/* دکمه‌ها */
.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.75rem;
  border-radius: 999px;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.auth-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.auth-btn--primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--deep);
  width: 100%;
}

.auth-btn--primary:not(:disabled):hover {
  transform: scale(1.02);
  box-shadow: 0 0 28px rgba(var(--gold-rgb), 0.4);
}

.auth-btn--ghost {
  background: transparent;
  color: rgba(var(--ink-rgb), 0.7);
  border: 1px solid rgba(var(--ink-rgb), 0.15);
}

.auth-btn--ghost:not(:disabled):hover {
  border-color: rgba(var(--gold-rgb), 0.4);
  color: var(--gold-light);
}

.auth-btn--danger {
  background: rgba(255, 80, 80, 0.15);
  color: #ff8a8a;
  border: 1px solid rgba(255, 80, 80, 0.35);
  flex: 1;
}

.auth-btn--success {
  background: rgba(16, 232, 122, 0.15);
  color: var(--green);
  border: 1px solid rgba(16, 232, 122, 0.35);
  flex: 1;
}

.auth-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.auth-actions--row {
  flex-direction: row;
}

/* کد تایید — ۵ خانه */
.otp-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  direction: ltr;
}

.otp-cell {
  width: 2.75rem;
  height: 3rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid rgba(var(--ink-rgb), 0.12);
  background: rgba(var(--ink-rgb), 0.06);
  color: var(--fg);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.otp-cell:focus {
  outline: none;
  border-color: rgba(var(--gold-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--gold-rgb), 0.12);
}

/* پروفایل */
.profile-card {
  position: relative;
  z-index: 1;
  text-align: right;
  border-radius: 16px;
  border: 1px solid rgba(var(--ink-rgb), 0.1);
  background: rgba(var(--ink-rgb), 0.03);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.profile-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.06);
  font-size: 0.9rem;
}

.profile-card__row:last-child {
  border-bottom: none;
}

.profile-card__label {
  color: rgba(var(--ink-rgb), 0.5);
  flex-shrink: 0;
}

.profile-card__value {
  color: var(--fg);
  font-weight: 600;
  text-align: left;
}

.profile-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 0;
  color: rgba(var(--ink-rgb), 0.55);
  font-size: 0.9rem;
}

.profile-loading[hidden],
.profile-card[hidden],
.auth-actions[hidden] {
  display: none;
}

.profile-loading__spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(var(--gold-rgb), 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* انتخاب گروه — ۲×۲ */
.auth-groups {
  width: 100%;
  max-width: 420px;
}

.auth-groups .doors-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.auth-groups .door-card {
  width: auto;
  cursor: pointer;
  opacity: 1;
  transform: none;
}

.auth-groups .door-card.is-selected {
  transform: scale(1.04);
  box-shadow: 0 0 28px rgba(var(--gold-rgb), 0.35);
}

.auth-resend {
  background: none;
  border: none;
  color: rgba(var(--gold-rgb), 0.75);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s;
}

.auth-resend:hover:not(:disabled) {
  color: var(--gold-light);
}

.auth-resend:disabled {
  color: rgba(var(--ink-rgb), 0.3);
  cursor: default;
}

.auth-footer {
  margin-top: auto;
  width: 100%;
  flex-shrink: 0;
  text-align: center;
  padding: 1.5rem 0 calc(1.5rem + env(safe-area-inset-bottom, 0px));
  font-size: 0.72rem;
  color: rgba(var(--ink-rgb), 0.38);
  line-height: 1.8;
  border-top: none;
}

.auth-footer__copy,
.auth-footer__credit {
  margin: 0;
}

.auth-footer__credit {
  margin-top: 0.15rem;
}

.auth-footer a {
  color: rgba(var(--gold-rgb), 0.65);
  text-decoration: none;
}

.auth-footer a:hover {
  color: var(--gold);
}

@media (max-width: 768px) {
  .auth-main {
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  }

  .otp-cell {
    width: 2.4rem;
    height: 2.75rem;
    font-size: 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .profile-loading__spinner {
    animation: none;
    border-top-color: rgba(var(--gold-rgb), 0.5);
  }

  .auth-progress__fill {
    transition: none;
  }
}

html[data-theme="light"] .auth-bg img {
  filter: brightness(1.05) saturate(0.55) contrast(0.95);
  opacity: 0.35;
}

html[data-theme="light"] .auth-card {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .auth-input {
  background: #f8fafc;
  border-color: var(--border);
  color: var(--fg-strong);
}

html[data-theme="light"] .jalali-picker {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .jalali-picker__dropdown-menu {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
}

html[data-theme="light"] .otp-cell {
  background: #f8fafc;
  border-color: var(--border);
  color: var(--fg-strong);
}



html[data-theme="light"] .auth-btn--primary,
html[data-theme="light"] .jalali-picker__day.is-selected {
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 82%, #fff) 0%, var(--gold-bright) 45%, var(--gold-pale) 100%);
  color: var(--gold-deep);
  box-shadow: 0 2px 14px rgba(var(--gold-rgb), 0.35);
}
