/* ================================================================
   KESIS — Dashboard Enhancement CSS
   Tambahkan di: public/css/dashboard-enhanced.css
   Lalu link di views/layouts/main.ejs setelah style.css:
   <link href="/css/dashboard-enhanced.css" rel="stylesheet">
   ================================================================ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── CSS Variables Override ── */
:root {
  --primary:        #2563eb;
  --primary-light:  #eff6ff;
  --primary-dark:   #1e40af;
  --success:        #16a34a;
  --warning:        #d97706;
  --danger:         #dc2626;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #e2e8f0;
  --text-1:         #0f172a;
  --text-2:         #475569;
  --text-3:         #94a3b8;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 12px 40px rgba(0,0,0,.12);
  --font-main:      'DM Sans', sans-serif;
  --font-mono:      'DM Mono', monospace;
  --sidebar-w:      240px;
  --topbar-h:       58px;
}

body {
  font-family: var(--font-main);
  background: #f1f5f9;
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
}

/* ════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════ */
.sidebar {
  background: #0f172a;
  border-right: none;
  box-shadow: 4px 0 24px rgba(0,0,0,.15);
}

.sb-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sb-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #2563eb);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}

.sb-appname strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: .2px;
}

.sb-appname small {
  font-size: 10.5px;
  color: #64748b;
}

/* User card di sidebar */
.sb-usercard {
  margin: 12px 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.05);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.06);
}

.sb-ava {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}

.sb-ava img { width: 100%; height: 100%; object-fit: cover; }

