/* =====================================================================
   Aledary Online — หน้าเข้าสู่ระบบ / ลงทะเบียนบุคลากร (L1 13 พ.ย. 2569 · pages/auth/layout.php)
   ไม่มีไลบรารีภายนอก (ไม่มี jQuery / Bootstrap / CDN) · ฟอนต์หัวข้อ Prompt จากโฮสต์ (dist/fonts/prompt — ชุดเดียวกับ iStudent)
   สีชุดเดียวกับ iStudent (brand เขียว #00573f · sage · gold) · โหมดมืด = html[data-theme="dark"] (ตามเครื่อง + ปุ่มสลับ)
   คอนทราสต์ AA ≥ 4.5:1 ทุกข้อความทั้งสองโหมด (ต่ำสุด 5.4:1 — ตรวจด้วยเบราว์เซอร์จริงในชุดทดสอบ)
   แก้ไฟล์นี้ = เปลี่ยน AUTH_ASSET_VERSION ใน modules/auth/shared/pages.php
   ===================================================================== */

@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../../dist/fonts/prompt/prompt-thai-500-normal.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../../dist/fonts/prompt/prompt-thai-600-normal.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../../dist/fonts/prompt/prompt-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Prompt'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../../dist/fonts/prompt/prompt-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --text: #1a211e;
  --text-strong: #014a36;
  --muted: #515f58;
  --border: #c3cfc9;
  --border-soft: #dde5e1;
  --brand: #00573f;
  --brand-hover: #014a36;
  --on-brand: #ffffff;
  --brand-soft: #eef7f2;
  --brand-soft-text: #014a36;
  --link: #00573f;
  --gold: #d4ad3f;
  --focus: #d4ad3f;
  --field-bg: #ffffff;
  --ok-bg: #eef7f2; --ok-text: #03392b; --ok-border: #aedbc4;
  --warn-bg: #f7efd2; --warn-text: #4a3810; --warn-border: #e3c76d;
  --err-bg: #fef2f2; --err-text: #991b1b; --err-border: #fecaca;
  --info-bg: #eef5ff; --info-text: #0b3d75; --info-border: #b6d4fe;
  --shadow: 0 1px 2px rgb(1 36 27 / .06), 0 12px 32px -12px rgb(1 36 27 / .18);
  --radius: 16px;
  --font-display: 'Prompt', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', 'Noto Sans Thai', 'Noto Sans Thai UI', 'Sukhumvit Set', Thonburi, Tahoma, Loma, sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0e1311;
  --surface: #1a211e;
  --surface-2: #222b27;
  --text: #edf1ef;
  --text-strong: #d6ede1;
  --muted: #c3cfc9;
  --border: #515f58;
  --border-soft: #3d4943;
  --brand: #7cc0a0;
  --brand-hover: #aedbc4;
  --on-brand: #01241b;
  --brand-soft: #03392b;
  --brand-soft-text: #d6ede1;
  --link: #aedbc4;
  --field-bg: #0e1311;
  --ok-bg: #03392b; --ok-text: #eef7f2; --ok-border: #1b6c4d;
  --warn-bg: #3a2f12; --warn-text: #f7efd2; --warn-border: #9a7520;
  --err-bg: #3b0d0d; --err-text: #fee2e2; --err-border: #7f1d1d;
  --info-bg: #0b2545; --info-text: #dbeafe; --info-border: #1e4e8c;
  --shadow: 0 0 0 1px #29322e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--link); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- โครงหน้า ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
  .auth { grid-template-columns: minmax(420px, 1.05fr) 1fr; }
  .auth--wide { grid-template-columns: minmax(380px, .8fr) 1.2fr; }
}

