/* ═══════════════════════════════════════════════════════════
   NoomQ Design System v2 — Premium Teacher Platform
   ═══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Prompt:wght@400;600;700;800&display=swap');

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #2563EB;
  --primary-dark:   #1D4ED8;
  --primary-light:  #EFF6FF;
  --primary-glow:   rgba(37,99,235,.15);
  --secondary:      #7C3AED;
  --accent:         #0EA5E9;

  /* Semantic */
  --success:        #059669;
  --success-light:  #ECFDF5;
  --warning:        #D97706;
  --warning-light:  #FFFBEB;
  --danger:         #DC2626;
  --danger-light:   #FEF2F2;

  /* Neutrals */
  --dark:           #0F172A;
  --dark-2:         #1E293B;
  --dark-3:         #334155;
  --gray:           #64748B;
  --gray-light:     #94A3B8;
  --border:         #E2E8F0;
  --border-light:   #F1F5F9;
  --light:          #F8FAFC;
  --white:          #FFFFFF;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 24px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);
  --shadow-xl:  0 20px 40px rgba(0,0,0,.1),  0 8px 16px rgba(0,0,0,.05);

  /* Radius */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  /* Sidebar */
  --sidebar-w:  248px;
  --sidebar-bg: #1D4ED8;
}

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Sarabun', sans-serif;
  background: var(--white);
  transition: background .3s, color .3s;
  color: var(--dark);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4,h5 { font-family: 'Prompt', sans-serif; line-height: 1.3; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

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

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #1A3A6B;
  color: #BFDBFE;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  border-right: 1px solid rgba(0,0,0,.12);
  box-shadow: 3px 0 16px rgba(0,0,0,.18);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 99px; }

.sidebar-logo {
  padding: 18px 20px;
  background: #032e6f;
  /*background: #032e6f;*/
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  position: sticky;
  top: 0;
  z-index: 10;
}
.sidebar-logo img { width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0; object-fit: contain; }
.sidebar-logo .logo-text { font-family: 'Prompt',sans-serif; font-weight: 800; font-size: 16px; color: #fff; letter-spacing: .5px; }
.sidebar-logo span { color: rgba(255,255,255,.65); font-size: 11px; display: block; font-weight: 400; margin-top: 1px; }

.sidebar-menu { padding: 4px 0 16px; }
.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  color: rgba(191,219,254,.75);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all .15s ease;
  border-left: none;
  margin: 1px 8px;
  border-radius: 7px;
}
.sidebar-menu a:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar-menu a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 4px rgba(0,0,0,.15);
}
.sidebar-menu hr { border: none; border-top: 1px solid rgba(255,255,255,.07); margin: 6px 16px; }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 28px 60px; min-height: 100vh; }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--dark); }
.page-header p  { font-size: 13px; color: var(--gray); margin-top: 3px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  transition: background .3s, box-shadow .2s, border-color .2s;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 20px;
  border: 1px solid rgba(226,232,240,.6);
  transition: box-shadow .2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-header h2 { font-size: 15px; font-weight: 700; color: var(--dark-2); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 13.5px;
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .18s ease;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--primary);  color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.btn-success   { background: var(--success);  color: #fff; box-shadow: 0 2px 8px rgba(5,150,105,.3); }
.btn-success:hover { background: #047857; box-shadow: 0 4px 12px rgba(5,150,105,.4); }
.btn-danger    { background: var(--danger);   color: #fff; box-shadow: 0 2px 8px rgba(220,38,38,.25); }
.btn-danger:hover  { background: #B91C1C; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--dark-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-ghost     { background: transparent; color: var(--gray); }
.btn-ghost:hover { background: var(--light); color: var(--dark); }
.btn-sm        { padding: 6px 12px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-lg        { padding: 12px 26px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-icon      { padding: 8px; border-radius: var(--radius-sm); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 13px; font-weight: 600; color: var(--dark-2); margin-bottom: 6px; }
.form-hint   { font-size: 12px; color: var(--gray); margin-top: 4px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: 'Sarabun', sans-serif;
  background: var(--white);
  color: var(--dark);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  appearance: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-control::placeholder { color: var(--gray-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-primary { background: #DBEAFE; color: #1D4ED8; }
.badge-success { background: #DCFCE7; color: #166534; }
.badge-warning { background: #FEF9C3; color: #854D0E; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-gray    { background: #F1F5F9; color: #475569; }
.badge-purple  { background: #EDE9FE; color: #6D28D9; }
.pkg-free   { background: #F1F5F9; color: #475569; }
.pkg-basic  { background: #DBEAFE; color: #1D4ED8; }
.pkg-pro    { background: linear-gradient(90deg,#EDE9FE,#DBEAFE); color: #6D28D9; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-light); color: #065F46; border-color: #A7F3D0; }
.alert-warning { background: var(--warning-light); color: #78350F; border-color: #FDE68A; }
.alert-danger  { background: var(--danger-light);  color: #7F1D1D; border-color: #FECACA; }
.alert-info    { background: var(--primary-light); color: #1E40AF; border-color: #BFDBFE; }

/* ── Stats / KPI Cards ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  transition: all .2s;
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226,232,240,.6);
  transition: all .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue   { background: #DBEAFE; }
.stat-icon.green  { background: #DCFCE7; }
.stat-icon.purple { background: #EDE9FE; }
.stat-icon.orange { background: #FEF3C7; }
.stat-icon.red    { background: #FEE2E2; }
.stat-value { font-size: 26px; font-weight: 800; font-family: 'Prompt',sans-serif; line-height: 1.1; color: var(--dark); }
.stat-label { font-size: 12px; color: var(--gray); margin-top: 3px; font-weight: 500; }
.stat-change { font-size: 12px; margin-top: 3px; font-weight: 600; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { background: var(--light); }
th {
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--dark-2);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--light); }

/* ── Score bars ──────────────────────────────────────────────── */
.score-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.score-name { width: 120px; font-size: 13px; font-weight: 600; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-bar-wrap { flex: 1; background: var(--light); border-radius: 99px; height: 10px; overflow: hidden; }
.score-bar { height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--accent)); min-width: 4px; transition: width .4s ease; display: flex; align-items: center; padding-left: 6px; font-size: 10px; color: #fff; font-weight: 700; }
.score-num { font-size: 13px; font-weight: 700; color: var(--dark); min-width: 44px; text-align: right; }
.progress-wrap { background: var(--light); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar  { height: 8px; border-radius: 99px; transition: width .4s; }

/* ── Flash messages ──────────────────────────────────────────── */
.flash-wrap { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.flash {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  border-left: 4px solid var(--success);
  animation: slideIn .3s ease;
  pointer-events: all;
}
.flash.danger { border-left-color: var(--danger); }
.flash.warning { border-left-color: var(--warning); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(.95) translateY(10px); } to { opacity:1; transform: scale(1) translateY(0); } }

/* ── Dividers ────────────────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Utilities ───────────────────────────────────────────────── */
.text-gray   { color: var(--gray); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.font-bold   { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
