/* ==========================================================================
   LIKHIT-TH V3 & GLASSMORPHISM DESIGN SYSTEM (ระบบ ปพ.5 & ปพ.6 สพฐ.)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Prompt:wght@300;400;500;600;700&family=Noto+Serif+Thai:wght@400;600;700&display=swap');

:root {
  /* LikhitTH Light Theme (Kraft Emerald) */
  --bg: #f5f3ee;
  --surface: #fffef9;
  --surface2: #f0ede6;
  --border: #ddd9ce;
  --border2: #c8c3b8;
  
  --text: #2c2820;
  --text2: #6b6358;
  --text3: #9e978d;
  
  --accent: #2d6a4f;
  --accent2: #1b4332;
  --accent-light: #d8f3dc;
  
  --gold: #b5860d;
  --gold-light: #fef9ed;
  
  --red: #c0392b;
  --red-light: #fdecea;
  
  --orange: #d68910;
  --blue: #1a5276;
  --blue-light: #eaf2ff;
  
  --sw: 240px;
  --r: 10px;
  --sh: 0 2px 12px rgba(0,0,0,.08);
  --sh2: 0 8px 32px rgba(0,0,0,.13);
  
  --font: 'Sarabun', 'Prompt', sans-serif;
  --font-title: 'Prompt', sans-serif;
}

/* Dark Theme (Emerald Obsidian) */
body.dark {
  --bg: #1a1814;
  --surface: #24221e;
  --surface2: #2e2b26;
  --border: #3d3930;
  --border2: #4d4940;
  
  --text: #f0ece4;
  --text2: #b0a898;
  --text3: #7a7268;
  
  --accent: #52b788;
  --accent2: #74c69d;
  --accent-light: #1a3d2b;
  
  --gold: #e0a82e;
  --gold-light: #2a2210;
  
  --red: #e74c3c;
  --red-light: #3d1a18;
  
  --blue: #5dade2;
  --blue-light: #1a2a3d;
}

/* Glassmorphism Theme (Neon Cyber Violet) */
body.glass {
  --bg: #0f172a;
  --surface: rgba(30, 41, 59, 0.7);
  --surface2: rgba(51, 65, 85, 0.6);
  --border: rgba(255, 255, 255, 0.15);
  --border2: rgba(255, 255, 255, 0.25);
  
  --text: #f8fafc;
  --text2: #cbd5e1;
  --text3: #94a3b8;
  
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --accent-light: rgba(99, 102, 241, 0.25);
  
  --gold: #f59e0b;
  --gold-light: rgba(245, 158, 11, 0.2);
  
  --red: #ef4444;
  --red-light: rgba(239, 68, 68, 0.2);
  
  --blue: #06b6d4;
  --blue-light: rgba(6, 182, 212, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background .3s, color .3s;
}

button {
  cursor: pointer;
  font-family: var(--font);
  border: none;
  outline: none;
}

input, select, textarea {
  font-family: var(--font);
  color: var(--text);
}

/* ── LAYOUT ── */
#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: var(--sw);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transition: width .25s;
  overflow: hidden;
}

#sidebar.collapsed {
  width: 64px;
}

.sb-head {
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.sb-logo {
  width: 38px;
  height: 38px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.sb-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-brand {
  font-size: 0.75rem;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.vtag {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}

/* Class Selector Dropdown in Sidebar */
.sb-cls {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sb-cls-lbl {
  font-size: 0.75rem;
  color: var(--text3);
  margin-bottom: 0.35rem;
  font-weight: 600;
  text-transform: uppercase;
}

.sb-cls select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0;
}

/* Navigation Items */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ni {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--r);
  background: transparent;
  color: var(--text2);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all .2s;
  width: 100%;
  text-align: left;
}

.ni:hover {
  background: var(--surface2);
  color: var(--text);
}

.ni.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
}

.ni-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.ni-label {
  white-space: nowrap;
}

/* Sidebar Footer (Developer Credits) */
.sb-foot {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  font-size: 0.78rem;
  color: var(--text2);
  line-height: 1.4;
}

.sb-foot-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Main Content Container */
#main {
  flex: 1;
  margin-left: var(--sw);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .25s;
}

#main.expanded {
  margin-left: 64px;
}

/* Topbar Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.tb-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.tb-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.tb-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Main Page Container */
.page-container {
  padding: 1.75rem;
  flex: 1;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--sh);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--text);
}

/* Developer Credit Banner Box */
.dev-credit-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--r);
  padding: 1.15rem 1.35rem;
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.dev-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--sh);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--surface2);
}

.stat-val {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-lbl {
  font-size: 0.8rem;
  color: var(--text2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all .2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent2);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: #27ae60;
  color: #fff;
}

/* Modal Overlay & Modal Window */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  padding: 1.75rem;
  box-shadow: var(--sh2);
  transform: translateY(12px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close {
  background: transparent;
  font-size: 1.25rem;
  color: var(--text3);
}
.modal-close:hover {
  color: var(--red);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Form Controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
}

.form-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  font-size: 0.92rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tbl th {
  background: var(--surface2);
  padding: 0.75rem 0.85rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

.tbl td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.tbl tr:hover td {
  background: var(--surface2);
}

.cell-input {
  width: 100%;
  min-width: 48px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem;
  text-align: center;
  font-size: 0.88rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-green { background: var(--accent-light); color: var(--accent); }
.badge-gold { background: var(--gold-light); color: var(--gold); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--blue-light); color: var(--blue); }

/* Print Stage (hidden on screen) */
#print-stage {
  display: none;
}

/* Print CSS */
@media print {
  body { background: #fff !important; color: #000 !important; font-family: 'Sarabun', sans-serif !important; }
  #app { display: none !important; }
  #print-stage { display: block !important; width: 100% !important; }
}
