/* ==========================================================================
   Нэвтрэх / бүртгүүлэх хуудасны загвар — auth.css
   ЭЗЭМШИГЧ: auth-ui
   Токенууд: styles.css-ийн :root-оос авна (--accent, --bg, --surface гэх мэт).
   Энд зөвхөн docs/UI-UX.md §2-т заасан нэмэлт төлөвийн өнгийг тодорхойлно.
   Энэ файлыг login.html-ээс гадна admin.html, account.html зэрэг хуудас бас
   импортлож ui-kit.js-ийн (toast, dialog, notice-info г.м.) загварыг авна.
   ========================================================================== */

:root {
  --warning: #b7791f;
  --warning-light: #fdf3e2;
  --info: #2c5282;
  --info-light: #e6effa;
}

/* --------------------------------------------------------------------------
   1. Нэвтрэх хуудасны байрлал
   -------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-7) var(--sp-6);
}

/* Нэвтрэх/бүртгүүлэх формын үндсэн товч — бүтэн өргөнтэй (хуруугаар дарахад
   хялбар, үйлдэл нь тодорхой). */
.auth-card .actions-end { justify-content: stretch; }
.auth-card .actions-end .btn-primary { width: 100%; padding-block: 13px; font-size: .95rem; }

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-header h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.7rem;
  letter-spacing: -.5px;
}

.auth-header p {
  color: var(--muted);
  font-size: .85rem;
  margin-top: 6px;
  font-weight: 300;
}

/* --------------------------------------------------------------------------
   1b. Хоёр багана: брэнд + форм (зөвхөн login.html — `auth-page--split`)
   reset.html зэрэг бусад хуудас нэг карттай хэвээр.
   -------------------------------------------------------------------------- */
.auth-brand { display: none; }

@media (min-width: 960px) {
  .auth-page--split {
    display: grid;
    grid-template-columns: minmax(380px, 1fr) minmax(400px, 460px);
    align-items: center;
    gap: var(--sp-8);
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--sp-7) var(--sp-6);
  }

  .auth-brand {
    /* Бүртгүүлэх маягт урт үед самбар өндөр болно — агуулгыг голлуулна. */
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    align-self: stretch;
    border-radius: var(--radius-lg);
    padding: var(--sp-7) var(--sp-6);
    color: #eef4ef;
    background:
      radial-gradient(120% 80% at 0% 0%, rgba(255, 255, 255, .10), transparent 55%),
      radial-gradient(90% 70% at 100% 100%, rgba(183, 121, 31, .22), transparent 60%),
      linear-gradient(160deg, #2d5a3d 0%, #1f4029 100%);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
  }

  /* Нарийн торон хээ — хавтгай ногоон биш, гүнтэй харагдана. */
  .auth-brand::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
      linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, .6), transparent 70%);
    pointer-events: none;
  }

  .auth-brand-inner { position: relative; z-index: 1; }

  .auth-page--split .auth-card { max-width: none; }
}

.auth-brand-eyebrow {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .3px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  margin-bottom: var(--sp-5);
}

.auth-brand-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: 400;
  font-size: 2.1rem;
  line-height: 1.15;
  letter-spacing: -.3px;
  color: #fff;
  margin-bottom: var(--sp-4);
}

.auth-brand-lead {
  font-size: .95rem;
  line-height: 1.7;
  color: rgba(238, 244, 239, .86);
  margin-bottom: var(--sp-6);
  max-width: 460px;
}

.auth-brand-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--sp-4);
}

.auth-brand-list li {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: var(--sp-3);
  align-items: start;
  font-size: .88rem;
  line-height: 1.6;
  color: rgba(238, 244, 239, .84);
}

.auth-brand-list strong { color: #fff; font-weight: 600; }

.auth-brand-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .16);
  font-size: 1.05rem;
}

/* --------------------------------------------------------------------------
   2. Таб (Нэвтрэх / Бүртгүүлэх)
   -------------------------------------------------------------------------- */
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 9px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.auth-tab:hover { color: var(--text); }

.auth-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.auth-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* --------------------------------------------------------------------------
   3. Нууц үг харах/нуух товч
   -------------------------------------------------------------------------- */
.password-field { position: relative; }

.password-field input { padding-right: 44px; }

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover { color: var(--text); background: var(--bg); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.password-toggle svg { width: 18px; height: 18px; }

/* --------------------------------------------------------------------------
   4. Нууц үгийн хүчний заагч
   -------------------------------------------------------------------------- */
.password-strength { margin-top: 8px; }

.strength-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  display: flex;
  gap: 3px;
}

.strength-track span {
  flex: 1;
  height: 100%;
  border-radius: 999px;
  background: var(--border);
  transition: background .2s;
}

.password-strength[data-level="weak"] .strength-track span:nth-child(1) { background: var(--danger); }

.password-strength[data-level="medium"] .strength-track span:nth-child(1),
.password-strength[data-level="medium"] .strength-track span:nth-child(2) { background: var(--warning); }

.password-strength[data-level="strong"] .strength-track span { background: var(--ok); }

