/* ============================================
   JEJAK IMPIAN - Main Stylesheet
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
  /* Brand Colors */
  --primary: #1E3A5F;
  --primary-light: #2563EB;
  --primary-lighter: #EFF6FF;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  
  /* Semantic Colors */
  --success: #10B981;
  --success-bg: #ECFDF5;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --info: #06B6D4;
  --info-bg: #ECFEFF;
  
  /* Neutrals */
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  
  /* Sidebar */
  --sidebar-bg: #0F2340;
  --sidebar-width: 220px;
  --sidebar-text: #94A3B8;
  --sidebar-text-active: #FFFFFF;
  --sidebar-active-bg: #1E3A5F;
  
  /* Layout */
  --topbar-height: 60px;
  --card-radius: 12px;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-display: 'Plus Jakarta Sans', sans-serif;
}

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

body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--gray-700);
  background: var(--gray-50);
  line-height: 1.5;
}

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

/* ============================================
   LAYOUT
   ============================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

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

.brand-logo {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-logo svg { width: 22px; height: 22px; fill: white; }

.brand-text .brand-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

.brand-text .brand-sub {
  font-size: 11px;
  color: var(--sidebar-text);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-label {
  padding: 8px 18px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(148,163,184,0.5);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: all 0.15s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-item svg {
  width: 18px; height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ---- Main Content ---- */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Topbar ---- */

.topbar {
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--gray-600);
}

.topbar-toggle svg { width: 22px; height: 22px; }

.topbar-spacer { flex: 1; }

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-search input {
  background: var(--gray-100);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 12px 7px 36px;
  font-size: 13px;
  width: 220px;
  color: var(--gray-700);
  transition: all 0.2s;
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
}

.topbar-search .search-icon {
  position: absolute;
  left: 10px;
  color: var(--gray-400);
  width: 16px; height: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notif-btn {
  position: relative;
  background: none;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--gray-500);
  transition: background 0.15s;
}

.notif-btn:hover { background: var(--gray-100); }
.notif-btn svg { width: 20px; height: 20px; }

.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 16px; height: 16px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  color: white;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.user-menu:hover { background: var(--gray-100); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-info { line-height: 1.2; }

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.user-role {
  font-size: 11px;
  color: var(--gray-500);
}

/* ---- Page Content ---- */

.page-content {
  padding: 24px;
  flex: 1;
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}

.page-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background: white;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--gray-100);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body { padding: 20px; }

/* ---- Stat Cards ---- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: var(--card-radius);
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.2s, transform 0.2s;
}

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

.stat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.blue { background: #EFF6FF; color: #3B82F6; }
.stat-icon.green { background: #ECFDF5; color: #10B981; }
.stat-icon.orange { background: #FFF7ED; color: #F97316; }
.stat-icon.purple { background: #F5F3FF; color: #8B5CF6; }
.stat-icon.red { background: #FEF2F2; color: #EF4444; }

.stat-label {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.stat-value.money { font-size: 18px; }

.stat-link {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.stat-link:hover { text-decoration: underline; }

/* ============================================
   GRID LAYOUTS
   ============================================ */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-cols-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.grid-cols-2-3 { display: grid; grid-template-columns: 2fr 3fr; gap: 16px; }

.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }

/* ============================================
   TABLE
   ============================================ */

.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-warning { background: var(--warning-bg); color: #D97706; }
.badge-info    { background: var(--info-bg);    color: #0891B2; }
.badge-primary { background: var(--primary-lighter); color: var(--primary-light); }

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-success { background: var(--success); color: white; }
.btn-danger  { background: var(--danger);  color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ============================================
   FORMS
   ============================================ */

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font-sans);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #1a56a4 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.login-header {
  background: var(--sidebar-bg);
  padding: 32px 36px 24px;
  text-align: center;
}

.login-logo {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}

.login-logo svg { width: 30px; height: 30px; fill: white; }

.login-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

.login-sub {
  font-size: 12px;
  color: var(--sidebar-text);
  margin-top: 4px;
}

.login-body {
  padding: 28px 36px 32px;
}

.login-body .form-group { margin-bottom: 18px; }

.login-body .btn {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 14px;
  margin-top: 8px;
}

/* ============================================
   CHARTS (Canvas)
   ============================================ */

.chart-container {
  position: relative;
  height: 200px;
}

/* ============================================
   DONUT CHART (CSS)
   ============================================ */

.donut-wrapper {
  display: flex;
  align-items: center;
  gap: 24px;
}

.donut-chart {
  position: relative;
  width: 130px;
  height: 130px;
  flex-shrink: 0;
}

.donut-chart svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  line-height: 1.2;
}

.donut-center .donut-total-label {
  font-size: 10px;
  color: var(--gray-500);
}

.donut-center .donut-total-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}

.donut-legend { flex: 1; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12.5px;
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label { color: var(--gray-600); flex: 1; }
.legend-value { font-weight: 600; color: var(--gray-800); }

/* ============================================
   CALENDAR / JADWAL LIST
   ============================================ */

.jadwal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}

.jadwal-item:last-child { border-bottom: none; }

.jadwal-time {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
  min-width: 95px;
}

.jadwal-info { flex: 1; }

.jadwal-murid {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.jadwal-mapel {
  font-size: 11.5px;
  color: var(--gray-500);
}

.jadwal-tentor {
  font-size: 11.5px;
  color: var(--gray-500);
  min-width: 80px;
}

/* ============================================
   CATATAN SECTION
   ============================================ */

.catatan-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

.catatan-item:last-child { border-bottom: none; }

.catatan-body { flex: 1; }

.catatan-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.catatan-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.catatan-date {
  font-size: 11px;
  color: var(--gray-400);
}

.catatan-text {
  font-size: 12.5px;
  color: var(--gray-600);
  line-height: 1.5;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: translateY(20px);
  transition: transform 0.2s;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--gray-400);
  border-radius: 6px;
  transition: background 0.15s;
}

.modal-close:hover { background: var(--gray-100); }

.modal-body { padding: 22px; }

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================
   FLASH / ALERT
   ============================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-success { background: var(--success-bg); color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger  { background: var(--danger-bg);  color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: var(--warning-bg); color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: var(--info-bg);    color: #155E75; border: 1px solid #A5F3FC; }

/* ============================================
   PROFILE / MURID CARD
   ============================================ */

.murid-profile {
  display: flex;
  align-items: center;
  gap: 14px;
}

.murid-photo {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gray-200);
}

.murid-photo-placeholder {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary-lighter);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-light);
}

.murid-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  font-family: var(--font-display);
}

.murid-sub { font-size: 12.5px; color: var(--gray-500); }

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
}

/* ============================================
   SELECT DROPDOWN (Filter)
   ============================================ */

.filter-select {
  padding: 5px 28px 5px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  font-size: 12px;
  color: var(--gray-600);
  background-color: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  appearance: none;
  cursor: pointer;
}

/* ============================================
   LINK BUTTON
   ============================================ */

.link-btn {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--gray-300); }
.empty-state p { font-size: 13px; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar-toggle { display: flex; }
  .grid-2, .grid-cols-3-2, .grid-cols-2-3 {
    grid-template-columns: 1fr;
  }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}
