/* ==========================================================================
   auth.css — صفحهٔ ورود کاربران پایانی (رمز / کد یک‌بارمصرف / ثبت‌نام)
   --------------------------------------------------------------------------
   فقط از توکن‌های رنگ و فاصلهٔ app.css استفاده می‌کند تا تم روشن، تم تاریک،
   RTL و حالت موبایل خودبه‌خود هماهنگ بمانند. این فایل فقط در login.html و
   پس از app.css بارگذاری می‌شود؛ بدون کتابخانه، فونت بیرونی یا استایل درون‌خطی
   (سازگار با CSP). چیدمان با inset-inline/safe-area نوشته شده تا در RTL و
   گوشی‌های دارای بریدگی درست بماند.
   ========================================================================== */

/* ==================================================== ۱) پوستهٔ صفحه */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 100dvh;
  padding: calc(58px + env(safe-area-inset-top, 0px)) 18px
    calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}

/* پس‌زمینهٔ نرم و نورانی؛ فقط تزئینی است و چیزی را مسدود نمی‌کند */
.auth-deco {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: .55;
  will-change: transform;
}

.auth-orb--1 {
  width: 420px;
  height: 420px;
  inset-block-start: -140px;
  inset-inline-end: -120px;
  background: radial-gradient(circle at 50% 50%, rgba(91, 84, 240, .38), rgba(91, 84, 240, 0) 70%);
  animation: auth-drift 18s ease-in-out infinite alternate;
}

.auth-orb--2 {
  width: 360px;
  height: 360px;
  inset-block-end: -130px;
  inset-inline-start: -110px;
  background: radial-gradient(circle at 50% 50%, rgba(14, 165, 233, .30), rgba(14, 165, 233, 0) 70%);
  animation: auth-drift 22s ease-in-out infinite alternate-reverse;
}

.auth-orb--3 {
  width: 240px;
  height: 240px;
  inset-block-start: 46%;
  inset-inline-start: 54%;
  background: radial-gradient(circle at 50% 50%, rgba(236, 72, 153, .18), rgba(236, 72, 153, 0) 70%);
}

[data-theme="dark"] .auth-orb {
  opacity: .4;
}

[data-theme="dark"] .auth-orb--1 {
  background: radial-gradient(circle at 50% 50%, rgba(124, 123, 255, .34), rgba(124, 123, 255, 0) 70%);
}

[data-theme="dark"] .auth-orb--2 {
  background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, .22), rgba(56, 189, 248, 0) 70%);
}

[data-theme="dark"] .auth-orb--3 {
  background: radial-gradient(circle at 50% 50%, rgba(244, 114, 182, .16), rgba(244, 114, 182, 0) 70%);
}

/* ============================================== ۲) دکمهٔ تغییر پوسته */
.auth-theme {
  position: fixed;
  inset-block-start: calc(12px + env(safe-area-inset-top, 0px));
  inset-inline-end: 14px;
  z-index: 20;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text-dim);
  font-size: 16px;
  transition: transform .16s ease, border-color .16s ease, color .16s ease;
}

.auth-theme:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--accent);
}

/* ==================================================== ۳) کارت اصلی */
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 452px;
  min-width: 0;
  margin-block: auto;
  padding: 34px 32px 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background-color: var(--surface);
  background-image: radial-gradient(540px 240px at 50% 0%, var(--accent-soft), transparent 74%);
  box-shadow: var(--shadow-lg);
  animation: auth-card-in .38s cubic-bezier(.22, 1, .36, 1);
}

/* نوار رنگی باریک بالای کارت */
.auth-card::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 4px;
  background: var(--accent-grad);
}

/* جلای متحرک نوار بالا، فقط هنگام بررسی نشست */
.auth-card::after {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 4px;
  opacity: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
}

.auth-card[aria-busy="true"]::after {
  opacity: 1;
  animation: auth-sheen 1.15s ease-in-out infinite;
}

.auth-card[aria-busy="true"] .auth-tabs,
.auth-card[aria-busy="true"] .auth-panels {
  opacity: .55;
}

.auth-tabs,
.auth-panels {
  transition: opacity .2s ease;
}

[data-theme="dark"] .auth-card {
  background-image: radial-gradient(540px 240px at 50% 0%, rgba(124, 123, 255, .14), transparent 74%);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .58);
}

/* ========================================== ۴) سرصفحه، لوگو و عنوان */
.auth-head {
  margin-bottom: 20px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
  text-align: center;
}

.auth-logo {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-grad);
  box-shadow: 0 14px 30px rgba(79, 70, 229, .32), inset 0 1px 0 rgba(255, 255, 255, .35);
  color: #fff;
  font-family: var(--font-emoji);
  font-size: 30px;
  line-height: 1;
}

[data-theme="dark"] .auth-logo {
  box-shadow: 0 14px 32px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .18);
}

.auth-brand-text {
  min-width: 0;
  max-width: 100%;
}

