/* ============================================================
   Pendataan Siswa — Design System
   Referensi: contoh/src/App.tsx + index.css
   Font  : Inter
   Warna : #4a90d9 primary | #1e3a8a dark | #f1f5f9 bg
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary      : #4a90d9;
  --primary-dark : #3a7bc0;
  --primary-light: #eff6ff;
  --dark-blue    : #1e3a8a;
  --bg           : #f1f5f9;   /* slate-100 */
  --surface      : #ffffff;
  --border       : #e2e8f0;   /* slate-200 */
  --border-light : #f1f5f9;
  --text         : #1e293b;   /* slate-800 */
  --text-muted   : #64748b;   /* slate-500 */
  --text-light   : #94a3b8;   /* slate-400 */
  --sidebar-w    : 240px;
  --topbar-h     : 56px;
  --radius       : 12px;
  --shadow-sm    : 0 1px 3px 0 rgb(0 0 0/.10), 0 1px 2px -1px rgb(0 0 0/.10);
  --shadow-md    : 0 4px 6px -1px rgb(0 0 0/.10), 0 2px 4px -2px rgb(0 0 0/.10);
}

body {
  background : var(--bg);
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  color      : var(--text);
  font-size  : 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
  display   : flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.app-sidebar {
  position  : fixed;
  inset     : 0 auto 0 0;
  width     : var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display   : flex;
  flex-direction: column;
  z-index   : 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s ease;
}
.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }

