/*
 * skin/default/auth.css
 * หน้าเข้าสู่ระบบ / ยืนยันตัวตนสองชั้น / ลืมรหัสผ่าน / ตั้งรหัสผ่านใหม่
 * ใช้โทนสีและฟอนต์เดียวกับระบบหลัก (style.css) แต่แยกไฟล์เพื่อให้หน้าเข้าสู่ระบบเบาและไม่ชนกับสไตล์เดิม
 */
:root {
  --font: "IBM Plex Sans Thai", "Prompt", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  --bg: #f1f4f9;
  --bg-accent: #dbe7fb;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --line: #e1e6ef;
  --line-strong: #9aa7bb;
  --ink: #142036;
  --ink-2: #26324a;
  --muted: #4a5568;
  --primary: #1e3a8a;
  --primary-hover: #172e70;
  --primary-soft: #eaf0fd;
  --primary-ring: rgba(29, 78, 216, .22);
  --link: #1d4ed8;
  --on-primary: #ffffff;
  --success: #15803d;
  --success-soft: #e8f6ee;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --warning: #b45309;
  --info-soft: #eaf0fd;
  --input-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1.125rem 3rem -1.125rem rgba(16, 24, 40, .22);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0b1220;
  --bg-accent: #14234a;
  --surface: #121b2d;
  --surface-2: #172238;
  --line: #24314d;
  --line-strong: #4f6286;
  --ink: #e6ebf4;
  --ink-2: #c3cddd;
  --muted: #b3bfd3;
  --primary: #3b6fe0;
  --primary-hover: #5583ea;
  --primary-soft: #1a2747;
  --primary-ring: rgba(143, 177, 255, .3);
  --link: #8fb1ff;
  --success: #4ade80;
  --success-soft: #11291c;
  --danger: #f87171;
  --danger-soft: #2c1517;
  --warning: #fbbf24;
  --info-soft: #1a2747;
  --input-bg: #0e1626;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1.5rem 3.5rem -1.5rem rgba(0, 0, 0, .8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
/* ขนาดตัวอักษรพื้นฐาน: ทุกขนาดในหน้านี้เป็นหน่วย rem จึงขยายตามทั้งหมด
   ใช้ค่า meet_fontsize ร่วมกับระบบหลัก (sm / md / lg / xl) */
html { font-size: 1.25rem; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-fontsize="sm"] { font-size: 1.125rem; }
html[data-fontsize="md"] { font-size: 1.25rem; }
html[data-fontsize="lg"] { font-size: 1.438rem; }
html[data-fontsize="xl"] { font-size: 1.625rem; }
body.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(68.75rem 32.5rem at 50% -11.25rem, var(--bg-accent), transparent 70%),
    var(--bg);
  font: 400 1rem/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
}
.auth-page a { color: var(--link); text-decoration: none; }
.auth-page a:hover { text-decoration: underline; }
.auth-page svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.auth-page [hidden], .auth-page .hidden { display: none !important; }

/* ---------- Layout ---------- */
.auth-shell {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4.5rem 1rem 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 32rem;
  padding: 2rem 2rem 1.625rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: auth-in .35s ease-out both;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Brand ---------- */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.375rem;
  border-bottom: 1px solid var(--line);
}
.auth-brand img { width: 3.25rem; height: 3.25rem; object-fit: contain; flex: none; }
.auth-brand__icon {
  display: grid; place-items: center; flex: none;
  width: 3rem; height: 3rem; border-radius: 0.875rem;
  color: var(--primary); background: var(--primary-soft);
}
.auth-brand__icon svg { width: 1.625rem; height: 1.625rem; }
.auth-brand__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.auth-brand__text strong { color: var(--ink); font-size: 1.02rem; font-weight: 600; }
.auth-brand__text span { color: var(--muted); font-size: .92rem; }

/* ---------- Progress (ขั้นตอน 1 → 2) ---------- */
.auth-progress {
  display: flex;
  gap: 8px;
  margin: 0 0 1.375rem;
  padding: 0;
  list-style: none;
  counter-reset: none;
}
.auth-progress li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 0.625rem;
  border-top: 3px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}