.sb-uname {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.sb-urole {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.role-admin    { background: rgba(99,102,241,.2);  color: #a5b4fc; }
.role-tatib    { background: rgba(234,88,12,.2);   color: #fb923c; }
.role-piket_kbm{ background: rgba(16,185,129,.2);  color: #6ee7b7; }
.role-wali_kelas{ background: rgba(245,158,11,.2); color: #fcd34d; }
.role-petugas  { background: rgba(100,116,139,.2); color: #94a3b8; }

/* Section label */
.sb-section {
  padding: 14px 16px 5px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #475569;
}

/* Menu item */
.sb-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 1px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s ease;
  position: relative;
}

.sb-item a:hover {
  background: rgba(255,255,255,.06);
  color: #e2e8f0;
}

.sb-item.active a {
  background: linear-gradient(135deg, rgba(99,102,241,.2), rgba(37,99,235,.15));
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,.25);
}

.sb-item.active .sb-ico { color: #818cf8; }

.sb-ico {
  width: 20px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sb-lbl { flex: 1; }

.sb-cnt {
  background: #ef4444;
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 20px;
  min-width: 16px;
  text-align: center;
}

.sb-scroll { flex: 1; overflow-y: auto; padding-bottom: 8px; }
.sb-scroll::-webkit-scrollbar { width: 0; }

.sb-footer {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sb-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}

.sb-logout:hover {
  background: rgba(239,68,68,.1);
  color: #f87171;
}

/* ════════════════════════════════════════
   TOPBAR
   ════════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.tb-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -.2px;
}

.tb-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.tb-toggle:hover { background: var(--border); color: var(--text-1); }

.tb-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all .15s;
}

.tb-btn:hover { background: var(--border); color: var(--text-1); }

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid white;
  font-size: 0;
}

.tb-userBtn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  transition: all .15s;
}

.tb-userBtn:hover { background: var(--border); }

.tb-ava {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #6366f1, #2563eb);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  overflow: hidden;
}

.tb-ava img { width: 100%; height: 100%; object-fit: cover; }

/* ════════════════════════════════════════
   PAGE HEADER
   ════════════════════════════════════════ */
.page-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.page-hdr-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -.3px;
}

.page-hdr-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ════════════════════════════════════════
   STAT CARDS — Versi baru
   ════════════════════════════════════════ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow .2s, transform .2s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-ico {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.si-blue  { background: #eff6ff; color: #2563eb; }
.si-red   { background: #fef2f2; color: #dc2626; }
.si-amber { background: #fffbeb; color: #d97706; }
.si-green { background: #f0fdf4; color: #16a34a; }
.si-purple{ background: #f5f3ff; color: #7c3aed; }

/* Accent bar per warna */
.stat-card:has(.si-blue)::before   { background: #2563eb; }
.stat-card:has(.si-red)::before    { background: #dc2626; }
.stat-card:has(.si-amber)::before  { background: #d97706; }
.stat-card:has(.si-green)::before  { background: #16a34a; }
.stat-card:has(.si-purple)::before { background: #7c3aed; }

.stat-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
  letter-spacing: -.5px;
  font-family: var(--font-mono);
}

.stat-lbl {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ════════════════════════════════════════
   CARDS (umum)
   ════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px !important;
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border) !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-1);
}

.card-header i { opacity: .85; }

.card-footer {
  padding: 12px 18px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* ════════════════════════════════════════
   TABEL
   ════════════════════════════════════════ */
.tbl-wrap { overflow-x: auto; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl thead th {
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  white-space: nowrap;
}

.tbl tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-1);
  vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: none; }

.tbl tbody tr:hover td {
  background: #f8fafc;
}

.tbl tbody tr[data-href] { cursor: pointer; }

/* ════════════════════════════════════════
   BADGE / PILL
   ════════════════════════════════════════ */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.pill-ringan  { background: #eff6ff; color: #1d4ed8; }
.pill-sedang  { background: #fffbeb; color: #b45309; }
.pill-berat   { background: #fef2f2; color: #b91c1c; }

/* ════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════ */
.btn {
  font-family: var(--font-main);
  font-weight: 500;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all .15s;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-2);
}

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

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}

/* ════════════════════════════════════════
   KEHADIRAN CARD
   ════════════════════════════════════════ */
.kehadiran-mini {
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  transition: transform .2s;
}

.kehadiran-mini:hover { transform: scale(1.03); }

.kehadiran-mini .kh-val {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  font-family: var(--font-mono);
}

.kehadiran-mini .kh-lbl {
  font-size: 10.5px;
  margin-top: 4px;
  font-weight: 500;
  opacity: .75;
}

/* ════════════════════════════════════════
   FLASH MESSAGES
   ════════════════════════════════════════ */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideDown .3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flash-ok  { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.flash-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ════════════════════════════════════════
   PAGE BODY
   ════════════════════════════════════════ */
.page-body {
  padding: 24px;
  min-height: calc(100vh - var(--topbar-h) - 48px);
  max-width: 1400px;
}

.page-footer {
  padding: 14px 24px;
  font-size: 12px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}

/* ════════════════════════════════════════
   GRAFIK / CHART AREA
   ════════════════════════════════════════ */
.card-body canvas {
  max-height: 240px;
}

/* ════════════════════════════════════════
   NOTIF PANEL
   ════════════════════════════════════════ */
#notifPanel {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border) !important;
}

.notif-item:hover { background: var(--surface-2) !important; }

/* ════════════════════════════════════════
   SISWA BAHAYA CARD
   ════════════════════════════════════════ */
.card[style*="border-left:4px solid #dc2626"] {
  border-left: 4px solid #dc2626 !important;
  border-radius: var(--radius) !important;
}

/* ════════════════════════════════════════
   PROGRESS BAR PER KELAS
   ════════════════════════════════════════ */
.progress-bar-wrap {
  background: #f1f5f9;
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}

/* ════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}

.empty i {
  font-size: 36px;
  display: block;
  margin-bottom: 10px;
  opacity: .5;
}

.empty p { font-size: 13.5px; margin: 0; }

/* ════════════════════════════════════════
   DARK MODE
   ════════════════════════════════════════ */
body.dark {
  --surface:   #1e293b;
  --surface-2: #0f172a;
  --border:    #334155;
  --text-1:    #f1f5f9;
  --text-2:    #94a3b8;
  --text-3:    #64748b;
  background:  #0f172a;
}

body.dark .card       { box-shadow: none; }
body.dark .topbar     { background: #1e293b; border-color: #334155; }
body.dark .stat-card  { background: #1e293b; border-color: #334155; }
body.dark .tbl thead th { background: #0f172a; }
body.dark .tbl tbody tr:hover td { background: #1e293b; }
body.dark .tb-userBtn { background: #334155; border-color: #475569; color: #e2e8f0; }
body.dark .tb-btn,
body.dark .tb-toggle  { background: #334155; color: #94a3b8; }
body.dark .btn-secondary { background: #334155; border-color: #475569; color: #94a3b8; }

/* ════════════════════════════════════════
   DROPDOWN MENU
   ════════════════════════════════════════ */
.dropdown-menu {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
  font-size: 13px;
}

.dropdown-item {
  padding: 8px 14px !important;
  border-radius: 6px;
  margin: 2px 6px;
  width: calc(100% - 12px);
}

.dropdown-item:hover { background: var(--surface-2) !important; }

/* ════════════════════════════════════════
   MODALS
   ════════════════════════════════════════ */
.modal-content {
  border-radius: var(--radius) !important;
  border: none !important;
  box-shadow: var(--shadow-lg) !important;
}

/* ════════════════════════════════════════
   CODE (no surat)
   ════════════════════════════════════════ */
code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--primary);
  border: 1px solid var(--border);
}

/* ════════════════════════════════════════
   ACADEMIC DASHBOARD UTILITIES
   ════════════════════════════════════════ */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}
.hover-lift:hover {
  transform: translateY(-4px) !important;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
}
.fw-800 { font-weight: 800 !important; }
.ls-1 { letter-spacing: 1px; }
.uppercase { text-transform: uppercase; }
.bg-primary-subtle { background-color: rgba(37, 99, 235, 0.1) !important; }
.bg-warning-subtle { background-color: rgba(217, 119, 6, 0.1) !important; }
.bg-success-subtle { background-color: rgba(22, 163, 74, 0.1) !important; }
.bg-info-subtle    { background-color: rgba(8, 145, 178, 0.1) !important; }

.stat-card:nth-child(1) { animation-delay: .05s; }
.stat-card:nth-child(2) { animation-delay: .10s; }
.stat-card:nth-child(3) { animation-delay: .15s; }
.stat-card:nth-child(4) { animation-delay: .20s; }

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

/* ════════════════════════════════════════
   ALERT OVERRIDE
   ════════════════════════════════════════ */
.alert {
  border-radius: var(--radius-sm) !important;
  font-size: 13.5px;
}

.alert-success {
  background: #f0fdf4 !important;
  border-color: #bbf7d0 !important;
  color: #15803d !important;
}

.alert-warning {
  background: #fffbeb !important;
  border-color: #fde68a !important;
  color: #92400e !important;
}

/* ════════════════════════════════════════
   SCROLLBAR GLOBAL
   ════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ════════════════════════════════════════
   FLOATING FOOTER OVERRIDE
   ════════════════════════════════════════ */
.tatib-floating-footer {
  backdrop-filter: blur(8px);
}

/* ════════════════════════════════════════
   FIX: SIDEBAR GROUP TOGGLE
   ════════════════════════════════════════ */
.sidebar .sb-group-toggle {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 12px !important;
  margin: 1px 8px !important;
  border-radius: 8px !important;
  color: #94a3b8 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  min-height: 44px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  width: calc(100% - 16px) !important;
  border: none !important;
  background: none !important;
  box-sizing: border-box !important;
}

.sidebar .sb-group-toggle:hover {
  background: rgba(255,255,255,.06) !important;
  color: #e2e8f0 !important;
}

.sidebar .sb-group-toggle.active {
  background: linear-gradient(135deg, rgba(99,102,241,.2), rgba(37,99,235,.15)) !important;
  color: #a5b4fc !important;
  border: 1px solid rgba(99,102,241,.25) !important;
}

.sidebar .sb-group-toggle .sb-ico {
  width: 20px !important;
  font-size: 15px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  color: inherit !important;
}

.sidebar .sb-group-toggle .sb-lbl {
  flex: 1 !important;
  display: block !important;
  color: inherit !important;
}

.sidebar .sb-group-toggle .sb-chev {
  display: block !important;
  color: rgba(255,255,255,.4) !important;
  font-size: 11px !important;
  margin-left: auto !important;
}