/* ─────────────────────────────────────────────────────────────
   CMEX.ai — auth.css. Стили страницы /auth/login.
   Дизайн: data/_disign/auth.jsx. Все цвета — через var(--*) из base.css.
   Иконки — через currentColor (inline stroke="var()" ломает Safari/iPad).
   ───────────────────────────────────────────────────────────── */

.auth-body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Десктоп ограничен 1440 по центру — как .h-container на главной.
   Шапка и обе колонки внутри .auth, поэтому всё центрируется вместе.
   На <1024 — на всю ширину (правило не действует). */
@media (min-width: 1024px) {
  .auth {
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
  }
}

/* ── Минимальная шапка ──────────────────────────────────────── */
.auth-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
  padding: 0 24px;
  flex-shrink: 0;
}

.auth-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  line-height: 1;
}
.auth-logo .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  transform: translateY(-1px);
}
.auth-logo .ai { color: var(--accent); font-weight: 700; }

.auth-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Иконочные кнопки шапки — цвет через currentColor */
.auth-theme,
.auth-nav-close,
.auth-back,
.auth-link-back,
.auth-hint { color: var(--icon-stroke); }
.auth-theme svg,
.auth-nav-close svg,
.auth-back svg,
.auth-link-back svg,
.auth-hint svg { stroke: currentColor; }

.auth-theme {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.auth-theme svg { width: 20px; height: 20px; }

/* Показываем одну иконку темы в зависимости от data-theme */
:root[data-theme="light"] .auth-theme .icon-sun  { display: none; }
:root[data-theme="dark"]  .auth-theme .icon-moon { display: none; }

.auth-nav-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--divider);
  background: transparent;
  display: none; /* только мобильный режим */
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.auth-nav-close svg { width: 18px; height: 18px; }

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.auth-back svg { width: 16px; height: 16px; }

/* Переключатель языка (RU/EN) — пилюля как .nav-lang на главной */
.auth-lang {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--divider);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  cursor: pointer;
  font-family: inherit;
}
.auth-lang svg { width: 12px; height: 12px; stroke: currentColor; }

/* ── Колонки ────────────────────────────────────────────────── */
.auth-cols {
  flex: 1;
  display: flex;
}

.auth-form-col {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-inner {
  width: 100%;
  max-width: 420px;
}

/* ── State machine: видимость шагов ─────────────────────────── */
.auth-step { display: none; }
.auth[data-step="phone"]    .auth-step--phone    { display: block; }
.auth[data-step="code"]     .auth-step--code     { display: block; }
.auth[data-step="age"]      .auth-step--age      { display: block; }
.auth[data-step="password"] .auth-step--password { display: block; }
.auth[data-step="welcome"]  .auth-step--welcome  { display: block; }
.auth[data-step="twofa"]    .auth-step--twofa    { display: block; }

/* Гейт шага PASSWORD: пароль обязателен — прячем способы «сбежать» из шапки
   (крестик, «На главную»), лого обездвиживаем. Сессия в PHP не смостится до
   установки пароля, так что ручной переход на / тоже отдаст гостя. */
.auth[data-step="password"] .auth-nav-close,
.auth[data-step="password"] .auth-back { display: none; }
.auth[data-step="password"] .auth-logo { pointer-events: none; }

/* ── Типографика ────────────────────────────────────────────── */
.auth-head { margin-bottom: 24px; }
.auth-title {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}
.auth-sub {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}
.auth-sent-to {
  color: var(--text);
  font-family: ui-monospace, Menlo, monospace;
}

/* ── Табы метода (код / пароль) ─────────────────────────────── */
.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--divider);
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  height: 40px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.auth[data-method="code"]     .auth-tab[data-method-btn="code"],
.auth[data-method="password"] .auth-tab[data-method-btn="password"] {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ── Поля формы ─────────────────────────────────────────────── */
.auth-label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.auth-field {
  height: 56px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--divider);
  display: flex;
  align-items: center;
  padding: 0 16px;
  transition: border-color 0.15s;
}
.auth-field:focus-within { border-color: var(--accent); }
.auth-input {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.auth-input::placeholder { color: var(--text-dim); }

/* Подпись-хинт под полем (шаг установки пароля) */
.auth-field-hint {
  margin: 7px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.auth-step--password .auth-label { margin-top: 16px; }
.auth-step--password .auth-form > .auth-label:first-of-type { margin-top: 0; }

/* Пароль виден только в методе «с паролем» */
.auth-pass-row { display: none; margin-top: 14px; }
.auth[data-method="password"] .auth-pass-row { display: block; }

/* ── Кнопки ─────────────────────────────────────────────────── */
.auth-btn {
  width: 100%;
  height: 54px;
  border-radius: 14px;
  border: none;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.auth-btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 33%, transparent);
  margin-top: 16px;
}
.auth-btn--primary:disabled {
  background: var(--divider);
  color: var(--text-dim);
  box-shadow: none;
  cursor: not-allowed;
}

/* Текст primary-кнопки на шаге phone зависит от метода */
.auth-btn-label-pass { display: none; }
.auth[data-method="password"] .auth-btn-label-code { display: none; }
.auth[data-method="password"] .auth-btn-label-pass { display: inline; }

/* ── Age-gate 18+ чекбокс ───────────────────────────────────── */
.auth-18 {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  cursor: pointer;
  user-select: none;
}
.auth-18 input { position: absolute; opacity: 0; width: 0; height: 0; }
.auth-18-box {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1.6px solid var(--divider);
  border-radius: 6px;
  background: var(--bg-elevated);
  transition: border-color .15s, background .15s;
  position: relative;
}
.auth-18 input:checked + .auth-18-box {
  background: var(--accent);
  border-color: var(--accent);
}
.auth-18 input:checked + .auth-18-box::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2.2px 2.2px 0;
  transform: rotate(45deg);
}
.auth-18 input:focus-visible + .auth-18-box {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.auth-18-text { display: flex; flex-direction: column; gap: 2px; }
.auth-18-text b { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3; }
.auth-18-hint { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* ── Разделитель ИЛИ ────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--divider);
}
.auth-divider span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Соцкнопки ──────────────────────────────────────────────── */
.auth-social {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.auth-btn--social {
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--divider);
  font-size: 14px;
  font-weight: 700;
}
/* Google — тот же стиль, что у Apple (фон elevated + рамка), но активная */
.auth-btn--google {
  background: var(--bg-elevated);
  color: var(--text);
}
.auth-btn--apple {
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: not-allowed;
  position: relative;
}
.auth-soon {
  position: absolute;
  right: 12px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--divider);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── Текст про соглашение ───────────────────────────────────── */
