/* =====================================================================
   ระบบนิเทศภายในออนไลน์ — ธีม EGGPLORE (ม่วง/น้ำเงิน) + IBM Plex Sans Thai
   ===================================================================== */

:root{
  /* Primary (ม่วง) */
  --primary:      #BE52F2;
  --primary-2:    #DBA5F5;
  --primary-3:    #EEDFF2;
  /* Accent (น้ำเงิน) */
  --accent:       #6979F8;
  --accent-2:     #A5AFFB;
  --accent-3:     #E5E7FA;
  /* Gradient */
  --grad:         linear-gradient(135deg, #8461C9 0%, #BD7AE3 100%);
  --grad-soft:    linear-gradient(135deg, #CDBAFA 0%, #CDDDF4 100%);
  /* Semantic */
  --success:      #00C48C;
  --success-2:    #7DDFC3;
  --warning:      #FFCF5C;
  --orange:       #FFA26B;
  --info:         #0084F4;
  --danger:       #FF647C;
  --danger-2:     #FDAFBB;
  /* Neutral */
  --ink:          #1A051D;
  --ink-2:        #3F3356;
  --muted:        #8A8397;
  --line:         #ECE9F1;
  --line-2:       #D0C9D6;
  --bg:           #F5F4F8;
  --card:         #FFFFFF;

  --radius:       16px;
  --radius-sm:    10px;
  --shadow:       0 8px 30px rgba(63,51,86,.08);
  --shadow-lg:    0 16px 44px rgba(63,51,86,.14);
  --sidebar-w:    256px;
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  font-family:'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  background:var(--bg);
  color:var(--ink-2);
  font-size:15px;
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
}
a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }
h1,h2,h3,h4{ color:var(--ink); font-weight:600; line-height:1.35; margin:0 0 .5rem; }

/* ---------- Layout ---------- */
.app{ display:flex; min-height:100vh; }

.sidebar{
  width:var(--sidebar-w);
  background:var(--card);
  border-right:1px solid var(--line);
  position:fixed; inset:0 auto 0 0;
  display:flex; flex-direction:column;
  z-index:40;
  transition:transform .25s ease;
}
.sidebar__brand{
  display:flex; align-items:center; gap:.65rem;
  padding:1.15rem 1.25rem;
  border-bottom:1px solid var(--line);
}
.brand-logo{
  width:44px; height:44px; border-radius:13px;
  background:var(--grad);
  display:grid; place-items:center; color:#fff; flex:none;
  box-shadow:0 6px 16px rgba(132,97,201,.4);
}
.brand-logo svg{ width:24px; height:24px; }
.brand-text b{ color:var(--ink); font-size:1rem; display:block; line-height:1.2; }
.brand-text span{ font-size:.72rem; color:var(--muted); }

.nav{ padding:.75rem; overflow-y:auto; flex:1; }
.nav__label{ font-size:.7rem; letter-spacing:.08em; color:var(--muted); text-transform:uppercase; padding:.75rem .8rem .35rem; }
.nav a{
  display:flex; align-items:center; gap:.7rem;
  padding:.65rem .8rem; border-radius:12px;
  color:var(--ink-2); font-weight:500; margin-bottom:2px;
  transition:.15s;
}
.nav a:hover{ background:var(--primary-3); text-decoration:none; }
.nav a.active{ background:var(--grad); color:#fff; box-shadow:0 6px 16px rgba(132,97,201,.35); }
.nav a.active svg{ stroke:#fff; }
.nav svg{ width:20px; height:20px; stroke:var(--ink-2); flex:none; }

.sidebar__foot{ padding:1rem; border-top:1px solid var(--line); }

.main{ flex:1; margin-left:var(--sidebar-w); min-width:0; display:flex; flex-direction:column; }

.topbar{
  position:sticky; top:0; z-index:30;
  background:rgba(255,255,255,.85); backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:1rem;
  padding:.85rem 1.5rem;
}
.topbar h1{ font-size:1.1rem; margin:0; }
.topbar__spacer{ flex:1; }
.user-chip{ display:flex; align-items:center; gap:.6rem; }
.avatar{
  width:38px; height:38px; border-radius:50%;
  background:var(--accent-3); color:var(--accent);
  display:grid; place-items:center; font-weight:600; flex:none;
}
.user-chip small{ display:block; color:var(--muted); font-size:.72rem; }
.user-chip b{ color:var(--ink); font-size:.85rem; }

.content{ padding:1.75rem 1.5rem 3rem; max-width:1180px; width:100%; margin:0 auto; }

.hamburger{
  display:none; width:42px; height:42px; border-radius:12px;
  border:1px solid var(--line); background:#fff; cursor:pointer;
  align-items:center; justify-content:center;
}
.hamburger svg{ width:22px; height:22px; stroke:var(--ink-2); }
.backdrop{ display:none; }

/* ---------- Cards ---------- */
.card{
  background:var(--card); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:1.5rem; margin-bottom:1.25rem;
}
.card__head{ display:flex; align-items:center; gap:.75rem; margin-bottom:1rem; }
.card__title{ font-size:1.05rem; margin:0; }
.section-title{
  display:flex; align-items:center; gap:.6rem;
  font-size:1.25rem; color:var(--accent); font-weight:700; margin:0 0 1.25rem;
}
.section-title::before{ content:''; width:5px; height:22px; border-radius:4px; background:var(--accent); }

/* ---------- Stat tiles ---------- */
.grid{ display:grid; gap:1.1rem; }
.grid-4{ grid-template-columns:repeat(4,1fr); }
.grid-3{ grid-template-columns:repeat(3,1fr); }
.grid-2{ grid-template-columns:repeat(2,1fr); }
.stat{
  background:var(--card); border-radius:var(--radius); padding:1.25rem;
  box-shadow:var(--shadow); display:flex; align-items:center; gap:1rem;
}
.stat__icon{ width:52px; height:52px; border-radius:14px; display:grid; place-items:center; flex:none; }
.stat__icon svg{ width:26px; height:26px; }
.stat__num{ font-size:1.7rem; font-weight:700; color:var(--ink); line-height:1.1; }
.stat__label{ color:var(--muted); font-size:.82rem; }
.i-purple{ background:var(--primary-3); color:var(--primary); }
.i-blue{ background:var(--accent-3); color:var(--accent); }
.i-green{ background:#D5F2EA; color:var(--success); }
.i-orange{ background:#FFE8DA; color:var(--orange); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; gap:.5rem; justify-content:center;
  border:none; cursor:pointer; font-family:inherit; font-weight:600;
  padding:.6rem 1.15rem; border-radius:12px; font-size:.9rem;
  background:var(--accent); color:#fff; transition:.15s; text-decoration:none;
}
.btn:hover{ filter:brightness(.96); text-decoration:none; }
.btn svg{ width:18px; height:18px; }
.btn-grad{ background:var(--grad); box-shadow:0 8px 18px rgba(132,97,201,.32); }
.btn-primary{ background:var(--primary); }
.btn-ghost{ background:var(--accent-3); color:var(--accent); }
.btn-outline{ background:#fff; color:var(--accent); border:1.5px solid var(--accent-2); }
.btn-danger{ background:var(--danger); }
.btn-muted{ background:var(--line); color:var(--ink-2); }
.btn-sm{ padding:.4rem .8rem; font-size:.82rem; border-radius:10px; }
.btn-block{ width:100%; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

/* ---------- Forms ---------- */
.field{ margin-bottom:1.1rem; }
.field > label{ display:block; font-weight:500; color:var(--ink-2); margin-bottom:.4rem; font-size:.92rem; }
.req{ color:var(--danger); }
input[type=text],input[type=password],input[type=number],input[type=date],
input[type=email],select,textarea{
  width:100%; font-family:inherit; font-size:.92rem; color:var(--ink);
  background:#fff; border:1.5px solid var(--line);
  border-radius:12px; padding:.65rem .85rem; transition:.15s;
}
textarea{ resize:vertical; line-height:1.6; }
input:focus,select:focus,textarea:focus{
  outline:none; border-color:var(--accent-2);
  box-shadow:0 0 0 4px var(--accent-3);
}
select{ appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236979F8' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right .9rem center; padding-right:2.2rem;
}
.form-row{ display:grid; gap:1rem; grid-template-columns:repeat(2,1fr); }
.form-row-3{ display:grid; gap:1rem; grid-template-columns:repeat(3,1fr); }
.help{ font-size:.78rem; color:var(--muted); margin-top:.3rem; }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; border-radius:var(--radius); }
table.tbl{ width:100%; border-collapse:collapse; background:#fff; min-width:640px; }
table.tbl th,table.tbl td{ padding:.8rem 1rem; text-align:left; border-bottom:1px solid var(--line); }
table.tbl th{ background:var(--primary-3); color:var(--ink); font-weight:600; font-size:.85rem; white-space:nowrap; }
table.tbl tbody tr:hover{ background:#FAF9FC; }
table.tbl td.num{ text-align:center; }

/* ---------- Badges / pills ---------- */
.badge{ display:inline-block; padding:.2rem .65rem; border-radius:999px; font-size:.75rem; font-weight:600; }
.badge-success{ background:#D5F2EA; color:#009e70; }
.badge-muted{ background:var(--line); color:var(--muted); }
.badge-primary{ background:var(--primary-3); color:var(--primary); }
.badge-accent{ background:var(--accent-3); color:var(--accent); }

/* ---------- Alerts ---------- */
.alert{ padding:.9rem 1.1rem; border-radius:12px; margin-bottom:1rem; font-size:.9rem; display:flex; gap:.6rem; align-items:flex-start; }
.alert-success{ background:#D5F2EA; color:#00885f; }
.alert-warning{ background:#FFF3D6; color:#9a6b00; }
.alert-danger{ background:#FFE1E6; color:#c02b45; }
.alert-info{ background:var(--accent-3); color:#3a4bd0; }

/* ---------- Form engine ---------- */
.subhead{
  background:var(--grad-soft); color:var(--ink);
  padding:.7rem 1rem; border-radius:12px; font-weight:600;
  margin:1.5rem 0 .9rem; font-size:.95rem;
}
.q-item{ padding:1rem 0; border-bottom:1px dashed var(--line); }
.q-item:last-child{ border-bottom:none; }
.q-item__label{ font-weight:500; color:var(--ink); margin-bottom:.6rem; }
.q-target{ display:inline-block; background:var(--warning); color:#7a5a00; font-size:.72rem; font-weight:600; padding:.12rem .55rem; border-radius:999px; margin-left:.35rem; }

/* radios as chips */
.choices{ display:flex; flex-wrap:wrap; gap:.5rem; margin-bottom:.6rem; }
.choice{ position:relative; }
.choice input{ position:absolute; opacity:0; inset:0; cursor:pointer; }
.choice span{
  display:inline-block; padding:.42rem .9rem; border-radius:999px;
  border:1.5px solid var(--line); background:#fff; color:var(--ink-2);
  font-size:.85rem; font-weight:500; cursor:pointer; transition:.15s; user-select:none;
}
.choice input:checked + span{ background:var(--grad); color:#fff; border-color:transparent; box-shadow:0 5px 12px rgba(132,97,201,.3); }
.choice input:focus-visible + span{ box-shadow:0 0 0 4px var(--accent-3); }
.choice.c-green input:checked + span{ background:var(--success); }
.choice.c-red input:checked + span{ background:var(--danger); }

.score-grid{ display:grid; grid-template-columns:1fr 1fr; gap:.75rem; }
.score-box{ background:var(--bg); border-radius:12px; padding:.7rem .8rem; }
.score-box b{ font-size:.78rem; color:var(--accent); display:block; margin-bottom:.4rem; }

/* ---------- Tabs (section stepper) ---------- */
.tabs{ display:flex; gap:.4rem; overflow-x:auto; padding-bottom:.5rem; margin-bottom:1.25rem; scrollbar-width:thin; }
.tab{
  flex:none; padding:.5rem .9rem; border-radius:999px; cursor:pointer;
  background:#fff; border:1.5px solid var(--line); color:var(--ink-2);
  font-size:.85rem; font-weight:600; white-space:nowrap; transition:.15s;
}
.tab.active{ background:var(--grad); color:#fff; border-color:transparent; }
.tab .num{ opacity:.8; margin-right:.25rem; }
.tab-pane{ display:none; }
.tab-pane.active{ display:block; animation:fade .2s ease; }
@keyframes fade{ from{ opacity:0; transform:translateY(4px);} to{ opacity:1; transform:none;} }

/* ---------- Topic menu (report hub) ---------- */
.topic-menu{ margin-bottom:1.5rem; }
.topic-card{
  display:flex; align-items:center; gap:.9rem;
  background:var(--card); border:1.5px solid var(--line); border-radius:var(--radius);
  padding:1.1rem 1.15rem; box-shadow:var(--shadow); color:var(--ink-2);
  transition:.15s; text-decoration:none;
}
.topic-card:hover{ text-decoration:none; transform:translateY(-2px); box-shadow:var(--shadow-lg); border-color:var(--accent-2); }
.topic-card__no{
  width:42px; height:42px; border-radius:12px; flex:none;
  display:grid; place-items:center; font-weight:700; font-size:1.05rem;
  background:var(--primary-3); color:var(--primary);
}
.topic-card.is-done .topic-card__no{ background:var(--grad); color:#fff; }
.topic-card__body{ flex:1; min-width:0; }
.topic-card__title{ font-weight:600; color:var(--ink); line-height:1.35; }
.topic-card__meta{ font-size:.78rem; color:var(--muted); display:flex; align-items:center; gap:.4rem; margin-top:.25rem; }
.dot-done,.dot-todo{ width:8px; height:8px; border-radius:50%; display:inline-block; }
.dot-done{ background:var(--success); }
.dot-todo{ background:var(--line-2); }
.topic-card__arrow{ width:20px; height:20px; stroke:var(--line-2); flex:none; }
.topic-card:hover .topic-card__arrow{ stroke:var(--accent); }

/* ---------- Teacher / observation rounds ---------- */
.teacher-block{ border:1.5px solid var(--line); border-radius:var(--radius); padding:1rem; margin-bottom:1rem; }
.teacher-head{ display:flex; align-items:center; gap:.7rem; margin-bottom:.75rem; }
.teacher-head small{ display:block; }
.round-list{ display:flex; flex-direction:column; gap:.5rem; }
.round-item{ display:flex; align-items:center; gap:.9rem; background:var(--bg); border-radius:12px; padding:.6rem .9rem; flex-wrap:wrap; }
.round-no{ font-weight:700; color:var(--accent); background:var(--accent-3); padding:.2rem .7rem; border-radius:999px; font-size:.82rem; flex:none; }
.round-meta{ flex:1; font-size:.85rem; min-width:120px; }
.obs-view{ margin-bottom:1rem; }

/* ---------- Auth page ---------- */
.auth{ min-height:100vh; display:grid; place-items:center; padding:1.5rem;
  background:var(--grad); position:relative; overflow:hidden; }
.auth::before,.auth::after{ content:''; position:absolute; border-radius:50%; background:rgba(255,255,255,.12); }
.auth::before{ width:340px; height:340px; top:-120px; right:-80px; }
.auth::after{ width:260px; height:260px; bottom:-100px; left:-60px; }
.auth__card{ background:#fff; border-radius:24px; box-shadow:var(--shadow-lg);
  width:100%; max-width:420px; padding:2.5rem 2rem; position:relative; z-index:1; }
.auth__logo{ width:64px; height:64px; border-radius:19px; background:var(--grad);
  display:grid; place-items:center; margin:0 auto 1rem; color:#fff; box-shadow:0 10px 24px rgba(132,97,201,.4); }
.auth__logo svg{ width:34px; height:34px; }
.auth h2{ text-align:center; margin-bottom:.25rem; }
.auth .sub{ text-align:center; color:var(--muted); font-size:.85rem; margin-bottom:1.75rem; }

/* ---------- Misc ---------- */
.page-head{ display:flex; align-items:center; flex-wrap:wrap; gap:1rem; margin-bottom:1.5rem; }
.page-head h2{ margin:0; }
.page-head .spacer{ flex:1; }
.muted{ color:var(--muted); }
.text-center{ text-align:center; }
.mt-2{ margin-top:1rem; } .mt-3{ margin-top:1.5rem; }
.mb-0{ margin-bottom:0; }
.flex{ display:flex; align-items:center; gap:.6rem; }
.gap-sm{ gap:.4rem; }
.pill-row{ display:flex; flex-wrap:wrap; gap:.5rem; }
.empty{ text-align:center; padding:3rem 1rem; color:var(--muted); }
.empty svg{ width:56px; height:56px; stroke:var(--line-2); margin-bottom:.75rem; }
.divider{ height:1px; background:var(--line); margin:1.25rem 0; }
.actions{ display:flex; gap:.5rem; flex-wrap:wrap; }
.sticky-actions{ position:sticky; bottom:0; background:rgba(255,255,255,.92); backdrop-filter:blur(8px);
  border-top:1px solid var(--line); padding:1rem 0; margin-top:1.5rem; display:flex; gap:.75rem; flex-wrap:wrap; }

/* ---------- Responsive ---------- */
@media (max-width:1024px){
  .grid-4{ grid-template-columns:repeat(2,1fr); }
}
@media (max-width:860px){
  .sidebar{ transform:translateX(-100%); box-shadow:var(--shadow-lg); }
  .sidebar.open{ transform:none; }
  .main{ margin-left:0; }
  .hamburger{ display:inline-flex; }
  .backdrop.show{ display:block; position:fixed; inset:0; background:rgba(26,5,29,.35); z-index:35; }
  .content{ padding:1.25rem 1rem 3rem; }
  .grid-3,.grid-2{ grid-template-columns:1fr; }
  .form-row,.form-row-3{ grid-template-columns:1fr; }
}
@media (max-width:520px){
  .grid-4{ grid-template-columns:1fr; }
  .stat__num{ font-size:1.4rem; }
  .topbar h1{ font-size:.98rem; }
  .score-grid{ grid-template-columns:1fr; }
  .content{ padding:1rem .85rem 3rem; }
  .card{ padding:1.15rem; }
}

/* ---------- Print ---------- */
@media print{
  .sidebar,.topbar,.hamburger,.backdrop,.sticky-actions,.no-print{ display:none !important; }
  .main{ margin:0; }
  body{ background:#fff; font-size:13px; }
  .content{ max-width:none; padding:0; }
  .card{ box-shadow:none; border:1px solid #ddd; break-inside:avoid; }
  .tab-pane{ display:block !important; }
  .tabs{ display:none; }
  .subhead{ background:#eee !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}