.auth-progress li span {
  display: grid; place-items: center; flex: none;
  width: 1.375rem; height: 1.375rem; border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  font-size: .82rem; font-weight: 600;
}
.auth-progress li span svg { width: 13px; height: 13px; stroke-width: 2.6; }
.auth-progress li.is-current { border-color: var(--primary); color: var(--ink); }
.auth-progress li.is-current span { border-color: var(--primary); color: var(--on-primary); background: var(--primary); }
.auth-progress li.is-done { border-color: var(--success); color: var(--ink-2); }
.auth-progress li.is-done span { border-color: var(--success); color: #fff; background: var(--success); }

/* ---------- Heading ---------- */
.auth-form { margin: 0; }
.auth-heading { margin-bottom: 1.25rem; }
.auth-heading h1 { margin: 0 0 4px; color: var(--ink); font-size: 1.6rem; line-height: 1.35; font-weight: 600; letter-spacing: 0; }
.auth-heading p { margin: 0; color: var(--ink-2); font-size: 1rem; }
.auth-heading__badge {
  display: grid; place-items: center;
  width: 3rem; height: 3rem; margin-bottom: 0.875rem; border-radius: 0.875rem;
  color: var(--primary); background: var(--primary-soft);
}
.auth-heading__badge svg { width: 1.625rem; height: 1.625rem; }

/* ---------- Alerts ---------- */
.auth-alert {
  margin: 0 0 1.125rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid transparent;
  border-left-width: 4px;
  border-radius: 0.625rem;
  font-size: .92rem;
  line-height: 1.55;
}
.auth-alert:empty { display: none; }
.auth-alert.is-error, .auth-alert.error { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.auth-alert.is-info, .auth-alert.message { color: var(--ink-2); border-color: var(--primary); background: var(--info-soft); }
.auth-alert.is-success { color: var(--success); border-color: var(--success); background: var(--success-soft); }

/* ---------- Fields ---------- */
.auth-field { margin-bottom: 1rem; }
.auth-field > label { display: block; margin-bottom: 6px; color: var(--ink-2); font-size: .9rem; font-weight: 500; }
.auth-input { position: relative; display: flex; align-items: center; }
.auth-input__icon {
  position: absolute; left: 0.875rem; top: 50%;
  width: 1.25rem; height: 1.25rem; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.auth-input input {
  width: 100%;
  height: 3.25rem;
  margin: 0;
  padding: 0 0.875rem 0 2.9rem;
  border: 2px solid var(--line-strong);
  border-radius: 0.75rem;
  color: var(--ink);
  background: var(--input-bg);
  font: 400 1.05rem/1.4 var(--font);
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.auth-input input::placeholder { color: var(--muted); opacity: 1; }
.auth-input input:hover { border-color: var(--muted); }
.auth-input input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.auth-page a:focus-visible, .auth-page button:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.auth-input input:focus + .auth-input__toggle, .auth-input:focus-within .auth-input__icon { color: var(--primary); }
.auth-input input:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: 0 0 0 40px var(--input-bg) inset; }
.auth-input input.invalid, .auth-input input[aria-invalid="true"] { border-color: var(--danger); }
.auth-input input.invalid:focus, .auth-input input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(198, 40, 40, .16); }
.auth-input:has(.auth-input__toggle) input { padding-right: 3rem; }
.auth-input__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 2.375rem; height: 2.375rem; padding: 0;
  border: 0; border-radius: 0.562rem;
  color: var(--muted); background: transparent; cursor: pointer;
}
.auth-input__toggle:hover { color: var(--ink); background: var(--surface-2); }
.auth-input__toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.auth-input__toggle svg { width: 1.25rem; height: 1.25rem; }
.auth-input__toggle .i-hide, .auth-input__toggle[aria-pressed="true"] .i-show { display: none; }
.auth-input__toggle[aria-pressed="true"] .i-hide { display: block; }

.auth-error { margin: 6px 0 0; color: var(--danger); font-size: .92rem; line-height: 1.5; }
.auth-error:empty { display: none; }
.auth-hint { margin: 6px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.auth-hint--warn { color: var(--warning); font-weight: 500; }
.auth-hint b { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.auth-timer.is-low b { color: var(--danger); }

/* ---------- OTP 6 ช่อง (input จริงซ้อนอยู่ด้านบน เพื่อรองรับวาง/เติมอัตโนมัติ) ---------- */
.auth-otp { position: relative; }
.auth-otp input {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%; margin: 0; padding: 0;
  border: 0; outline: 0; opacity: 0;
  font-size: 1rem; /* ป้องกัน iOS ซูมหน้าจอ */
  cursor: text;
}
.auth-otp__cells { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.auth-otp__cells span {
  display: grid; place-items: center;
  height: 3.5rem;
  border: 2px solid var(--line-strong);
  border-radius: 0.75rem;
  color: var(--ink);
  background: var(--input-bg);
  font: 600 1.5rem/1 var(--font);
  font-variant-numeric: tabular-nums;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-otp__cells span:nth-child(3) { margin-right: 6px; }
.auth-otp__cells span:nth-child(4) { margin-left: 6px; }
.auth-otp.is-focus .auth-otp__cells span.is-active { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.auth-otp.is-focus .auth-otp__cells span.is-active:empty::after {
  content: ""; width: 2px; height: 1.625rem; background: var(--primary);
  animation: auth-caret 1s steps(1) infinite;
}
.auth-otp.is-invalid .auth-otp__cells span { border-color: var(--danger); }
.auth-otp.is-shake { animation: auth-shake .35s ease; }
@keyframes auth-caret { 50% { opacity: 0; } }
@keyframes auth-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* ---------- MFA: บัญชี + การตั้งค่าครั้งแรก ---------- */
.auth-account {
  display: flex; align-items: center; gap: 8px;
  margin: -4px 0 1.125rem; padding: 0.625rem 0.75rem;
  border: 1px solid var(--line); border-radius: 0.75rem;
  color: var(--muted); background: var(--surface-2);
  font-size: .9rem;
}
.auth-account svg { width: 1.125rem; height: 1.125rem; flex: none; }
.auth-account strong { min-width: 0; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.auth-steps-list { margin: 0 0 1rem; padding: 0; list-style: none; counter-reset: s; }
.auth-steps-list li {
  position: relative; counter-increment: s;
  margin-bottom: 8px; padding-left: 2.125rem;
  color: var(--ink-2); font-size: .9rem; line-height: 1.55;
}
.auth-steps-list li::before {
  content: counter(s);
  position: absolute; left: 0; top: 0;
  display: grid; place-items: center;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  color: var(--primary); background: var(--primary-soft);
  font-size: .85rem; font-weight: 600;
}
.auth-steps-list b { color: var(--ink); font-weight: 600; }
.auth-qr {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.125rem; padding: 0.875rem;
  border: 1px solid var(--line); border-radius: 0.875rem;
  background: var(--surface-2);
}
.auth-qr img {
  flex: none; width: 9.25rem; height: 9.25rem; padding: 8px;
  border: 1px solid var(--line); border-radius: 0.625rem;
  background: #fff; image-rendering: pixelated;
}
.auth-secret { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.auth-secret span { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.auth-secret code {
  display: block; padding: 8px 0.625rem;
  border: 1px dashed var(--line-strong); border-radius: 8px;
  color: var(--ink); background: var(--input-bg);
  font: 600 .86rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .06em; overflow-wrap: anywhere; user-select: all;
}
.auth-copy {
  align-self: flex-start;
  padding: 5px 0.75rem; border: 1px solid var(--line-strong); border-radius: 8px;
  color: var(--ink-2); background: var(--surface); cursor: pointer;
  font: 500 .82rem/1.4 var(--font);
}
.auth-copy:hover { border-color: var(--primary); color: var(--primary); }
.auth-copy.is-done { border-color: var(--success); color: var(--success); }

/* ---------- Buttons ---------- */
.auth-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 0.625rem;
  width: 100%; min-height: 3.4rem; margin: 0.6rem 0 0; padding: 0 1.125rem;
  border: 1px solid transparent; border-radius: 0.75rem;
  color: var(--on-primary) !important; background: var(--primary);
  font: 600 1.1rem/1.3 var(--font);
  text-decoration: none !important;
  cursor: pointer;
  box-shadow: 0 8px 20px -10px rgba(30, 58, 138, .6);
  transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.auth-btn:hover { background: var(--primary-hover); }
.auth-btn:active { transform: translateY(1px); }
.auth-btn:focus-visible { outline: 0; box-shadow: 0 0 0 4px var(--primary-ring); }
.auth-btn[disabled] { cursor: progress; opacity: .85; }
.auth-btn--ghost { color: var(--ink) !important; border-color: var(--line-strong); background: var(--surface); box-shadow: none; }
.auth-btn--ghost:hover { background: var(--surface-2); }
.auth-btn__spinner {
  display: none; width: 1.125rem; height: 1.125rem;
  border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%;
  animation: auth-spin .8s linear infinite;
}
.auth-btn.is-busy .auth-btn__spinner { display: block; }
.auth-btn.is-success { background: var(--success); }
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ---------- Links / notes ---------- */
.auth-links {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 0.625rem;
  margin-top: 1rem; color: var(--muted); font-size: .9rem;
}
.auth-links:empty { display: none; }
.auth-links a { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.auth-links svg { width: 1rem; height: 1rem; }
.auth-note {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 1.25rem 0 0; padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: .9rem; line-height: 1.5;
}
.auth-note svg { width: 1.125rem; height: 1.125rem; flex: none; margin-top: 1px; color: var(--success); }

/* ---------- แถบเครื่องมือ: ขนาดตัวอักษร + ธีม ---------- */
.auth-tools {
  position: fixed; top: 0.75rem; right: 0.75rem; z-index: 5;
  display: flex; gap: 0.35rem; padding: 0.3rem;
  border: 1px solid var(--line); border-radius: 0.9rem;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}
.auth-tools button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.4rem; height: 2.4rem; padding: 0 0.4rem;
  border: 1px solid transparent; border-radius: 0.65rem;
  color: var(--ink); background: transparent; cursor: pointer;
  font: 600 1rem/1 var(--font);
}
.auth-tools button:hover { color: var(--primary); background: var(--primary-soft); }
.auth-tools button[disabled] { opacity: .35; cursor: not-allowed; background: transparent; }
.auth-tools button.is-active { border-color: var(--primary); color: var(--primary); }
.auth-tools button sup { margin-left: 1px; font-size: .7em; line-height: 0; vertical-align: super; }
.auth-tools .sep { width: 1px; margin: 0.3rem 0.1rem; background: var(--line); }
.auth-tools svg { width: 1.25rem; height: 1.25rem; }
.auth-tools .i-sun, html[data-theme="dark"] .auth-tools .i-moon { display: none; }
html[data-theme="dark"] .auth-tools .i-sun { display: block; }

/* ---------- Footer ---------- */
.auth-footer {
  flex: none;
  padding: 8px 1rem calc(1.25rem + env(safe-area-inset-bottom));
  color: var(--muted); font-size: .88rem; line-height: 1.6; text-align: center;
}
.auth-footer p { margin: 2px 0; }
.auth-footer span[aria-hidden] { margin: 0 4px; opacity: .6; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .auth-shell { align-items: flex-start; padding: 0.75rem 0.75rem 1rem; }
  .auth-card { padding: 1.25rem 1rem 1rem; border-radius: 1rem; }
  .auth-tools { position: static; align-self: flex-end; margin: 0.5rem 0.5rem 0; }
  .auth-heading h1 { font-size: 1.4rem; }
  .auth-otp__cells { gap: 6px; }
  .auth-otp__cells span { height: 3.125rem; font-size: 1.3rem; }
  .auth-otp__cells span:nth-child(3) { margin-right: 3px; }
  .auth-otp__cells span:nth-child(4) { margin-left: 3px; }
  .auth-qr { flex-direction: column; text-align: center; }
  .auth-secret { align-items: center; }
  .auth-copy { align-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card, .auth-otp.is-shake, .auth-btn__spinner { animation: none; }
}

/* ---------- popup บัญชีถูกระงับชั่วคราว ---------- */
.auth-modal{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.55);animation:auth-modal-in .18s ease-out}
.auth-modal__box{width:min(440px,100%);padding:28px 26px 22px;border-radius:18px;background:var(--surface,#fff);color:var(--ink,#142036);text-align:center;box-shadow:0 30px 70px -20px rgba(15,23,42,.55)}
.auth-modal__icon{display:grid;place-items:center;width:64px;height:64px;margin:0 auto 14px;border-radius:50%;background:#fde8e8;color:#c62828;font-size:34px;font-weight:700;line-height:1;box-shadow:0 0 0 8px rgba(198,40,40,.08)}
.auth-modal__box h2{margin:0 0 10px;color:#c62828;font-size:1.25rem}
.auth-modal__box p{margin:0 0 16px;color:var(--ink-2,#334155);line-height:1.7}
.auth-modal__tel{display:inline-block;margin-bottom:18px;padding:8px 16px;border-radius:999px;background:#fde8e8;color:#c62828!important;font-weight:700;text-decoration:none}
.auth-modal__close{display:block;width:100%;min-height:46px;border:0;border-radius:12px;background:var(--primary,#1e3a8a);color:#fff;font:inherit;font-weight:600;cursor:pointer}
html[data-theme="dark"] .auth-modal__icon,html[data-theme="dark"] .auth-modal__tel{background:rgba(248,113,113,.15);color:#f87171}
html[data-theme="dark"] .auth-modal__box h2{color:#f87171}
@keyframes auth-modal-in{from{opacity:0}to{opacity:1}}