.auth-terms {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  margin: 0;
}
.auth-terms a { color: var(--accent); text-decoration: none; }

/* ── Ошибки ─────────────────────────────────────────────────── */
.auth-error {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.auth-error.is-visible { display: block; }

/* ── Шаг кода: «изменить контакт» ───────────────────────────── */
.auth-link-back {
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  margin-bottom: 18px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
}
.auth-link-back svg { width: 14px; height: 14px; }

/* ── Клетки кода ────────────────────────────────────────────── */
.auth-cells {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.auth-cell {
  width: 60px;
  height: 68px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--divider);
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  font-family: ui-monospace, Menlo, monospace;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.auth-cell:focus { border-color: var(--accent); }
.auth-cell.is-filled {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Ресенд ─────────────────────────────────────────────────── */
.auth-resend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}
.auth-resend-q { font-size: 13px; color: var(--text-muted); }
.auth-resend-timer {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  font-family: ui-monospace, Menlo, monospace;
}
.auth-resend-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-family: inherit;
  padding: 0;
}

/* ── Подсказка про одноразовый код ──────────────────────────── */
.auth-hint {
  margin-top: 24px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px dashed var(--divider);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}
.auth-hint svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

/* ── Шаг welcome ────────────────────────────────────────────── */
.auth-check {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: color-mix(in srgb, #1F8A5B 18%, transparent);
  color: #1F8A5B;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.auth-check svg { width: 28px; height: 28px; stroke: currentColor; }

.auth-roles {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.auth-role {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.auth-role.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.auth-role input { position: absolute; opacity: 0; pointer-events: none; }
.auth-role-radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--divider);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-role.is-active .auth-role-radio {
  border-color: var(--accent);
  background: var(--accent);
}
.auth-role.is-active .auth-role-radio::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}
.auth-role-text { flex: 1; }
.auth-role-title { display: block; font-size: 14px; font-weight: 800; color: var(--text); }
.auth-role.is-active .auth-role-title { color: var(--accent); }
.auth-role-sub { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }

/* ── Правый navy-баннер (десктоп) ───────────────────────────── */
.auth-banner {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  /* Баннер всегда тёмный (не зависит от темы): navy + лёгкая подсветка */
  background:
    linear-gradient(135deg, rgba(255,255,255,0) 40%, rgba(255,255,255,0.06) 100%),
    linear-gradient(135deg, var(--navy) 0%, color-mix(in srgb, var(--navy) 70%, #2A3F7A) 100%);
}
.auth-banner-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.auth-banner-glow--1 {
  right: -150px;
  top: -150px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 40%, transparent) 0%, transparent 70%);
}
.auth-banner-glow--2 {
  left: -100px;
  bottom: -100px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 20%, transparent) 0%, transparent 70%);
}
.auth-banner-inner {
  position: relative;
  max-width: 420px;
  color: #fff;
}
.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.auth-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.auth-banner-title {
  margin: 0;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.auth-banner-text {
  margin: 18px 0 28px;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.5;
}
.auth-banner-stats { display: flex; gap: 32px; }
.auth-banner-stats b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.auth-banner-stats span { font-size: 11px; color: rgba(255, 255, 255, 0.55); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════
   БРЕЙКПОИНТЫ
   ═══════════════════════════════════════════════════════════════ */

/* < 1024px — одна колонка, баннер скрыт, мобильная шапка */
@media (max-width: 1023px) {
  .auth-banner { display: none; }
  .auth-back   { display: none; }
  .auth-nav-close { display: inline-flex; }
  .auth-nav { justify-content: space-between; }
  .auth-form-col { align-items: flex-start; padding: 8px 24px 40px; }
}

/* 768–1023px — планшет: те же блоки, но крупнее */
@media (min-width: 768px) and (max-width: 1023px) {
  .auth-inner { max-width: 460px; }
  .auth-title { font-size: 34px; }
  .auth-form-col { padding-top: 24px; }
}

/* < 768px — мобильный: компактнее */
@media (max-width: 767px) {
  .auth-title { font-size: 28px; }
  .auth-cell { width: 56px; height: 64px; font-size: 26px; }
}

/* очень узкие экраны — клетки не должны вылезать */
@media (max-width: 360px) {
  .auth-cells { gap: 8px; }
  .auth-cell { width: 100%; max-width: 64px; }
}
