/* วิทยาลัยเทคนิคพนมสารคาม · ระบบเช็คชื่อเข้าเรียน
   สีหลัก: เขียวใบไม้ (leaf green) */
:root {
  --leaf: #5bb733;
  --leaf-hover: #4aa429;
  --leaf-deep: #2f8a1e;
  --leaf-soft: #e6f4dc;
  --bg: #f3f9ee;
  --surface: #ffffff;
  --ink: #10261a;
  --muted: #4f6457;
  --line: #d3e3c8;
  --ok: #1f6b24;
  --ok-bg: #ddf1d3;
  --late: #8f4500;
  --late-bg: #ffe8c7;
  --bad: #b42318;
  --bad-bg: #fde3e0;
  --focus: #1b4ddb;
  --shadow: 0 1px 2px rgba(16, 38, 26, 0.06), 0 8px 22px rgba(16, 38, 26, 0.07);
  --font: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.35; }
h2 { font-size: 19px; line-height: 1.4; }

/* ---------- ส่วนหัว (โลโก้ซ้ายบน) ---------- */
.bar {
  position: relative;
  z-index: 5;
  background: linear-gradient(120deg, #6cc54a, #4fae2c);
  color: var(--ink);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  box-shadow: 0 2px 0 var(--leaf-hover), 0 6px 18px rgba(47, 138, 30, 0.25);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.logo {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), 0 3px 10px rgba(0, 0, 0, 0.2);
  animation: logo-in 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.brand-text { display: grid; line-height: 1.3; min-width: 0; }
.brand-text b { font-size: 17px; font-weight: 800; }
.brand-text small { font-size: 13px; font-weight: 600; opacity: 0.85; }
.bar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 600; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.wrap {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 26px 16px 64px;
  display: grid;
  gap: 20px;
  align-content: start;
}
.wrap > h1, .head-row > h1 { display: flex; align-items: center; gap: 10px; }
.wrap > h1::before, .head-row > h1::before {
  content: "";
  width: 6px;
  height: 26px;
  border-radius: 3px;
  background: var(--leaf);
  flex: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- เข้าสู่ระบบ ---------- */
body.login { background: var(--bg); position: relative; overflow-x: hidden; }
.hero-band {
  position: absolute;
  inset: 0 0 auto 0;
  height: 330px;
  background: linear-gradient(160deg, #6cc54a 0%, #4fae2c 100%);
  overflow: hidden;
  z-index: 0;
}
.blob { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.16); animation: drift 9s ease-in-out infinite alternate; }
.blob.b1 { width: 260px; height: 260px; left: -70px; top: -90px; }
.blob.b2 { width: 150px; height: 150px; right: 12%; top: 60px; animation-duration: 11s; animation-delay: -3s; }
.blob.b3 { width: 340px; height: 340px; right: -120px; top: -150px; animation-duration: 13s; animation-delay: -6s; }
body.login .bar { background: transparent; box-shadow: none; }

.login-wrap { position: relative; z-index: 2; flex: 1; width: 100%; max-width: 440px; margin: 0 auto; padding: 48px 16px 56px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 24px 26px;
  box-shadow: 0 2px 4px rgba(16, 38, 26, 0.06), 0 22px 50px rgba(16, 38, 26, 0.16);
  display: grid;
  gap: 18px;
  animation: rise 0.65s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.logo-lg {
  width: 116px;
  height: 116px;
  margin: -34px auto 0;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
  box-shadow: 0 0 0 5px var(--surface), 0 0 0 7px var(--leaf), 0 10px 24px rgba(16, 38, 26, 0.22);
  animation: logo-in 0.9s 0.1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.login-head { text-align: center; display: grid; gap: 2px; }
.login-head h1 { font-size: 24px; }
.login-head .college { font-weight: 700; color: var(--leaf-deep); }
.login-head .en { font-size: 13px; color: var(--muted); }
.login-form { display: grid; gap: 16px; }

/* ---------- แบบฟอร์ม ---------- */
.meta { font-size: 14px; color: var(--muted); }
.label { font-weight: 600; font-size: 14px; color: var(--muted); }

.field { display: grid; gap: 6px; }
input, select {
  font: inherit;
  padding: 12px;
  min-height: 48px;
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:hover, select:hover { border-color: #b6d1a6; }
input:focus, select:focus { border-color: var(--leaf-deep); box-shadow: 0 0 0 3px rgba(91, 183, 51, 0.25); outline: none; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible { box-shadow: none; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.check input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--leaf-deep); }

.btn {
  font: 700 15px var(--font);
  padding: 10px 18px;
  min-height: 44px;
  border-radius: 10px;
  border: 1.5px solid var(--leaf-deep);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn:hover { background: var(--leaf-soft); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(47, 138, 30, 0.18); }
.btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.btn.primary { background: var(--leaf); border-color: var(--leaf-hover); }
.btn.primary:hover { background: var(--leaf-hover); }
.btn.big { width: 100%; min-height: 56px; font-size: 18px; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); box-shadow: 0 4px 12px rgba(180, 35, 24, 0.15); }
.btn.small { min-height: 36px; padding: 4px 14px; font-size: 14px; }
.btn.ghost { background: rgba(255, 255, 255, 0.28); border-color: rgba(16, 38, 26, 0.55); color: var(--ink); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.55); }
.btn[disabled] { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

.error { color: var(--bad); font-weight: 600; }
.muted { color: var(--muted); }
.notice { background: var(--leaf-soft); color: var(--ok); border-radius: 10px; padding: 10px 12px; font-weight: 600; animation: rise 0.4s both; }
.chip { display: inline-block; background: var(--leaf-soft); color: var(--ok); border-radius: 99px; padding: 2px 12px; font-size: 14px; font-weight: 600; }

details { font-size: 14px; color: var(--muted); }
details summary { cursor: pointer; font-weight: 600; color: var(--leaf-deep); }
details p { margin-top: 6px; }

.stamp {
  display: inline-block;
  border: 4px solid currentColor;
  border-radius: 10px;
  padding: 6px 22px;
  font: 800 36px/1.3 var(--font);
  transform: rotate(-4deg);
  animation: stamp-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}
.stamp.ok { color: var(--ok); }
.stamp.late { color: var(--late); }
.result { text-align: center; display: grid; gap: 14px; justify-items: center; }

/* ---------- แดชบอร์ด ---------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row .field { flex: 1 1 160px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.class-card { display: grid; gap: 10px; align-content: start; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.class-card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(16, 38, 26, 0.06), 0 14px 30px rgba(47, 138, 30, 0.16); }

.strip { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.strip.four { grid-template-columns: repeat(4, 1fr); }
.strip b { display: block; font-size: 32px; line-height: 1.3; }
.strip span { font-size: 14px; color: var(--muted); }
.strip .warn b { color: var(--late); }
.strip .bad b { color: var(--bad); }
.strip > div + div { border-left: 1px solid var(--line); }

.scroll { overflow-x: auto; }
.scroll.tall { max-height: 280px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th {
  text-align: left;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  background: var(--leaf-soft);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
tbody tr { transition: background-color 0.15s; }
tbody tr:hover { background: #f6fbf2; }
tbody tr:last-child td { border-bottom: 0; }
#listRows tr, #classRows tr, #histRows tr { animation: row-in 0.4s ease both; }
#listRows tr:nth-child(2), #classRows tr:nth-child(2), #histRows tr:nth-child(2) { animation-delay: 0.04s; }
#listRows tr:nth-child(3), #classRows tr:nth-child(3), #histRows tr:nth-child(3) { animation-delay: 0.08s; }
#listRows tr:nth-child(4), #classRows tr:nth-child(4), #histRows tr:nth-child(4) { animation-delay: 0.12s; }
#listRows tr:nth-child(n + 5), #classRows tr:nth-child(n + 5), #histRows tr:nth-child(n + 5) { animation-delay: 0.16s; }

.pill { font-weight: 600; font-size: 13px; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.late { background: var(--late-bg); color: var(--late); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.num-bad { color: var(--bad); font-weight: 700; }
.num-late { color: var(--late); font-weight: 700; }

dialog { border: 0; border-radius: 16px; padding: 22px; max-width: 440px; width: calc(100% - 32px); color: var(--ink); background: var(--surface); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); }
dialog[open] { animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1) both; }
dialog::backdrop { background: rgba(10, 30, 16, 0.65); }
dialog[open]::backdrop { animation: fade 0.25s both; }
.dialog-stack { display: grid; gap: 14px; }
.qr { background: #fff; width: min(100%, 340px); margin: 0 auto 12px; border-radius: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
.linkbox { font: 12px ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

/* ---------- สแกน QR ---------- */
.scan-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 1 / 1; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 15%; border: 3px solid var(--leaf); border-radius: 16px; pointer-events: none; }
.scan-wrap::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  top: 15%;
  height: 3px;
  background: var(--leaf);
  box-shadow: 0 0 14px 2px var(--leaf);
  pointer-events: none;
  animation: scanline 2.2s ease-in-out infinite alternate;
}

/* ---------- ปุ่มสอนใช้งานลอย ---------- */
.fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--leaf);
  color: var(--ink);
  border: 2px solid var(--leaf-hover);
  border-radius: 99px;
  padding: 8px 18px 8px 10px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(47, 138, 30, 0.35);
  animation: pulse 3s ease-out infinite;
  transition: transform 0.15s ease;
}
.fab:hover { transform: translateY(-2px); background: var(--leaf-hover); }
.fab-i { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* ---------- สอนการใช้งาน ---------- */
body.tutorial { padding-bottom: 300px; }
.tut-banner { background: var(--leaf-soft); color: var(--ok); border-bottom: 1px solid var(--line); padding: 10px 16px; font-weight: 700; text-align: center; font-size: 14px; }
.spot {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  border: 3px solid var(--leaf);
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(10, 30, 16, 0.58);
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}
.coach {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.coach-in {
  pointer-events: auto;
  background: var(--surface);
  border: 2px solid var(--leaf);
  border-radius: 16px;
  padding: 16px;
  max-width: 560px;
  width: 100%;
  display: grid;
  gap: 10px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.3);
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.coach-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.linkbtn { background: none; border: 0; color: var(--muted); font: 600 14px var(--font); text-decoration: underline; cursor: pointer; padding: 4px; }
.dots { display: flex; gap: 5px; flex-wrap: wrap; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: background-color 0.2s, width 0.2s; }
.dots i.on { background: var(--leaf-deep); width: 22px; border-radius: 4px; }

/* ---------- ภาพเคลื่อนไหว ---------- */
.wrap > * { animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.wrap > *:nth-child(2) { animation-delay: 0.05s; }
.wrap > *:nth-child(3) { animation-delay: 0.1s; }
.wrap > *:nth-child(4) { animation-delay: 0.15s; }
.wrap > *:nth-child(5) { animation-delay: 0.2s; }
.wrap > *:nth-child(n + 6) { animation-delay: 0.25s; }
body.tutorial .wrap > * { animation: none; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes row-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes logo-in { from { opacity: 0; transform: scale(0.6) rotate(-12deg); } to { opacity: 1; transform: none; } }
@keyframes stamp-in { from { opacity: 0; transform: rotate(-12deg) scale(1.8); } to { opacity: 1; transform: rotate(-4deg) scale(1); } }
@keyframes drift { from { transform: translate(0, 0); } to { transform: translate(24px, 18px); } }
@keyframes scanline { from { top: 15%; } to { top: calc(85% - 3px); } }
@keyframes pulse {
  0% { box-shadow: 0 6px 18px rgba(47, 138, 30, 0.35), 0 0 0 0 rgba(91, 183, 51, 0.55); }
  70%, 100% { box-shadow: 0 6px 18px rgba(47, 138, 30, 0.35), 0 0 0 16px rgba(91, 183, 51, 0); }
}

@media (max-width: 520px) {
  h1 { font-size: 22px; }
  .strip b { font-size: 26px; }
  .brand-text b { font-size: 15px; }
  .brand-text small { font-size: 12px; }
  .logo { width: 46px; height: 46px; }
  .login-card { padding: 0 18px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- ส่วนเพิ่มเติม ---------- */
.alert { background: var(--late-bg); color: var(--late); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.acts { white-space: nowrap; }
.acts .btn + .btn { margin-left: 6px; }
dialog.live { max-width: 640px; }
dialog.live .qr { width: min(100%, 520px); }
[id^="t-"] { scroll-margin-top: 14px; }

/* ---------- ยืนยันใบหน้า ---------- */
.face-wrap video { transform: scaleX(-1); }
.face-wrap::after { display: none; }
.face-oval { position: absolute; inset: 8% 18%; border: 3px dashed var(--leaf); border-radius: 50%; pointer-events: none; }
.face-step { font-weight: 700; font-size: 18px; text-align: center; }
label.btn { cursor: pointer; text-align: center; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 50%; border: 1px solid var(--line, #dfe7e1); }