/* แผงโรงเรียน (จอใหญ่) */
.auth-panel {
  display: none;
  position: relative;
  overflow: hidden;
  color: #fff;
  background: #014a36;
  padding: 48px 56px;
}
@media (min-width: 1024px) { .auth-panel { display: flex; flex-direction: column; justify-content: space-between; position: sticky; top: 0; height: 100vh; min-height: 640px; } }
.auth-panel::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.07'%3E%3Cpath d='M28 6l6.2 15.8L50 28l-15.8 6.2L28 50l-6.2-15.8L6 28l15.8-6.2z'/%3E%3Crect x='17' y='17' width='22' height='22' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E");
}
.auth-panel::after {
  content: '';
  position: absolute; right: -140px; bottom: -160px;
  width: 460px; height: 460px; border-radius: 50%;
  border: 14px solid rgb(212 173 63 / .55);
  box-shadow: 0 0 0 26px rgb(124 192 160 / .12);
}
.auth-panel > * { position: relative; z-index: 1; }
.panel-school { display: flex; align-items: center; gap: 18px; }
.panel-logo { width: 84px; height: 84px; border-radius: 50%; background: #fff; padding: 6px; object-fit: contain; box-shadow: 0 8px 24px rgb(0 0 0 / .25); }
.panel-name { margin: 0; font: 600 1.6rem/1.25 var(--font-display); }
.panel-name-ar { margin: 2px 0 0; font-family: 'Noto Naskh Arabic', 'Geeza Pro', 'Traditional Arabic', serif; font-size: 1.25rem; color: #d6ede1; }
.panel-name-en { margin: 2px 0 0; font-size: .9rem; letter-spacing: .02em; color: #d6ede1; }
.panel-hero { max-width: 460px; }
.panel-system { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 6px 12px; border-radius: 999px; background: rgb(255 255 255 / .1); font: 500 .9rem var(--font-display); color: #f7efd2; }
.panel-title { margin: 0; font: 600 2.4rem/1.2 var(--font-display); }
.panel-title em { font-style: normal; color: #e3c76d; }
.panel-lead { margin: 14px 0 0; color: #d6ede1; font-size: 1.05rem; }
.panel-points { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
.panel-points li { display: flex; gap: 12px; align-items: center; color: #eef7f2; }
.panel-points .dot { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: rgb(255 255 255 / .1); color: #e3c76d; }
.panel-foot { font-size: .875rem; color: #aedbc4; }

/* พื้นที่ฟอร์ม */
.auth-main {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 16px 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%2300573f' stroke-opacity='.06'%3E%3Cpath d='M28 6l6.2 15.8L50 28l-15.8 6.2L28 50l-6.2-15.8L6 28l15.8-6.2z'/%3E%3C/g%3E%3C/svg%3E");
}
html[data-theme="dark"] .auth-main {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%237cc0a0' stroke-opacity='.05'%3E%3Cpath d='M28 6l6.2 15.8L50 28l-15.8 6.2L28 50l-6.2-15.8L6 28l15.8-6.2z'/%3E%3C/g%3E%3C/svg%3E");
}
@media (min-width: 1024px) { .auth-main { padding: 76px 32px 48px; } }   /* บน 76 = พ้นปุ่มโหมดสี (14 + 44 + 18) — หน้าลงทะเบียนยาวเริ่มชิดบน */

.theme-btn {
  position: absolute; top: 14px; right: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--border-soft); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: 500 .9rem var(--font-display); cursor: pointer;
}
.theme-btn:hover { border-color: var(--brand); }

.auth-box { width: 100%; max-width: 420px; }
.auth-box--wide { max-width: 760px; }

/* หัวบนจอเล็ก */
.mobile-head { text-align: center; margin-bottom: 18px; }
@media (min-width: 1024px) { .mobile-head { display: none; } }
.mobile-head img { width: 76px; height: 76px; border-radius: 50%; background: #fff; padding: 5px; object-fit: contain; box-shadow: var(--shadow); }
.mobile-head h1 { margin: 10px 0 0; font: 600 1.25rem/1.3 var(--font-display); color: var(--text-strong); }
.mobile-head p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
  padding: 24px 20px;
}
@media (min-width: 480px) { .card { padding: 28px; } }

.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.card-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-soft-text); flex: none; }
.card-icon .ic { width: 24px; height: 24px; }
.card-title { margin: 0; font: 600 1.3rem/1.25 var(--font-display); color: var(--text-strong); }
.card-sub { margin: 2px 0 0; color: var(--muted); font-size: .95rem; }

/* ข้อความแจ้ง */
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid; font-size: .95rem; margin: 0 0 16px; }
.note .ic { margin-top: 2px; }
.note p { margin: 0; }
.note b { font-weight: 600; }
.note--ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.note--warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.note--err { background: var(--err-bg); color: var(--err-text); border-color: var(--err-border); }
.note--info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }

/* ช่องกรอก */
.field-row { margin-bottom: 16px; }
.label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .95rem; color: var(--text); }
.label .req { color: var(--err-text); }
html[data-theme="dark"] .label .req { color: #fca5a5; }
.label small { font-weight: 400; color: var(--muted); }
.input-wrap { position: relative; }
.input-wrap > .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input {
  display: block; width: 100%;
  min-height: 48px; padding: 11px 14px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); opacity: .85; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(0 87 63 / .18); }
html[data-theme="dark"] .input:focus { box-shadow: 0 0 0 3px rgb(124 192 160 / .25); }
.input-wrap > .ic + .input { padding-left: 44px; }
.input--pass { padding-right: 52px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
textarea.input { min-height: 76px; resize: vertical; }
.eye-btn {
  position: absolute; right: 2px; top: 2px; bottom: 2px;
  width: 48px; display: grid; place-items: center;
  border: 0; border-radius: 0 10px 10px 0; background: transparent; color: var(--muted); cursor: pointer;
}
.eye-btn:hover { color: var(--brand); }
.hint { margin: 6px 0 0; font-size: .875rem; color: var(--muted); }

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; margin: 4px 0 8px; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.check span small { color: var(--muted); font-size: .875rem; }

/* ปุ่ม */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 50px; padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent;
  font: 500 1.05rem var(--font-display); cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s;
}
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-soft-text); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn .g { width: 20px; height: 20px; }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: .9rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }

.links { margin-top: 18px; display: grid; gap: 10px; }
.help {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-size: .95rem;
}
.help .ic { color: var(--muted); margin-top: 2px; }
.help p { margin: 0; }
.help b { font-weight: 600; }
.register-line { text-align: center; margin: 4px 0 0; }
.register-line a { font-weight: 600; }

.student-line {
  display: flex; align-items: center; gap: 12px;
  margin-top: 16px; padding: 14px 16px;
  border-radius: 14px; text-decoration: none;
  border: 1px dashed var(--border); color: var(--text); background: var(--surface);
}
.student-line:hover { border-color: var(--brand); border-style: solid; }
.student-line .cap { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #f7efd2; color: #7a5c1a; flex: none; }
html[data-theme="dark"] .student-line .cap { background: #3a2f12; color: #efdea4; }
.student-line .txt { flex: 1; font-size: .95rem; }
.student-line .txt b { display: block; font-family: var(--font-display); font-weight: 500; font-size: 1rem; color: var(--text-strong); }
.student-line .txt span { color: var(--muted); }

.foot { margin: 20px 0 0; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---------- หน้าลงทะเบียน ---------- */
.steps { display: grid; gap: 16px; }
.sec { border: 1px solid var(--border-soft); border-radius: 14px; padding: 18px 16px 4px; background: var(--surface); }
@media (min-width: 480px) { .sec { padding: 20px 20px 6px; } }
.sec-head { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.sec-no { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font: 600 .9rem var(--font-display); flex: none; }
.sec-title { margin: 0; font: 600 1.05rem var(--font-display); color: var(--text-strong); }
.sec-title small { font: 400 .875rem var(--font-body); color: var(--muted); margin-left: 6px; }
.grid { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 9rem 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}
.photo-pick { display: flex; align-items: center; gap: 16px; padding-bottom: 14px; }
.photo-circle { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 2px dashed var(--border); color: var(--muted); flex: none; }
.photo-circle .ic { width: 28px; height: 28px; }
.file-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 .95rem var(--font-display); cursor: pointer; }
.sec--code { border-color: var(--gold); background: linear-gradient(0deg, transparent, transparent), var(--surface); }
.code-input { text-align: center; letter-spacing: .25em; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-weight: 600; text-transform: uppercase; }
.pw-rules { list-style: none; margin: -6px 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .875rem; color: var(--muted); }
.pw-rules li { display: inline-flex; align-items: center; gap: 6px; }
.pw-rules .ic { width: 16px; height: 16px; }
.pw-rules li.ok { color: var(--brand-soft-text); }
html:not([data-theme="dark"]) .pw-rules li.ok { color: #14532d; }
.actions { display: flex; flex-direction: column-reverse; gap: 10px; margin-top: 4px; }
@media (min-width: 640px) { .actions { flex-direction: row; justify-content: flex-end; } .actions .btn { width: auto; min-width: 200px; } }

/* ---------- ส่วนเพิ่มของของจริง ---------- */
.note[hidden] { display: none !important; }
.input[aria-invalid="true"] { border-color: var(--err-text); box-shadow: 0 0 0 3px rgb(153 27 27 / .15); }
html[data-theme="dark"] .input[aria-invalid="true"] { border-color: #fca5a5; box-shadow: 0 0 0 3px rgb(252 165 165 / .2); }
.field-error { margin: 6px 0 0; font-size: .875rem; color: var(--err-text); }
html[data-theme="dark"] .field-error { color: #fca5a5; }
.photo-circle img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.photo-circle.has-img { border-style: solid; padding: 0; overflow: hidden; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn-ghost { background: transparent; color: var(--link); border: 0; min-height: 44px; padding: 0 8px; font: 500 .95rem var(--font-display); cursor: pointer; }
.closed-box { text-align: center; padding: 8px 0; }
.closed-box .ic { width: 44px; height: 44px; color: var(--muted); }
.closed-box p { margin: 10px 0 18px; }
.success-box { text-align: center; padding: 6px 0; }
.success-box .ic { width: 52px; height: 52px; color: var(--brand); }
.spin { animation: auth-spin 1s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } * { transition: none !important; } }
.student-line--plain { border-style: dashed; cursor: default; }
.student-line--plain:hover { border-style: dashed; border-color: var(--border); }
