/* ==========================================================================
   ABSENSI GURU — Design System
   Sistem Informasi Absensi Guru | Premium Admin Dashboard
   ========================================================================== */

:root {
  /* Brand */
  --primary: #2563EB;
  --primary-rgb: 37, 99, 235;
  --secondary: #1D4ED8;
  --primary-tint: #EFF4FF;
  --primary-tint-2: #DCE8FF;

  /* Surfaces */
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --card-soft: #F1F5F9;
  --border: #E2E8F0;
  --border-soft: #EDF1F7;

  /* Text */
  --text: #0F172A;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  /* Status */
  --success: #16A34A;
  --success-tint: #E9F9EF;
  --warning: #F59E0B;
  --warning-tint: #FEF6E7;
  --danger: #DC2626;
  --danger-tint: #FDECEC;
  --info: #0EA5E9;
  --info-tint: #E7F7FE;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 20px -6px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 20px 45px -12px rgba(15, 23, 42, 0.18);
  --shadow-primary: 0 12px 24px -10px rgba(37, 99, 235, 0.45);

  /* Geometry */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --sidebar-w: 272px;
  --sidebar-w-collapsed: 88px;
  --topbar-h: 76px;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --fast: 150ms;
  --med: 260ms;

  /* Fonts */
  --font-display: 'Lexend', 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #0B1220;
  --card: #121A2B;
  --card-soft: #182338;
  --border: #24304A;
  --border-soft: #1C273D;

  --text: #EAF1FB;
  --text-muted: #93A3BE;
  --text-faint: #64748B;

  --primary-tint: #16233F;
  --primary-tint-2: #1B2C4E;
  --success-tint: #10281C;
  --warning-tint: #2E230D;
  --danger-tint: #2C1418;
  --info-tint: #0D2532;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 25px 50px -15px rgba(0, 0, 0, 0.65);
}

/* ==========================================================================
   Reset / Base
   ========================================================================== */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  transition: background var(--med) var(--ease), color var(--med) var(--ease);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

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

.text-muted-c { color: var(--text-muted) !important; }
.text-faint { color: var(--text-faint) !important; }
.mono { font-family: var(--font-mono); letter-spacing: -0.02em; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--primary-tint-2); color: var(--secondary); }

/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ==========================================================================
   App Shell
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--med) var(--ease);
}

.app-shell.is-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }

.app-content {
  padding: 28px 32px 56px;
  max-width: 1440px;
  animation: pageFade .45s var(--ease);
}

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

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition: width var(--med) var(--ease);
  overflow: hidden;
}

.app-shell.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 22px;
  border-bottom: 1px solid var(--border-soft);
  min-height: var(--topbar-h);
}

.sidebar-brand__mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 700;
  flex: none;
  box-shadow: var(--shadow-primary);
}

.sidebar-brand__text { overflow: hidden; white-space: nowrap; }
.sidebar-brand__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1.2;
}
.sidebar-brand__sub { font-size: 11.5px; color: var(--text-muted); }

.app-shell.is-collapsed .sidebar-brand__text { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
}

.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  padding: 16px 12px 8px;
  white-space: nowrap;
}

.app-shell.is-collapsed .sidebar-section-label { text-align: center; padding: 16px 0 8px; }
.app-shell.is-collapsed .sidebar-section-label span { display: none; }

.nav-item { position: relative; margin-bottom: 4px; }

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.8px;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}

.nav-link-item i { font-size: 17px; width: 22px; flex: none; text-align: center; }

.nav-link-item:hover {
  background: var(--primary-tint);
  color: var(--secondary);
}

.nav-link-item.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.nav-link-item.active i { color: #fff; }

.app-shell.is-collapsed .nav-link-item span { display: none; }
.app-shell.is-collapsed .nav-link-item { justify-content: center; padding: 12px; }

/* Tooltip for collapsed sidebar */
.app-shell.is-collapsed .nav-item { position: relative; }
.app-shell.is-collapsed .nav-item::after {
  content: attr(data-title);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
  z-index: 40;
  box-shadow: var(--shadow-md);
}
.app-shell.is-collapsed .nav-item:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-soft);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--card-soft);
}

.app-shell.is-collapsed .sidebar-user__text { display: none; }
.app-shell.is-collapsed .sidebar-user { justify-content: center; }

.sidebar-collapse-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: absolute;
  top: 30px;
  right: -16px;
  z-index: 10;
  box-shadow: var(--shadow-sm);
  transition: transform var(--med) var(--ease), color var(--fast);
}
.sidebar-collapse-btn:hover { color: var(--primary); }
.app-shell.is-collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 1020;
  backdrop-filter: blur(2px);
}