/* Brand / Logo */
.sidebar-brand {
  display    : flex;
  align-items: center;
  gap        : 12px;
  padding    : 20px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.sidebar-brand-icon {
  width : 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.sidebar-brand-title {
  font-size  : 13.5px;
  font-weight: 700;
  color      : var(--dark-blue);
  line-height: 1.2;
  letter-spacing: -.01em;
}
.sidebar-brand-subtitle {
  font-size: 11px;
  color    : var(--text-light);
  margin-top: 2px;
}

/* Nav links */
.sidebar-nav {
  flex   : 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap    : 2px;
}
.sidebar-link {
  display    : flex;
  align-items: center;
  gap        : 10px;
  padding    : 9px 12px;
  border-radius: 10px;
  color      : var(--dark-blue);
  text-decoration: none;
  font-size  : 13.5px;
  font-weight: 500;
  transition : background .15s, color .15s;
  cursor     : pointer;
  border     : none;
  background : transparent;
  width      : 100%;
  text-align : left;
}
.sidebar-link svg, .sidebar-link i {
  color     : var(--primary);
  flex-shrink: 0;
  font-size : 16px;
  width     : 18px;
  height    : 18px;
}
.sidebar-link:hover { background: #f8fafc; color: var(--dark-blue); }
.sidebar-link.active {
  background: var(--primary);
  color     : #fff;
  box-shadow: 0 1px 3px rgb(74 144 217/.35);
}
.sidebar-link.active svg,
.sidebar-link.active i { color: #fff; }

/* Submenu (Mutasi) */
.sidebar-dropdown-toggle .submenu-arrow {
  margin-left: auto;
  font-size  : 12px;
  color      : var(--text-light);
  transition : transform .2s;
}
.sidebar-dropdown-toggle[aria-expanded="true"] .submenu-arrow {
  transform: rotate(90deg);
}
#mutasiSubmenu {
  margin-left: 30px;
  padding    : 2px 0;
  display    : flex;
  flex-direction: column;
  gap        : 2px;
}
#mutasiSubmenu.collapse:not(.show) { display: none; }
.sidebar-sub {
  padding    : 7px 12px;
  font-size  : 13px;
  border-radius: 8px;
  display    : flex;
  align-items: center;
  gap        : 8px;
}
.sidebar-sub::before {
  content      : '';
  width        : 6px;
  height       : 6px;
  border-radius: 50%;
  background   : var(--primary);
  flex-shrink  : 0;
}
.sidebar-sub.active { background: var(--primary); color: #fff; }
.sidebar-sub.active::before { background: #fff; }

/* Footer sidebar */
.sidebar-footer {
  padding    : 12px;
  border-top : 1px solid var(--border-light);
  display    : flex;
  flex-direction: column;
  gap        : 2px;
  flex-shrink: 0;
}
.sidebar-footer .sidebar-link { font-size: 13px; color: var(--text-muted); }
.sidebar-footer .sidebar-link svg,
.sidebar-footer .sidebar-link i { color: var(--text-light); }
.text-danger-soft { color: #ef4444 !important; }
.text-danger-soft svg,
.text-danger-soft i { color: #ef4444 !important; }
.text-danger-soft:hover { background: #fef2f2 !important; }

/* Overlay mobile */
.sidebar-overlay {
  position  : fixed;
  inset     : 0;
  background: rgb(15 23 42/.4);
  backdrop-filter: blur(2px);
  z-index   : 1035;
  opacity   : 0;
  visibility: hidden;
  transition: opacity .25s;
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* ── App Content ──────────────────────────────────────────── */
.app-content {
  flex      : 1;
  margin-left: var(--sidebar-w);
  display   : flex;
  flex-direction: column;
  min-height: 100vh;
  min-width : 0;
  transition: margin-left .25s;
}

/* ── Topbar ───────────────────────────────────────────────── */
.app-topbar {
  height     : var(--topbar-h);
  background : var(--surface);
  border-bottom: 1px solid var(--border);
  display    : flex;
  align-items: center;
  padding    : 0 24px;
  gap        : 12px;
  position   : sticky;
  top        : 0;
  z-index    : 1020;
  box-shadow : 0 1px 2px rgb(0 0 0/.04);
}
.sidebar-toggle {
  display    : none;
  width      : 36px;
  height     : 36px;
  border     : 1px solid var(--border);
  background : #fff;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  font-size  : 18px;
  color      : var(--text-muted);
  cursor     : pointer;
  flex-shrink: 0;
}
.topbar-title {
  font-size  : 14px;
  font-weight: 500;
  color      : var(--text-muted);
}

/* Profile button */
.profile-btn {
  display    : flex;
  align-items: center;
  gap        : 8px;
  border     : none;
  background : transparent;
  padding    : 4px 6px;
  border-radius: 9999px;
  cursor     : pointer;
  transition : background .15s;
}
.profile-btn:hover { background: #f8fafc; }
.profile-avatar {
  width        : 32px;
  height       : 32px;
  border-radius: 50%;
  background   : #2563eb;
  color        : #fff;
  display      : flex;
  align-items  : center;
  justify-content: center;
  font-weight  : 700;
  font-size    : 12px;
  flex-shrink  : 0;
  object-fit   : cover;
}
.profile-avatar-fallback { background: #2563eb; color: #fff; }
.profile-info { text-align: left; line-height: 1.2; }
.profile-name  { font-size: 12px; font-weight: 600; color: var(--text); display: block; }
.profile-email { font-size: 10px; color: var(--text-muted); display: block; }
.profile-chevron { color: var(--text-light); font-size: 12px; }

/* ── Main ─────────────────────────────────────────────────── */
.app-main {
  flex   : 1;
  padding: 24px;
}

/* Page header */
.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-size  : 20px;
  font-weight: 700;
  color      : var(--text);
  margin     : 0 0 2px;
  letter-spacing: -.01em;
}
.page-header p { font-size: 12px; color: var(--text-light); margin: 0; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-grid {
  display              : grid;
  grid-template-columns: repeat(4, 1fr);
  gap                  : 16px;
  margin-bottom        : 20px;
}
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width:  576px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background   : var(--surface);
  border-radius: var(--radius);
  padding      : 20px;
  box-shadow   : var(--shadow-sm);
  border-left  : 4px solid transparent;
  transition   : box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card.blue   { border-left-color: #3b82f6; }
.stat-card.emerald{ border-left-color: #10b981; }
.stat-card.rose   { border-left-color: #f43f5e; }
.stat-card.violet { border-left-color: #8b5cf6; }

.stat-card-top {
  display        : flex;
  align-items    : flex-start;
  justify-content: space-between;
  margin-bottom  : 12px;
}
.stat-card-label {
  font-size     : 11px;
  font-weight   : 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  color         : var(--text-muted);
}
.stat-card-value {
  font-size  : 30px;
  font-weight: 700;
  color      : var(--text);
  margin-top : 4px;
  line-height: 1;
}
.stat-card-icon {
  width        : 40px;
  height       : 40px;
  border-radius: 10px;
  display      : flex;
  align-items  : center;
  justify-content: center;
}
.stat-card-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-card-icon.emerald{ background: #ecfdf5; color: #059669; }
.stat-card-icon.rose   { background: #fff1f2; color: #e11d48; }
.stat-card-icon.violet { background: #f5f3ff; color: #7c3aed; }

.stat-card-footer { font-size: 12px; color: var(--text-light); }
.stat-card-footer strong { color: var(--text-muted); font-weight: 500; }

/* ── Content Grid (Dashboard) ─────────────────────────────── */
.content-grid {
  display              : grid;
  grid-template-columns: 2fr 1fr;
  gap                  : 16px;
}
@media (max-width: 992px) { .content-grid { grid-template-columns: 1fr; } }

/* ── Card Modern ──────────────────────────────────────────── */
.card-modern {
  background   : var(--surface);
  border-radius: var(--radius);
  box-shadow   : var(--shadow-sm);
  overflow     : hidden;
}
.card-modern-header {
  padding        : 16px 20px;
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  border-bottom  : 1px solid var(--border-light);
}
.card-modern-header h3 {
  font-size  : 14px;
  font-weight: 600;
  color      : var(--text);
  margin     : 0;
}
.card-modern-header a {
  font-size  : 12px;
  font-weight: 500;
  color      : var(--primary);
  text-decoration: none;
}
.card-modern-header a:hover { text-decoration: underline; }

/* ── Table Modern ─────────────────────────────────────────── */
.table-modern {
  width          : 100%;
  border-collapse: collapse;
  font-size      : 13px;
}
.table-modern thead th {
  font-size     : 11px;
  font-weight   : 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color         : var(--text-muted);
  padding       : 10px 20px;
  text-align    : left;
  border-bottom : 1px solid var(--border-light);
  white-space   : nowrap;
  background    : #f8fafc;
}
.table-modern tbody tr {
  border-bottom: 1px solid #f8fafc;
  transition   : background .12s;
}
.table-modern tbody tr:last-child { border-bottom: none; }
.table-modern tbody tr:hover { background: #f8fafc; }
.table-modern tbody td { padding: 11px 20px; vertical-align: middle; }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub  { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ── Badge Modern ─────────────────────────────────────────── */
.badge-modern {
  display    : inline-flex;
  align-items: center;
  padding    : 2px 10px;
  border-radius: 9999px;
  font-size  : 11px;
  font-weight: 600;
}
.badge-modern.success { background: #dcfce7; color: #15803d; }
.badge-modern.primary { background: #dbeafe; color: #1d4ed8; }
.badge-modern.danger  { background: #fee2e2; color: #b91c1c; }
.badge-modern.warning { background: #fef3c7; color: #b45309; }
.badge-modern.secondary{ background: #f1f5f9; color: #64748b; }

/* ── Distribusi Kelas ─────────────────────────────────────── */
.kelas-list { padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.kelas-item-top {
  display        : flex;
  justify-content: space-between;
  font-size      : 12px;
  margin-bottom  : 4px;
}
.kelas-item-name  { font-weight: 500; color: var(--text-muted); }
.kelas-item-count { color: var(--text-muted); }
.kelas-progress {
  width        : 100%;
  height       : 6px;
  background   : #f1f5f9;
  border-radius: 9999px;
  overflow     : hidden;
}
.kelas-progress-bar {
  height       : 100%;
  background   : #3b82f6;
  border-radius: 9999px;
  transition   : width .3s;
}

/* ── Footer ───────────────────────────────────────────────── */
.app-footer {
  padding    : 12px 24px;
  border-top : 1px solid var(--border-light);
  background : var(--surface);
  text-align : center;
  font-size  : 12px;
  color      : var(--text-light);
}

/* ── Bootstrap Overrides ──────────────────────────────────── */
.card {
  border       : 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow   : var(--shadow-sm);
  background   : var(--surface);
}
.card-header {
  background   : var(--surface);
  border-bottom: 1px solid var(--border-light);
  font-weight  : 600;
  font-size    : 14px;
  padding      : 14px 20px;
}
.table thead th {
  font-size     : 11px;
  font-weight   : 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color         : var(--text-muted);
  background    : #f8fafc;
  border-bottom : 1px solid var(--border);
  white-space   : nowrap;
}
.table td { font-size: 13px; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

.btn { font-size: 13px; border-radius: 8px; font-weight: 500; }
.btn-sm { font-size: 12px; padding: 4px 10px; border-radius: 6px; }

.btn-brand {
  background  : var(--primary);
  border-color: var(--primary);
  color       : #fff;
  font-weight : 500;
  box-shadow  : 0 1px 2px rgb(0 0 0/.05);
}
.btn-brand:hover {
  background  : var(--primary-dark);
  border-color: var(--primary-dark);
  color       : #fff;
}
.text-brand { color: var(--primary) !important; }

.form-control, .form-select {
  font-size    : 13px;
  border-radius: 8px;
  border-color : var(--border);
  padding      : 8px 12px;
}
.form-control:focus, .form-select:focus {
  border-color: #93c5fd;
  box-shadow  : 0 0 0 3px rgb(59 130 246/.15);
}
.form-label { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.input-group-text { font-size: 13px; background: #f8fafc; border-color: var(--border); }

.alert { font-size: 13px; border-radius: var(--radius); }
.badge { font-size: 11px; font-weight: 600; }
.pagination .page-link { font-size: 13px; border-radius: 6px !important; }
.required::after { content: ' *'; color: #dc2626; }

/* ── Login Page ───────────────────────────────────────────── */
.login-wrapper {
  min-height     : 100vh;
  display        : flex;
  align-items    : center;
  justify-content: center;
  background     : var(--bg);
  padding        : 1rem;
}
.login-card {
  width        : 100%;
  max-width    : 400px;
  border-radius: 16px;
  box-shadow   : var(--shadow-md);
  border       : 1px solid var(--border);
  background   : #fff;
}
.login-logo {
  width          : 96px;
  height         : 96px;
  border-radius  : 16px;
  background     : linear-gradient(135deg, #3b82f6, #1d4ed8);
  color          : #fff;
  display        : flex;
  align-items    : center;
  justify-content: center;
  font-size      : 24px;
  margin         : 0 auto 16px;
  overflow       : hidden;
}
.login-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); box-shadow: none; }
  .app-sidebar.show { transform: translateX(0); box-shadow: var(--shadow-md); }
  .app-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .app-main { padding: 16px; }
  .stat-grid { gap: 12px; }
}

@media (min-width: 992px) {
  body.sidebar-collapsed .app-sidebar { width: 72px; }
  body.sidebar-collapsed .app-content { margin-left: 72px; }
  body.sidebar-collapsed .sidebar-brand-title,
  body.sidebar-collapsed .sidebar-brand-subtitle,
  body.sidebar-collapsed .sidebar-link span,
  body.sidebar-collapsed .submenu-arrow { display: none; }
  body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 16px 0; }
  body.sidebar-collapsed .sidebar-nav { padding: 12px 8px; }
  body.sidebar-collapsed .sidebar-link { justify-content: center; padding: 10px; }
  body.sidebar-collapsed #mutasiSubmenu { display: none !important; }
  body.sidebar-collapsed .sidebar-footer { padding: 8px; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .app-sidebar, .sidebar-overlay, .app-topbar, .app-footer,
  .d-print-none { display: none !important; }
  .app-content { margin-left: 0 !important; }
  body { background: #fff; }
}
