/* ============================================================
   Attendify — Custom styles & design tokens
   ============================================================ */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-soft: #EFF6FF;
  --sidebar: #0F172A;
  --sidebar-hover: #1E293B;
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --muted: #64748B;
  --success: #16A34A;
  --warning: #F59E0B;
  --info: #0EA5E9;
  --purple: #7C3AED;
  --danger: #DC2626;
  --radius-card: 12px;
  --radius-control: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text); }
h1 { font-size: 1.5rem; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar);
  color: #CBD5E1;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width .2s ease, transform .2s ease;
  overflow: hidden;
}
.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff;
  flex-shrink: 0;
}
.sidebar-brand .logo-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  display: grid; place-items: center;
  color: #fff; font-size: 1rem;
  flex-shrink: 0;
}
.sidebar-brand .brand-text { font-weight: 800; font-size: 1.05rem; letter-spacing: .2px; white-space: nowrap; }
.sidebar-brand small { display: block; font-size: .65rem; font-weight: 400; color: #94A3B8; }

.sidebar-nav {
  padding: 12px 10px 90px;
  overflow-y: auto;
  flex: 1;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.nav-section {
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #64748B;
  padding: 14px 12px 6px;
  white-space: nowrap;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #CBD5E1;
  font-weight: 500;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  white-space: nowrap;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active {
  background: var(--primary);
  color: #fff;
  border-left-color: #93C5FD;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .25);
}
.sidebar-foot {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 12px 18px;
  font-size: .7rem;
  color: #64748B;
  background: linear-gradient(transparent, rgba(15,23,42,.95));
  white-space: nowrap;
}

/* Collapsed desktop */
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .nav-section,
body.sidebar-collapsed .sidebar .sidebar-link span,
body.sidebar-collapsed .sidebar .sidebar-foot { display: none; }
body.sidebar-collapsed .sidebar-link { justify-content: center; padding: 11px; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
body.sidebar-collapsed .main-wrap { margin-left: var(--sidebar-collapsed); }

/* ---------- Main / topbar ---------- */
.main-wrap { margin-left: var(--sidebar-width); min-height: 100vh; transition: margin .2s ease; }

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  z-index: 1030;
}
.topbar .btn-toggle {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
}
.breadcrumb { margin: 0; font-size: .8rem; }
.breadcrumb-item + .breadcrumb-item::before { content: "›"; color: #94A3B8; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .active { color: var(--text); font-weight: 600; }

.ta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid #DBEAFE;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 0;
  padding: 4px 6px;
  border-radius: 9px;
}
.user-chip:hover { background: #F1F5F9; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
  color: var(--primary-dark);
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem;
  flex-shrink: 0;
}
.avatar-lg { width: 72px; height: 72px; font-size: 1.4rem; }
.user-meta { line-height: 1.15; text-align: left; }
.user-meta strong { display: block; font-size: .8rem; }
.user-meta small { color: var(--muted); font-size: .68rem; }

.content { padding: 24px; max-width: 1320px; margin: 0 auto; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 1.45rem; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.footer {
  padding: 18px 24px 28px;
  color: var(--muted);
  font-size: .74rem;
  text-align: center;
}

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-header h2, .card-header h3 { font-size: .95rem; margin: 0; }
.card-body { padding: 18px; }
.card-footer { background: transparent; border-top: 1px solid var(--border); padding: 12px 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 13px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon.blue { background: #EFF6FF; color: #2563EB; }
.stat-icon.green { background: #F0FDF4; color: #16A34A; }
.stat-icon.amber { background: #FFFBEB; color: #D97706; }
.stat-icon.purple { background: #F5F3FF; color: #7C3AED; }
.stat-icon.red { background: #FEF2F2; color: #DC2626; }
.stat-value { font-size: 1.45rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: .72rem; color: var(--muted); font-weight: 500; }

.progress { background: #E2E8F0; border-radius: 999px; }
.progress-bar { background: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { margin: 0; font-size: .82rem; vertical-align: middle; }
.table thead th {
  background: #F8FAFC;
  color: var(--muted);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  white-space: nowrap;
}
.table tbody td { padding: 10px 12px; border-color: #EEF2F7; }
.table tbody tr:hover { background: #F8FAFC; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-tight td, .table-tight th { padding: 6px 8px !important; }

.table-matrix th, .table-matrix td { text-align: center; padding: 6px; font-size: .74rem; }
.table-matrix .sticky-col { position: sticky; left: 0; background: #fff; z-index: 2; text-align: left; min-width: 160px; }
.table-matrix thead .sticky-col { background: #F8FAFC; z-index: 3; }
.cell-h { color: #15803D; background: #F0FDF4; font-weight: 700; }
.cell-t { color: #B45309; background: #FFFBEB; font-weight: 700; }
.cell-i { color: #0369A1; background: #F0F9FF; font-weight: 700; }
.cell-s { color: #6D28D9; background: #F5F3FF; font-weight: 700; }
.cell-a { color: #B91C1C; background: #FEF2F2; font-weight: 700; }
.cell-legend { display: inline-flex; gap: 10px; flex-wrap: wrap; font-size: .72rem; color: var(--muted); }
.cell-legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 4px; }

/* ---------- Badges ---------- */
.badge-status {
  font-weight: 600;
  font-size: .68rem;
  padding: .38em .6em;
  border-radius: 6px;
  white-space: nowrap;
}
.badge-hadir { background: #DCFCE7; color: #15803D; }
.badge-terlambat { background: #FEF3C7; color: #B45309; }
.badge-izin { background: #E0F2FE; color: #0369A1; }
.badge-sakit { background: #EDE9FE; color: #6D28D9; }
.badge-alfa { background: #FEE2E2; color: #B91C1C; }
.badge-secondary { background: #E2E8F0; color: #475569; }
.badge-soft { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

/* ---------- Forms ---------- */
.form-label { font-size: .78rem; font-weight: 600; margin-bottom: 5px; }
.form-label .req { color: var(--danger); }
.form-control, .form-select {
  border-radius: var(--radius-control);
  border-color: #CBD5E1;
  font-size: .84rem;
  padding: .48rem .7rem;
  min-height: 38px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.form-text { font-size: .7rem; color: var(--muted); }
.invalid-feedback.d-block { font-size: .72rem; }
.btn { border-radius: var(--radius-control); font-size: .82rem; font-weight: 600; padding: .48rem .85rem; }
.btn-sm { font-size: .74rem; padding: .34rem .6rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-icon { width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0; }

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  background: #FCFDFF;
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-visual {
  background: radial-gradient(circle at 20% 10%, #1E3A8A, #0F172A 60%);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-visual::after {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,.35), transparent 65%);
  bottom: -180px; right: -120px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.3rem; position: relative; z-index: 1; }
.auth-brand .logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--primary); display: grid; place-items: center; }
.auth-copy { position: relative; z-index: 1; max-width: 440px; }
.auth-copy h2 { font-size: 2.2rem; line-height: 1.2; color: #fff; margin-bottom: 16px; }
.auth-copy p { color: #CBD5E1; font-size: .9rem; line-height: 1.7; }
.auth-features { display: grid; gap: 10px; margin-top: 22px; }
.auth-features div { display: flex; gap: 10px; align-items: center; color: #E2E8F0; font-size: .82rem; }
.auth-features i { color: #60A5FA; }
.auth-panel { background: var(--surface); display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-form { width: 100%; max-width: 390px; }
.auth-form h1 { font-size: 1.7rem; margin-bottom: 4px; }
.auth-form .sub { color: var(--muted); font-size: .84rem; margin-bottom: 24px; }
.auth-footer { text-align: center; color: var(--muted); font-size: .72rem; margin-top: 18px; }

/* ---------- Absensi input ---------- */
.absensi-list { display: grid; gap: 10px; }
.absensi-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}
.absensi-row .student-name { font-weight: 600; font-size: .86rem; }
.absensi-row .student-nis { color: var(--muted); font-size: .7rem; }
.status-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.status-group input { position: absolute; opacity: 0; pointer-events: none; }
.status-group label {
  min-width: 40px;
  padding: 7px 10px;
  text-align: center;
  font-size: .76rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
  user-select: none;
  transition: background .12s, color .12s;
}
.status-group label:last-child { border-right: 0; }
.status-group input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: -2px; }
.status-group input:checked + label.s-h { background: var(--success); color: #fff; }
.status-group input:checked + label.s-t { background: var(--warning); color: #fff; }
.status-group input:checked + label.s-i { background: var(--info); color: #fff; }
.status-group input:checked + label.s-s { background: var(--purple); color: #fff; }
.status-group input:checked + label.s-a { background: var(--danger); color: #fff; }
.absensi-sticky {
  position: sticky;
  bottom: 0;
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--border);
  padding: 12px 0;
  z-index: 5;
}
.absensi-summary { font-size: .78rem; color: var(--muted); font-weight: 600; }
.unsaved-badge { display: none; }
body.is-dirty .unsaved-badge { display: inline-flex; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 38px 16px; color: var(--muted); }
.empty-state i { font-size: 2.2rem; color: #CBD5E1; display: block; margin-bottom: 10px; }
.empty-state p { margin: 0 0 12px; font-size: .84rem; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid #E2E8F0; margin-left: 6px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline .t-time { font-size: .68rem; color: var(--muted); }
.timeline .t-text { font-size: .78rem; }
.schedule-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; margin-bottom: 9px; background: #fff;
}
.schedule-time { font-weight: 800; font-size: .78rem; color: var(--primary-dark); background: var(--primary-soft); border-radius: 7px; padding: 7px 9px; min-width: 58px; text-align: center; }
.schedule-main { flex: 1; min-width: 0; }
.schedule-main strong { display: block; font-size: .84rem; }
.schedule-main small { color: var(--muted); font-size: .7rem; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .7rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.alert { border-radius: 10px; font-size: .82rem; border: 0; }
.alert-success { background: #F0FDF4; color: #15803D; }
.alert-danger { background: #FEF2F2; color: #B91C1C; }
.alert-info { background: #EFF6FF; color: #1D4ED8; }
.alert-warning { background: #FFFBEB; color: #B45309; }
.modal-content { border-radius: 14px; border: 0; box-shadow: 0 20px 50px rgba(15,23,42,.18); }
.modal-header, .modal-footer { border-color: var(--border); }
.dropdown-menu { border-radius: 10px; border-color: var(--border); box-shadow: 0 8px 24px rgba(15,23,42,.12); font-size: .82rem; }
.dropdown-item { padding: .5rem .8rem; }
.dropdown-item i { width: 18px; }
.nav-tabs .nav-link { font-size: .8rem; font-weight: 600; color: var(--muted); }
.nav-tabs .nav-link.active { color: var(--primary); }
.text-muted-sm { font-size: .72rem; color: var(--muted); }
.nowrap { white-space: nowrap; }
.w-fit { width: fit-content; }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 20px 0 50px rgba(15,23,42,.25); }
  body.sidebar-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 1035;
  }
  .main-wrap { margin-left: 0 !important; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-width); }
  .content { padding: 18px 14px; }
  .topbar { padding: 0 14px; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .page-head h1 { font-size: 1.25rem; }
}
@media (max-width: 575.98px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; gap: 9px; }
  .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
  .stat-value { font-size: 1.15rem; }
  .status-group label { min-width: 34px; padding: 7px 8px; }
  .absensi-row { padding: 10px; }
  .table { font-size: .76rem; }
  .topbar .ta-pill { display: none; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .page-actions, .footer, .no-print { display: none !important; }
  .main-wrap { margin: 0 !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; font-size: 11px; }
  .card { box-shadow: none; border: 0; }
  .table thead th { background: #F1F5F9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cell-h, .cell-t, .cell-i, .cell-s, .cell-a { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; }
}
