/* ===========================================================
   OI-NET-WEB dashboard theme
   Palette lifted from sedc.edu-south.go.th (purple / white)
   =========================================================== */

:root {
  --c-primary: #7c1fd4;      /* core purple (accessible on white) */
  --c-primary-dark: #4c0d94; /* deep purple / indigo */
  --c-accent: #c10fff;       /* vivid magenta-purple accent */
  --c-accent-2: #ffcd57;     /* warm accent for highlights */
  --c-text: #1e293b;
  --c-text-muted: #67768e;
  --c-bg: #f7f5fb;
  --c-bg-tint: #f9f6fe;
  --c-surface: #ffffff;
  --c-border: #ece7f7;
  --c-success: #16a34a;
  --c-danger: #e11d48;

  --grad-primary: linear-gradient(135deg, #4c0d94 0%, #7c1fd4 55%, #c10fff 100%);
  --grad-soft: linear-gradient(135deg, #f9f6fe 0%, #f1e6ff 100%);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 2px 8px rgba(76, 13, 148, 0.06);
  --shadow-md: 0 8px 24px rgba(76, 13, 148, 0.10);
  --shadow-lg: 0 16px 40px rgba(76, 13, 148, 0.14);

  --header-h: 72px;
  font-family: "Prompt", "Noto Sans Thai", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: "Prompt", "Noto Sans Thai", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------- Header ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text { min-width: 0; }
.brand-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: 12px;
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-nav { display: flex; align-items: center; gap: 8px; }

.nav-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--c-bg-tint);
  border-radius: 999px;
}
.nav-switch a {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--c-text-muted);
  transition: all 0.2s ease;
}
.nav-switch a.active {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.nav-switch a:not(.active):hover { color: var(--c-primary); }

/* ---------------- Hero ---------------- */

.hero {
  background: var(--grad-primary);
  color: #fff;
  padding: 40px 0 88px;
  position: relative;
  overflow: hidden;
}
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}
.hero::before { width: 420px; height: 420px; top: -220px; right: -100px; }
.hero::after { width: 260px; height: 260px; bottom: -160px; left: 10%; background: rgba(255,205,87,0.12); }

.hero .container { position: relative; z-index: 1; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.16);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-accent-2); }

.hero h1 {
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 700;
  margin: 0 0 12px;
}
.hero p {
  max-width: 760px;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.88);
  margin: 0 0 6px;
}
.hero .meta-line {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 14px;
}

/* ---------------- Filter panel ---------------- */

.filter-panel {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px 24px;
  margin-top: -56px;
  position: relative;
  z-index: 2;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.filter-group label.filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  appearance: none;
  border: 1.5px solid var(--c-border);
  background: var(--c-bg-tint);
  color: var(--c-text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.chip:hover { border-color: var(--c-accent); color: var(--c-primary-dark); }
.chip.active {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.chip.small { padding: 5px 12px; font-size: 12.5px; }

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { border-color: var(--c-accent); color: var(--c-primary-dark); }
.btn-primary {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.06); color: #fff; }

/* ---------------- Sections ---------------- */

.section { padding: 40px 0; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 4px;
}
.section-head p { margin: 0; font-size: 13px; color: var(--c-text-muted); }

/* ---------------- KPI cards ---------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.kpi-card {
  background: var(--c-surface);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--grad-soft);
  color: var(--c-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.kpi-card .kpi-icon svg { width: 20px; height: 20px; }
.kpi-label { font-size: 12.5px; color: var(--c-text-muted); font-weight: 500; margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--c-text); line-height: 1.2; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--c-text-muted); }
.kpi-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; margin-top: 8px; }
.kpi-trend.up { color: var(--c-success); }
.kpi-trend.down { color: var(--c-danger); }
.kpi-trend.flat { color: var(--c-text-muted); }

/* ---------------- Charts ---------------- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.chart-grid .span-2 { grid-column: 1 / -1; }

.chart-card {
  background: var(--c-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border);
  padding: 22px;
}
.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.chart-card-head h3 { font-size: 15.5px; font-weight: 600; margin: 0; }
.chart-card-head .hint { font-size: 12px; color: var(--c-text-muted); }
.chart-body { min-height: 320px; }
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 320px;
  color: var(--c-text-muted);
  font-size: 13.5px;
  text-align: center;
  flex-direction: column;
  gap: 8px;
}

/* ---------------- Table ---------------- */

.table-card {
  background: var(--c-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--c-bg-tint);
  border-radius: 10px;
  padding: 8px 14px;
  min-width: 220px;
}
.search-box svg { width: 16px; height: 16px; color: var(--c-text-muted); flex-shrink: 0; }
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 13.5px;
  width: 100%;
  color: var(--c-text);
}

.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.data-table thead th {
  text-align: left;
  padding: 12px 22px;
  background: var(--c-bg-tint);
  color: var(--c-text-muted);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
table.data-table thead th:hover { color: var(--c-primary-dark); }
table.data-table thead th .sort-arrow { opacity: 0.4; margin-left: 4px; font-size: 11px; }
table.data-table thead th.sorted .sort-arrow { opacity: 1; color: var(--c-accent); }
table.data-table tbody td { padding: 11px 22px; border-top: 1px solid var(--c-border); white-space: nowrap; }
table.data-table tbody tr:hover { background: var(--c-bg-tint); }
.badge-level {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--grad-soft);
  color: var(--c-primary-dark);
}
.table-empty { padding: 40px 22px; text-align: center; color: var(--c-text-muted); font-size: 13.5px; }

/* ---------------- Footer ---------------- */

.site-footer {
  border-top: 1px solid var(--c-border);
  padding: 26px 0 40px;
  margin-top: 20px;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.footer-brand a {
  display: inline-flex;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}
.footer-brand a:hover { opacity: 0.75; }
.footer-brand img {
  height: 30px;
  width: auto;
  flex-shrink: 0;
  opacity: 0.9;
}
.footer-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.footer-source { color: var(--c-text-muted); }

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--c-text-muted);
}

/* ---------------- Loading ---------------- */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.3s ease;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--c-border);
  border-top-color: var(--c-accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Responsive ---------------- */

@media (max-width: 860px) {
  .chart-grid { grid-template-columns: 1fr; }
  .hero { padding-bottom: 110px; }
  .filter-panel { margin-top: -74px; }
  .brand-sub { display: none; }
}

@media (max-width: 560px) {
  .site-header .container { gap: 8px; }
  .nav-switch a { padding: 7px 12px; font-size: 13px; }
  .hero { padding-top: 28px; padding-bottom: 130px; }
  .filter-panel { margin-top: -94px; padding: 18px; }
  .kpi-value { font-size: 22px; }
}