/* ==========================================================================
   Topbar
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1010;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-left { display: flex; align-items: center; gap: 18px; min-width: 0; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex: none;
  transition: all var(--fast) var(--ease);
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary-tint-2); background: var(--primary-tint); transform: translateY(-1px); }

.breadcrumb-custom { display: flex; flex-direction: column; min-width: 0; }
.breadcrumb-custom .page-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.breadcrumb-custom .crumb-path { font-size: 12px; color: var(--text-faint); }

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

.notif-bell { position: relative; }
.notif-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--card);
}

.theme-toggle { position: relative; overflow: hidden; }

.profile-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: all var(--fast) var(--ease);
}
.profile-chip:hover { border-color: var(--primary-tint-2); background: var(--primary-tint); }
.profile-chip img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.profile-chip .p-name { font-size: 13px; font-weight: 600; line-height: 1.1; color: var(--text); }
.profile-chip .p-role { font-size: 11px; color: var(--text-muted); }

/* ==========================================================================
   Cards
   ========================================================================== */
.surface {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--med) var(--ease), transform var(--med) var(--ease), border-color var(--med);
}

.surface-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.surface-header h3 { font-size: 15.5px; font-weight: 600; }
.surface-body { padding: 22px; }

.stat-card {
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary-tint-2); }

.stat-card__icon {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 16px;
}
.stat-card__value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card__label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.stat-trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  margin-top: 12px;
}
.stat-trend.up { color: var(--success); background: var(--success-tint); }
.stat-trend.down { color: var(--danger); background: var(--danger-tint); }
.stat-trend.flat { color: var(--text-muted); background: var(--card-soft); }

.tone-primary { color: var(--primary); background: var(--primary-tint); }
.tone-success { color: var(--success); background: var(--success-tint); }
.tone-warning { color: var(--warning); background: var(--warning-tint); }
.tone-danger { color: var(--danger); background: var(--danger-tint); }
.tone-info { color: var(--info); background: var(--info-tint); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn { font-family: var(--font-body); font-weight: 600; font-size: 13.5px; border-radius: var(--radius-sm); padding: 10px 18px; transition: all var(--fast) var(--ease); border: 1px solid transparent; }
.btn:active { transform: scale(0.97); }

.btn-brand {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-brand:hover { color: #fff; filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 16px 28px -10px rgba(37,99,235,.55); }

.btn-outline-brand { background: var(--card); color: var(--primary); border-color: var(--border); }
.btn-outline-brand:hover { background: var(--primary-tint); color: var(--secondary); border-color: var(--primary-tint-2); }

.btn-soft-danger { background: var(--danger-tint); color: var(--danger); }
.btn-soft-danger:hover { background: var(--danger); color: #fff; }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--card-soft); color: var(--text); }

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

/* Quick action tiles */
.quick-action {
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--card);
  transition: all var(--med) var(--ease);
  height: 100%;
}
.quick-action:hover { border-color: transparent; background: linear-gradient(160deg, var(--primary), var(--secondary)); transform: translateY(-4px); box-shadow: var(--shadow-primary); }
.quick-action:hover .quick-action__icon { background: rgba(255,255,255,.18); color: #fff; }
.quick-action:hover .quick-action__title, .quick-action:hover .quick-action__desc { color: #fff; }
.quick-action:hover .quick-action__desc { color: rgba(255,255,255,.85); }
.quick-action__icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; background: var(--primary-tint); color: var(--primary); transition: all var(--med) var(--ease); }
.quick-action__title { font-weight: 600; font-size: 14px; color: var(--text); transition: color var(--med) var(--ease); }
.quick-action__desc { font-size: 12px; color: var(--text-muted); transition: color var(--med) var(--ease); }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  padding: 5px 11px 5px 8px;
  border-radius: 999px;
  line-height: 1.4;
}
.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status.st-hadir { color: var(--success); background: var(--success-tint); }
.badge-status.st-terlambat { color: var(--warning); background: var(--warning-tint); }
.badge-status.st-izin { color: var(--info); background: var(--info-tint); }
.badge-status.st-sakit { color: #C2610A; background: #FDF0DE; }
.badge-status.st-alpa { color: var(--danger); background: var(--danger-tint); }
.badge-status.st-aktif { color: var(--success); background: var(--success-tint); }
.badge-status.st-nonaktif { color: var(--text-muted); background: var(--card-soft); }

/* ==========================================================================
   Table
   ========================================================================== */
.table-premium-wrap { overflow-x: auto; }
.table-premium { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 760px; }
.table-premium thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.table-premium tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--text);
}
.table-premium tbody tr { transition: background var(--fast) var(--ease); }
.table-premium tbody tr:hover { background: var(--primary-tint); }
.table-premium tbody tr:last-child td { border-bottom: none; }

.avatar-sm { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; }
.avatar-name-row { display: flex; align-items: center; gap: 12px; }
.avatar-name-row .n-name { font-weight: 600; font-size: 13.5px; }
.avatar-name-row .n-sub { font-size: 11.5px; color: var(--text-muted); }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-label-premium { font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 6px; display: block; }
.form-control, .form-select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  transition: all var(--fast) var(--ease);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-tint);
  background: var(--card);
  color: var(--text);
}
.form-control::placeholder { color: var(--text-faint); }
.input-icon-group { position: relative; }
.input-icon-group i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 15px; }
.input-icon-group .form-control { padding-left: 40px; }
.input-icon-group .toggle-pass { position: absolute; right: 12px; left: auto; cursor: pointer; }

