/* ============================================
   SisPen Snesaka - Main Stylesheet
   Sistem Informasi Penilaian SMPN 1 Kalitengah
   ============================================ */

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

:root {
  --primary: #1a4a7a;
  --primary-light: #2563a8;
  --primary-dark: #0f2d4e;
  --accent: #e8a020;
  --accent-light: #f5c354;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dde4ec;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --shadow-md: 0 4px 20px rgba(0,0,0,.1);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ============ LAYOUT ============ */
.wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  color: #fff;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform .3s ease;
}

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

.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: var(--primary-dark);
  flex-shrink: 0;
}

.sidebar-brand .brand-text { line-height: 1.2; }
.sidebar-brand .brand-name { font-size: 14px; font-weight: 700; color: #fff; }
.sidebar-brand .brand-sub { font-size: 10px; color: rgba(255,255,255,.5); }

.sidebar-menu { padding: 12px 0; flex: 1; }

.menu-section { padding: 16px 20px 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.35); }

.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s;
  border-left: 3px solid transparent;
}

.menu-item:hover { background: rgba(255,255,255,.07); color: #fff; border-left-color: rgba(255,255,255,.3); }
.menu-item.active { background: rgba(232,160,32,.15); color: var(--accent-light); border-left-color: var(--accent); }
.menu-item .icon { width: 18px; text-align: center; font-size: 15px; }

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

.topbar {
  height: var(--header-h);
  background: linear-gradient(135deg, #0f2d4e 0%, #1a4a7a 50%, #1e5a96 100%);
  border-bottom: none;
  box-shadow: 0 2px 20px rgba(15,45,78,.35), 0 1px 0 rgba(255,255,255,.08) inset;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0; z-index: 90;
}

/* Garis aksen bawah topbar */
.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #e8a020 30%, #f5c354 50%, #e8a020 70%, transparent);
  opacity: .7;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.topbar-breadcrumb {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

/* Tanggal & waktu di topbar */
.topbar-datetime {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.topbar-datetime .td-date {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,.95);
  letter-spacing: .2px;
}
.topbar-datetime .td-time {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,.8);
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}

/* Divider vertikal di topbar */
.topbar-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,.15);
}

/* Tombol hamburger */
#toggleSidebar {
  background: rgba(255,255,255,.08) !important;
  border: 1px solid rgba(255,255,255,.12) !important;
  border-radius: 8px !important;
  color: rgba(255,255,255,.8) !important;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
#toggleSidebar:hover {
  background: rgba(255,255,255,.18) !important;
  color: #fff !important;
}

.user-badge {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 40px;
  padding: 5px 14px 5px 5px;
  cursor: pointer;
  transition: all .25s;
  backdrop-filter: blur(6px);
}

.user-badge:hover {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.user-badge .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #e8a020, #f5c354);
  color: #0f2d4e;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(232,160,32,.4);
  flex-shrink: 0;
}

.user-badge .user-info .name {
  font-size: 13px; font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.user-badge .user-info .role {
  font-size: 10px;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  letter-spacing: .4px;
}

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

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

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

.card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }

/* ============ STAT CARDS ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

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

.stat-card.blue::before { background: var(--primary); }
.stat-card.amber::before { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.teal::before { background: var(--info); }

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

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

.stat-card.blue .stat-icon { background: rgba(26,74,122,.1); color: var(--primary); }
.stat-card.amber .stat-icon { background: rgba(232,160,32,.12); color: var(--accent); }
.stat-card.green .stat-icon { background: rgba(22,163,74,.1); color: var(--success); }
.stat-card.teal .stat-icon { background: rgba(8,145,178,.1); color: var(--info); }

.stat-info .label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-info .value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; font-family: 'Lora', serif; }
.stat-info .sub { font-size: 11px; color: var(--text-light); margin-top: 3px; }

/* ============ TABLE ============ */
.table-responsive { overflow-x: auto; }

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}

table.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: var(--surface-2); }

/* ============ BADGE ============ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: rgba(22,163,74,.12); color: #16a34a; }
.badge-danger  { background: rgba(220,38,38,.1); color: #dc2626; }
.badge-warning { background: rgba(217,119,6,.12); color: #d97706; }
.badge-info    { background: rgba(8,145,178,.1); color: #0891b2; }
.badge-blue    { background: rgba(26,74,122,.1); color: var(--primary); }
.badge-gray    { background: rgba(100,116,139,.1); color: #64748b; }

/* ============ BUTTON ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent  { background: var(--accent); color: var(--primary-dark); }
.btn-accent:hover { background: var(--accent-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }

/* ============ FORM ============ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 3px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,168,.12);
}

.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: 12px; color: var(--danger); margin-top: 4px; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

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

/* ============ ALERT ============ */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid transparent;
}

