/* ============================================================
   Absensi NFC — Sistem papan absensi sekolah
   Palet institusional + status semantik. Tenang & jelas.
   ============================================================ */

:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --surface: #ffffff;
  --bg: #eef2f7;

  --brand: #1d4ed8;
  --brand-dark: #1e3a8a;
  --brand-soft: #dbe4fb;

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fdeecd;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .08);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--brand); }

.hidden { display: none !important; }

/* ---------------- Tombol ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  background: #fff;
  color: var(--ink);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 1px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--ink); }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------------- Form ---------------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink); margin-bottom: 6px;
}
input, select {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  padding: 4px 9px; border-radius: 999px;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: #eef2f7; color: var(--muted); }

/* ============================================================
   HALAMAN ABSENSI (index.html)
   ============================================================ */
.scan-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -10%, #e8eefb 0%, rgba(238,242,247,0) 60%),
    var(--bg);
}

.scan-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 20px; max-width: 640px; width: 100%; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.clock { text-align: right; }
.clock-time { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 12px; color: var(--muted); }

.scan-main {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 20px 28px;
}

.scan-card {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 30px 26px 26px;
  text-align: center;
}

.scan-eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--brand);
}
.scan-title { font-size: 24px; font-weight: 800; margin: 6px 0 22px; letter-spacing: -.02em; }

/* Cakram status — elemen tanda tangan halaman */
.disc {
  --disc: var(--brand);
  width: 168px; height: 168px; margin: 4px auto 20px;
  border-radius: 50%;
  display: grid; place-items: center;
  position: relative;
  background: #f6f8fc;
  border: 2px solid var(--line);
  transition: background .25s, border-color .25s;
}
.disc::before {
  content: ""; position: absolute; inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--disc);
  opacity: 0;
}
.disc.waiting { --disc: var(--brand); background: #eef3fe; border-color: var(--brand-soft); }
.disc.waiting::before { animation: ping 1.8s cubic-bezier(0,0,.2,1) infinite; }
.disc.busy { --disc: var(--brand); background: #eef3fe; border-color: var(--brand-soft); }
.disc.ok { --disc: var(--ok); background: var(--ok-soft); border-color: #bbf7d0; }
.disc.warn { --disc: var(--warn); background: var(--warn-soft); border-color: #fde3b3; }
.disc.err { --disc: var(--danger); background: var(--danger-soft); border-color: #fecaca; }

.disc-icon { width: 66px; height: 66px; color: var(--disc); }
.disc.busy .disc-icon { animation: spin 1s linear infinite; }

@keyframes ping {
  0% { transform: scale(1); opacity: .6; }
  80%,100% { transform: scale(1.18); opacity: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-text { font-size: 17px; font-weight: 700; min-height: 24px; }
.status-hint { font-size: 13.5px; color: var(--muted); margin-top: 6px; min-height: 20px; }

/* Panel hasil siswa */
.result {
  margin-top: 18px; padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #f8fafc;
  text-align: left;
}
.result-name { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.result-meta { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.result-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line-strong);
}
.result-time { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }

.scan-action { margin-top: 22px; }
.scan-foot {
  text-align: center; padding: 14px; font-size: 12px; color: var(--muted);
}
.test-panel {
  margin-top: 18px; padding: 14px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius); background: #fffdf5; text-align: left;
}
.test-panel h4 { margin: 0 0 8px; font-size: 13px; color: var(--warn); }
.test-row { display: flex; gap: 8px; }
.test-row input { flex: 1; }

/* ============================================================
   PANEL ADMIN (admin.html)
   ============================================================ */

/* --- Login --- */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 400px at 50% -10%, #e8eefb 0%, rgba(238,242,247,0) 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 28px 26px;
}
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-card h1 { font-size: 20px; text-align: center; margin: 8px 0 2px; }
.login-card p.sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.form-error {
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px;
  font-weight: 600; margin-bottom: 14px;
}

/* --- Shell --- */
.admin-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }

.sidebar {
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100dvh;
}
.sidebar .brand { padding: 6px 8px 16px; border-bottom: 1px solid var(--line); }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: var(--muted);
  text-decoration: none; transition: background .12s, color .12s;
}
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav a:hover { background: #f1f5f9; color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; }
.sidebar-user { font-size: 13px; color: var(--muted); padding: 0 8px 10px; }
.sidebar-user b { color: var(--ink); display: block; font-size: 14px; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.main { padding: 26px 28px 44px; max-width: 1100px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* --- Kartu statistik --- */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px;
}
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 30px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-accent { height: 3px; width: 34px; border-radius: 3px; margin-top: 10px; background: var(--brand); }
.stat.ok .stat-accent { background: var(--ok); }
.stat.warn .stat-accent { background: var(--warn); }

/* --- Panel & toolbar --- */
.panel {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.panel-head h3 { margin: 0; font-size: 15px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 130px; }

/* --- Tabel --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td {
  padding: 11px 14px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.data th {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: #f8fafc; font-weight: 700;
}
table.data tbody tr:hover, table.data tr:hover td { background: #fbfcfe; }
table.data td.actions { text-align: right; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.uid-chip {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  background: #f1f5f9; padding: 3px 7px; border-radius: 6px; color: var(--ink);
}

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 18px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.pagination .info { font-size: 13px; color: var(--muted); }
.pagination .pager { display: flex; gap: 8px; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: grid; place-items: center; padding: 20px; z-index: 60;
}
.modal {
  width: 100%; max-width: 460px; background: #fff;
  border-radius: 16px; box-shadow: 0 20px 60px rgba(15,23,42,.3); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line); background: #f8fafc;
}
.modal .form-error { margin-bottom: 16px; }

/* --- Registrasi NFC --- */
.reg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.reg-uid {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 20px; font-weight: 700; text-align: center;
  padding: 18px; border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: #f8fafc; margin: 6px 0 16px; color: var(--ink); word-break: break-all;
}
.reg-uid.empty-uid { color: var(--muted); font-weight: 500; font-size: 14px; }

/* --- Toast --- */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(15,23,42,.35);
  max-width: 340px; animation: toastin .2s ease;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- Responsif ---------------- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .reg-grid { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; width: 256px; height: 100dvh;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 10px 40px rgba(15,23,42,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; }
  .sidebar-scrim {
    position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 40;
  }
  .main { padding: 18px 16px 40px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 24px; }
  .scan-card { padding: 24px 18px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