.strength-label {
  display: block;
  font-size: .74rem;
  color: var(--muted);
  margin-top: 6px;
}

.password-strength[data-level="weak"] .strength-label { color: var(--danger); }
.password-strength[data-level="medium"] .strength-label { color: var(--warning); }
.password-strength[data-level="strong"] .strength-label { color: var(--ok); }

.strength-rules {
  list-style: none;
  margin-top: 8px;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: .76rem;
  color: var(--muted);
}

.strength-rules li { display: flex; align-items: center; gap: 6px; }

.strength-rules li::before {
  content: '✗';
  color: var(--danger);
  font-weight: 700;
  width: 14px;
  flex-shrink: 0;
}

.strength-rules li.met { color: var(--text); }
.strength-rules li.met::before { content: '✓'; color: var(--ok); }

/* --------------------------------------------------------------------------
   5. Заавал биш талбарын тэмдэглэгээ, туслах текст
   -------------------------------------------------------------------------- */
.field-optional {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--muted);
  font-size: .74rem;
}

.field-error {
  color: var(--danger);
  font-size: .76rem;
  margin-top: 6px;
  line-height: 1.5;
}

[aria-invalid="true"] { border-color: var(--danger) !important; }

/* --------------------------------------------------------------------------
   6. Доор нэмэлт холбоос, чекбокс мөр
   -------------------------------------------------------------------------- */
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-foot {
  text-align: center;
  margin-top: 20px;
  font-size: .8rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   7. Амжилт / тусгай төлөвийн дэлгэц (ACCOUNT_PENDING г.м.)
   -------------------------------------------------------------------------- */
.state-screen { text-align: center; padding: 12px 4px 4px; }

.state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.state-icon svg { width: 28px; height: 28px; }

.state-icon.state-ok { background: var(--accent-light); color: var(--accent); }
.state-icon.state-pending { background: var(--warning-light); color: var(--warning); }
.state-icon.state-suspended { background: #fdf0ef; color: var(--danger); }
.state-icon.state-expired { background: var(--info-light); color: var(--info); }

.state-screen h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.25rem;
  margin-bottom: 10px;
}

.state-screen p {
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.7;
  margin-bottom: 22px;
}

/* --------------------------------------------------------------------------
   8. Түр хугацааны хориглолтын тоолуур (TOO_MANY_ATTEMPTS)
   -------------------------------------------------------------------------- */
.retry-countdown {
  font-size: .8rem;
  color: var(--warning);
  margin-top: 8px;
}

/* ==========================================================================
   9. ui-kit.js-ийн бүрэлдэхүүн хэсгүүдийн загвар
   (login.html-ээс гадна admin.html, account.html-д бас ашиглагдана.)
   ========================================================================== */

/* Toast ─────────────────────────────────────────────────────────────────── */
.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  font-size: .85rem;
  color: var(--text);
  animation: toast-in .2s ease-out;
}

.toast-leaving { animation: toast-out .2s ease-in forwards; }

.toast-ok { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

/* Notice — info төлөв (error/warn/ok нь styles.css-д байгаа) ──────────────── */
.notice-info { color: var(--info); background: var(--info-light); border-color: #b9d3ea; }

/* Dialog ────────────────────────────────────────────────────────────────── */
dialog.ui-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  width: min(420px, calc(100vw - 32px));
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  /*
   * styles.css-ийн `* { margin: 0 }` нь браузерын `dialog { margin: auto }`-г
   * дардаг тул модал цонх дэлгэцийн зүүн дээд буланд наалддаг байв.
   * `margin: auto` + `max-height` нь цонхыг голлуулж, урт агуулгатай үед
   * дотроо гүйдэг болгоно.
   */
  margin: auto;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

dialog.ui-dialog::backdrop {
  background: rgba(26, 25, 23, .45);
}

.ui-dialog-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.ui-dialog-message {
  font-size: .875rem;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 16px;
}

.ui-dialog-body { margin-bottom: 16px; }

.ui-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* Аюултай товч (styles.css-д .btn-primary/.btn-secondary/.btn-outline байгаа) */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a53125; }

/* --------------------------------------------------------------------------
   10. Гар утас
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .auth-card { padding: 26px 20px; }
  .auth-header h1 { font-size: 1.4rem; }
}

@media (max-width: 360px) {
  .auth-card { padding: 20px 14px; }
}

/* --------------------------------------------------------------------------
   11. Хөдөлгөөн багасгах тохиргоо
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast-leaving { animation: none; }
}

/* Туршилтын санал — эерэг санал тул брэндийн ногоон өнгөөр (мэдээллийн цэнхэр биш). */
.trial-offer {
  background: var(--accent-light);
  border: 1px solid #cfe0d4;
  border-left: 3px solid var(--accent);
  color: var(--text);
}
.trial-offer strong { color: var(--accent); }

/* Утсан дээр нүдний дүрсэн товч 32×32 байсан — хуруугаар дарахад жижиг. */
@media (max-width: 640px) {
  .password-toggle {
    width: 44px;
    height: 44px;
  }
}