.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-content { border-radius: var(--radius-lg); border: none; background: var(--card); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border-soft); padding: 20px 24px; }
.modal-header .modal-title { font-family: var(--font-display); font-weight: 600; font-size: 16.5px; }
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--border-soft); padding: 16px 24px; }

/* ==========================================================================
   Toast (Bootstrap)
   ========================================================================== */
.toast { border-radius: var(--radius-sm); border: 1px solid var(--border-soft); box-shadow: var(--shadow-md); }

/* ==========================================================================
   Empty / Loading / Skeleton
   ========================================================================== */
.empty-state { text-align: center; padding: 56px 24px; }
.empty-state__icon {
  width: 76px; height: 76px; margin: 0 auto 18px;
  border-radius: 24px;
  background: var(--primary-tint);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
}
.empty-state h4 { font-size: 15.5px; margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); font-size: 13px; max-width: 320px; margin: 0 auto 18px; }

.skeleton {
  background: linear-gradient(90deg, var(--card-soft) 25%, var(--border-soft) 37%, var(--card-soft) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner-brand { width: 20px; height: 20px; border: 2.5px solid var(--primary-tint-2); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Pagination
   ========================================================================== */
.pagination-premium { display: flex; align-items: center; gap: 6px; }
.pagination-premium button {
  min-width: 34px; height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-size: 12.5px; font-weight: 600;
  transition: all var(--fast) var(--ease);
}
.pagination-premium button:hover { border-color: var(--primary-tint-2); color: var(--primary); }
.pagination-premium button.active { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; border-color: transparent; box-shadow: var(--shadow-primary); }
.pagination-premium button:disabled { opacity: .4; }

/* ==========================================================================
   Progress
   ========================================================================== */
.progress-premium { height: 8px; border-radius: 999px; background: var(--card-soft); overflow: hidden; }
.progress-premium > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--info)); }

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs-premium { display: inline-flex; padding: 4px; background: var(--card-soft); border-radius: 12px; gap: 4px; }
.tabs-premium button {
  border: none; background: transparent; color: var(--text-muted);
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 9px;
  transition: all var(--fast) var(--ease);
}
.tabs-premium button.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ==========================================================================
   Filter bar
   ========================================================================== */
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filter-field { min-width: 160px; flex: 1; }

/* ==========================================================================
   Misc utilities
   ========================================================================== */
.divider-soft { height: 1px; background: var(--border-soft); border: none; margin: 8px 0; }
.hover-lift { transition: transform var(--med) var(--ease), box-shadow var(--med) var(--ease); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--card-soft); color: var(--text-muted); }

.ring-chart-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.ring-chart-label { position: absolute; text-align: center; }
.ring-chart-label b { display: block; font-family: var(--font-display); font-size: 22px; }
.ring-chart-label small { font-size: 10.5px; color: var(--text-muted); }

.dropdown-menu { border-radius: var(--radius-md); border: 1px solid var(--border-soft); box-shadow: var(--shadow-lg); padding: 8px; background: var(--card); }
.dropdown-item { border-radius: 9px; padding: 9px 12px; font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 10px; }
.dropdown-item:hover { background: var(--primary-tint); color: var(--secondary); }
.dropdown-item i { font-size: 15px; width: 18px; }
