/* =============================================================================
   Absensi Sekolah — professional UI theme
   Flat, calm, no gradients / neon. Slate + steel-blue palette.
   ============================================================================= */

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2b4c7e;
  --primary-d: #213c64;
  --primary-soft: #eaf0f8;
  --sidebar: #1b2638;
  --sidebar-hover: #27344a;
  --sidebar-text: #c3ccda;
  --success: #15803d;
  --success-soft: #e7f3ec;
  --danger: #b91c1c;
  --danger-soft: #fbeaea;
  --warning: #b45309;
  --warning-soft: #fbf1e3;
  --info: #0369a1;
  --info-soft: #e6f1f8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .10);
  --sidebar-w: 256px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--text); font-weight: 700; line-height: 1.25; }

.ico { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info)    !important; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.mt-0{margin-top:0}.mt-1{margin-top:.5rem}.mt-2{margin-top:1rem}.mt-3{margin-top:1.5rem}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:.5rem}.mb-2{margin-bottom:1rem}
.w-100{width:100%}

/* ---------------- App shell ---------------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 50;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px; border-bottom: 1px solid rgba(255,255,255,.07);
  color: #fff; font-weight: 700; font-size: 16px;
}
.sidebar-brand .logo {
  width: 38px; height: 38px; border-radius: 9px; background: #fff;
  display: flex; align-items: center; justify-content: center; flex: none; overflow: hidden;
}
.sidebar-brand .logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand small { display:block; font-weight:400; font-size:11px; color:#8a97ab; }

.sidebar-role {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: #7c8aa0; padding: 16px 22px 8px;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0 12px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 14px; margin: 2px 0; border-radius: 9px;
  color: var(--sidebar-text); font-size: 14.5px; font-weight: 500;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a.danger:hover { background: var(--danger); }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 26px; display: flex; align-items: center; gap: 14px;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .spacer { flex: 1; }
.topbar .user-chip { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:14px; }
.topbar .user-chip .av { width:34px;height:34px;border-radius:50%;background:var(--primary-soft);color:var(--primary);
  display:flex;align-items:center;justify-content:center;font-weight:700; overflow:hidden; }
.topbar .user-chip .av img{width:100%;height:100%;object-fit:cover}
.menu-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: 4px; }

.content { padding: 26px; max-width: 1240px; width: 100%; }

/* ---------------- Cards ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.card-head { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 16px; margin: 0; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
}
.stat .ic { width: 48px; height: 48px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex: none; }
.stat .ic .ico { width: 24px; height: 24px; }
.stat .ic.blue { background: var(--primary-soft); color: var(--primary); }
.stat .ic.green { background: var(--success-soft); color: var(--success); }
.stat .ic.amber { background: var(--warning-soft); color: var(--warning); }
.stat .ic.red { background: var(--danger-soft); color: var(--danger); }
.stat .num { font-size: 26px; font-weight: 700; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--text);
  transition: background .15s, border-color .15s, opacity .15s; text-decoration: none; line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #126b34; color:#fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9e1818; color:#fff; }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; }
.btn-block { display: flex; width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 6px; }

/* ---------------- Forms ---------------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43,76,126,.12); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex:none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 26px; transition: .2s; cursor: pointer; }
.switch .slider:before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: var(--shadow); }
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.toggle-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .ti { width: 42px; height: 42px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display:flex;align-items:center;justify-content:center;flex:none; }
.toggle-row .meta { flex: 1; } .toggle-row .meta b { display:block; } .toggle-row .meta small { color: var(--muted); }

/* ---------------- Tables ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.table th { text-align: left; padding: 12px 14px; color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tbody tr:hover { background: var(--surface-2); }
table.table tbody tr:last-child td { border-bottom: none; }
.cell-name b { display: block; }
.cell-name small { color: var(--muted); }

/* avatar */
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--primary-soft); color: var(--primary); display:flex;align-items:center;justify-content:center;font-weight:700; overflow:hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------- Badges & pills ---------------- */
.badge { display: inline-flex; align-items:center; gap:5px; padding: 4px 11px; border-radius: 30px; font-size: 12.5px; font-weight: 600; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.info    { background: var(--info-soft);    color: var(--info); }
.badge.muted   { background: var(--surface-2);    color: var(--muted); border:1px solid var(--border); }

/* ---------------- Alerts ---------------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #bfe0cb; }
.alert-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: #f0c4c4; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #ecd5b0; }
.alert-info    { background: var(--info-soft);    color: var(--info);    border-color: #bcdcef; }

/* ---------------- Auth pages ---------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 410px; }
.auth-logo { width: 72px; height: 72px; border-radius: 16px; background: var(--surface); border:1px solid var(--border); margin: 0 auto 16px; display:flex;align-items:center;justify-content:center; overflow:hidden; box-shadow: var(--shadow); }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.auth-tabs { display: flex; background: var(--surface-2); border:1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 20px; }
.auth-tabs a { flex: 1; text-align: center; padding: 9px; border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.auth-tabs a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.auth-tabs a:hover { text-decoration: none; }

/* ---------------- Misc ---------------- */
.page-actions { display:flex; align-items:center; gap:10px; margin-bottom: 18px; flex-wrap: wrap; }
.page-actions .spacer { flex:1; }
.empty { text-align:center; color: var(--muted); padding: 30px 16px; }
.divider { height:1px; background: var(--border); margin: 18px 0; border:none; }
.clock { font-size: 38px; font-weight: 700; letter-spacing: .02em; }
.scan-stage { background:#0b1220; border-radius: var(--radius); overflow:hidden; }
#reader { width: 100%; }
video { border-radius: var(--radius); }

/* ---------------- Toasts & modal ---------------- */
.toast-host { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--muted); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 13px 18px; font-size: 14px; max-width: 340px; opacity: 0; transform: translateX(20px);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--success); }
.toast-error, .toast-danger { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--primary); }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 9998; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 24px; max-width: 420px; width: 100%; }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 20px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------- Fingerprint (WebAuthn) ---------------- */
.fp-or { display:flex; align-items:center; gap:12px; margin:16px 0; color: var(--muted); font-size:13px; }
.fp-or::before, .fp-or::after { content:""; flex:1; height:1px; background: var(--border); }
.cred-list { list-style:none; margin:0 0 6px; padding:0; }
.cred-row { display:flex; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--border); }
.cred-row:last-child { border-bottom:none; }
.cred-row .ti { width:38px; height:38px; border-radius:10px; background: var(--primary-soft); color: var(--primary); display:flex; align-items:center; justify-content:center; flex:none; }
.cred-row .meta { flex:1; } .cred-row .meta b { display:block; } .cred-row .meta small { color: var(--muted); }

/* ---------------- Responsive ---------------- */
@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 18px; }
  .sidebar-backdrop { display:none; position:fixed; inset:0; background:rgba(15,23,42,.45); z-index:40; }
  .sidebar-backdrop.show { display:block; }
}