.alert-success { background: rgba(22,163,74,.1); border-color: rgba(22,163,74,.25); color: #15803d; }
.alert-danger  { background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.2); color: #b91c1c; }
.alert-warning { background: rgba(217,119,6,.08); border-color: rgba(217,119,6,.2); color: #b45309; }
.alert-info    { background: rgba(8,145,178,.08); border-color: rgba(8,145,178,.2); color: #0e7490; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}

.modal-backdrop.show { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%; max-width: 540px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: scale(.95) translateY(16px);
  transition: transform .25s;
  overflow: hidden;
}

.modal-backdrop.show .modal { transform: scale(1) translateY(0); }

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

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { width: 30px; height: 30px; border: none; background: none; cursor: pointer; font-size: 18px; color: var(--text-muted); border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ============ PROGRESS ============ */
.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s ease; }

/* ============ PAGINATION ============ */
.pagination { display: flex; gap: 4px; list-style: none; }
.page-item .page-link { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text); border: 1px solid var(--border); transition: all .2s; }
.page-item.active .page-link { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item .page-link:hover { background: var(--bg); }

/* ============ LOGIN PAGE ============ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  top: -200px; right: -200px;
}

.login-wrapper::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(232,160,32,.08);
  bottom: -150px; left: -100px;
}

.login-card {
  background: var(--surface);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  padding: 40px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
  position: relative;
  z-index: 1;
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon { width: 60px; height: 60px; background: var(--primary); border-radius: 16px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--text); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ============ UTILITIES ============ */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }

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

/* Overlay gelap saat sidebar terbuka di mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Tablet (≤992px) ── */
@media (max-width: 992px) {
  :root { --sidebar-w: 240px; }
  .stat-grid { grid-template-columns: repeat(3,1fr); }
  .page-content { padding: 20px; }
  .topbar { padding: 0 20px; }

  /* Sembunyikan datetime di tablet kecil */
  .topbar-datetime .td-date { font-size: 12px; }
  .topbar-datetime .td-time { font-size: 11px; }
}

/* ── Mobile landscape / tablet kecil (≤768px) ── */
@media (max-width: 768px) {
  /* Sidebar jadi drawer */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0 !important; }
  .page-content { padding: 14px; }
  .topbar { padding: 0 14px; }

  /* Sembunyikan datetime di topbar mobile */
  .topbar-datetime, .topbar-divider:first-of-type { display: none; }

  /* Stat grid: 2 kolom */
  .stat-grid { grid-template-columns: repeat(2,1fr); gap: 10px; }

  /* Form rows jadi 1 kolom */
  .form-row.cols-2,
  .form-row.cols-3 { grid-template-columns: 1fr; }

  /* Card header: wrap ke bawah */
  .card-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
  }
  .card-body { padding: 14px; }

  /* Tabel: scroll horizontal */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 500px; }

  /* User badge: sembunyikan nama, tampilkan avatar saja */
  .user-badge .user-info { display: none; }
  .user-badge { padding: 4px; border-radius: 50%; }

  /* Tombol logout: sembunyikan teks */
  .topbar-right > a:last-child span { display: none; }
  .topbar-right > a:last-child { padding: 0 10px; }

  /* Grid 2 kolom kustom di dashboard BK */
  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(2,1fr) !important;
  }

  /* Banner dashboard */
  [style*="justify-content:space-between"][style*="flex-wrap:wrap"] {
    flex-direction: column;
    align-items: flex-start !important;
  }
}

/* ── Mobile portrait (≤480px) ── */
@media (max-width: 480px) {
  .page-content { padding: 10px; }
  .topbar { padding: 0 10px; }
  .topbar-title { font-size: 14px; }

  /* Stat grid: 1 kolom */
  .stat-grid { grid-template-columns: 1fr; gap: 8px; }

  /* Semua form row jadi 1 kolom */
  .form-row { grid-template-columns: 1fr !important; }

  /* Card lebih kompak */
  .card-header { padding: 10px 12px; }
  .card-body { padding: 12px; }

  /* Profil 2 kolom jadi 1 kolom */
  [style*="grid-template-columns:280px"] {
    grid-template-columns: 1fr !important;
  }

  /* BK stat cards: 1 kolom di HP kecil */
  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: 1fr !important;
  }

  /* Tombol aksi tabel: stack */
  .btn.btn-xs { font-size: 11px; padding: 3px 7px; }

  /* Font size tabel lebih kecil */
  table { font-size: 12px; }

  /* Hilangkan padding berlebih di tabel */
  td, th { padding: 6px 8px !important; }

  /* Input absensi: lebih kecil */
  .abs-input { width: 50px !important; }

  /* Sembunyikan beberapa kolom tabel di HP */
  .hide-mobile { display: none !important; }

  /* Badge lebih kecil */
  .badge { font-size: 10px; padding: 2px 6px; }
}

/* ── Pastikan sidebar bisa ditutup dengan klik overlay ── */
@media (min-width: 769px) {
  .sidebar-overlay { display: none !important; }
  .sidebar { transform: none !important; }
  .main-content { margin-left: var(--sidebar-w); }
}