.auth-title {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: -.2px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.auth-sub {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

/* ==================================================== ۵) تب‌های داخلی */
.auth-tabs {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

/* نشانگر متحرک تب فعال؛ با data-active جابه‌جا می‌شود (بدون استایل درون‌خطی) */
.auth-tabs::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset-block: 4px;
  inset-inline-start: 4px;
  width: calc((100% - 8px) / 3);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: transform .24s cubic-bezier(.22, 1, .36, 1);
}

.auth-tabs[data-active="code"]::before {
  transform: translateX(-100%);
}

.auth-tabs[data-active="signup"]::before {
  transform: translateX(-200%);
}

[data-theme="dark"] .auth-tabs::before {
  background: var(--accent-soft);
  border-color: transparent;
}

.auth-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 9px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: clamp(11.5px, 3.3vw, 13px);
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
  transition: color .16s ease;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab[aria-selected="true"] {
  color: var(--accent);
  font-weight: 700;
}

.auth-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.auth-tab-ico {
  flex: 0 0 auto;
  font-family: var(--font-emoji);
  font-size: 13px;
  line-height: 1;
}

.auth-tab-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ======================================================== ۶) خطا */
.auth-error {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 14px;
  padding: 10px 13px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.85;
  overflow-wrap: anywhere;
  animation: auth-fade-up .18s ease;
}

.auth-error::before {
  content: "⚠";
  flex: 0 0 auto;
  font-family: var(--font-emoji);
  line-height: 1.7;
}

/* ==================================================== ۷) فرم و فیلدها */
.auth-panels {
  position: relative;
}

.auth-panel {
  min-width: 0;
  animation: auth-fade-up .22s ease;
}

.auth-panel[hidden] {
  display: none;
}

.auth-form {
  display: block;
}

.auth-form .field {
  margin-bottom: 15px;
}

.auth-form .label {
  margin-bottom: 6px;
  font-size: 12.5px;
}

.auth-optional {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-faint);
}

/* قاب ورودی؛ آیکون در آغاز منطقی (راست در RTL) می‌نشیند */
.auth-control {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.auth-input {
  min-width: 0;
}

.auth-control .auth-input {
  padding-inline-start: 42px;
}

.auth-control .auth-input--pass {
  padding-inline-end: 46px;
}

.auth-ico {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 13px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--text-faint);
  font-family: var(--font-emoji);
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
  transition: color .15s ease;
}

.auth-control:focus-within .auth-ico {
  color: var(--accent);
}

/* دکمهٔ نمایش/پنهان‌کردن رمز */
.auth-reveal {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: 6px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font-emoji);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}

.auth-reveal:hover {
  background: var(--surface-3);
  color: var(--text);
}

.auth-reveal[aria-pressed="true"] {
  color: var(--accent);
}

.auth-reveal:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ورودی کد یک‌بارمصرف: درشت، وسط‌چین و با فاصلهٔ نویسه‌ها */
.auth-code {
  padding: 13px 16px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: .22em;
  text-align: center;
  text-transform: uppercase;
}

/* ================================================ ۸) دکمهٔ ارسال */
.auth-submit {
  gap: 8px;
  min-height: 48px;
  margin-top: 4px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.6;
}

.auth-submit[aria-busy="true"]:disabled {
  opacity: .82;
}

.auth-btn-label {
  display: inline-block;
}

.auth-spinner {
  display: none;
  width: 17px;
  height: 17px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: auth-spin .7s linear infinite;
}

.auth-submit[aria-busy="true"] .auth-spinner {
  display: inline-block;
}

.auth-submit[aria-busy="true"] .auth-btn-label {
  opacity: .92;
}

/* پیوندهای جابه‌جایی بین تب‌ها، زیر هر فرم */
.auth-alt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 14px;
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--text-faint);
  text-align: center;
}

.auth-link {
  padding: 2px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.9;
  text-decoration: none;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}

.auth-link:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.auth-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ==================================================== ۹) پانویس */
.auth-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--text-faint);
  text-align: center;
}

.auth-note {
  margin-bottom: 4px;
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
}

.auth-back:hover {
  color: var(--accent);
  text-decoration: none;
}

.auth-privacy {
  position: relative;
  z-index: 1;
  max-width: 420px;
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--text-faint);
  text-align: center;
  overflow-wrap: anywhere;
}

/* ==================================================== ۱۰) پویانمایی */
@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to { opacity: 1; transform: none; }
}

@keyframes auth-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

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

@keyframes auth-sheen {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes auth-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-16px, 20px, 0) scale(1.05); }
}

/* ==================================================== ۱۱) موبایل */
@media (max-width: 520px) {
  .auth-page {
    gap: 12px;
    padding: calc(50px + env(safe-area-inset-top, 0px)) 12px
      calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .auth-card {
    padding: 27px 20px 22px;
    border-radius: 18px;
  }

  .auth-logo {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    font-size: 26px;
  }

  .auth-title {
    font-size: 19px;
  }

  .auth-sub {
    font-size: 12.5px;
  }

  .auth-tabs {
    margin-bottom: 16px;
  }

  .auth-tab {
    gap: 3px;
    padding: 8px 4px;
  }

  .auth-theme {
    inset-block-start: calc(10px + env(safe-area-inset-top, 0px));
    inset-inline-end: 12px;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }
}

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

  .auth-tab {
    font-size: 11px;
  }

  .auth-tab-ico {
    font-size: 12px;
  }

  .auth-code {
    font-size: 16px;
    letter-spacing: .18em;
  }
}

/* ============================================ ۱۲) کاهش انیمیشن */
@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .auth-panel,
  .auth-error {
    animation: none;
  }

  .auth-orb {
    animation: none;
  }

  .auth-card[aria-busy="true"]::after {
    animation: none;
    opacity: .55;
  }

  .auth-tabs::before,
  .auth-tabs,
  .auth-panels,
  .auth-tab,
  .auth-theme,
  .auth-reveal,
  .auth-link {
    transition: none;
  }
}
