/* ==========================================================================
   Absensi Proyek — design system bersama (halaman absen + admin)
   Urutan keputusan: keterbacaan dulu, informasi kedua, dekorasi terakhir.
   Motif identitas: "shift track" (titik — garis — titik) = masuk → durasi → pulang.
   ========================================================================== */

:root {
  /* --- Warna UI: netral + 1 primer + 3 status. Tidak ada warna lain. --- */
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef1f7;
  --line: #e2e7f0;
  --line-strong: #c9d1e0;
  --text: #111a2e;
  --text-2: #48546b;
  --text-3: #6b7689;

  --primary: #1a3f8f;
  --primary-hover: #15316f;
  --primary-active: #102554;
  --primary-soft: #eaf0fc;
  --primary-soft-2: #d8e2f7;
  --primary-ink: #12306e;

  --ok: #15774a;
  --ok-soft: #e4f4eb;
  --ok-ink: #0e5a37;

  --warn: #ad6400;
  --warn-soft: #fdf0d8;
  --warn-ink: #7a4700;

  --bad: #b42318;
  --bad-soft: #fdeceb;
  --bad-ink: #8a1a12;

  /* --- Warna ilustrasi: acuan untuk /illus.svg. Nilainya ditulis ulang sebagai heks
         di file itu, karena atribut fill/stroke pada SVG tidak bisa membaca var(). --- */
  --il-ink: #12306e;
  --il-deep: #1a3f8f;
  --il-mid: #6f8ecb;
  --il-soft: #d8e2f7;
  --il-pale: #eef3fc;
  --il-skin: #f3c99a;
  --il-hi: #f5b544;
  --il-ok: #35a06a;

  /* --- Bentuk & bayangan (bayangan bernuansa navy, bukan abu-abu) --- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(17, 26, 46, .06), 0 1px 1px rgba(17, 26, 46, .04);
  --sh-2: 0 2px 4px -1px rgba(17, 26, 46, .06), 0 8px 20px -6px rgba(17, 26, 46, .10);
  --sh-3: 0 4px 10px -4px rgba(17, 26, 46, .10), 0 18px 40px -12px rgba(17, 26, 46, .20);
  --shadow-pop: var(--sh-3);
  --ring: 0 0 0 3px rgba(26, 63, 143, .26);

  /* --- Ukuran kontrol --- */
  --h: 40px;
  --h-lg: 52px;

  /* --- Gerak: satu set durasi & easing untuk seluruh aplikasi --- */
  --dur-1: 120ms;   /* hover, tekan */
  --dur-2: 180ms;   /* badge, toast, pertukaran kecil */
  --dur-3: 260ms;   /* modal, drawer, masuknya konten */
  --dur-4: 420ms;   /* momen sukses */
  --ease: cubic-bezier(.3, .8, .4, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* --- Tipografi --- */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* Ikon (sprite: /icons.svg) */
.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 22px; height: 22px; }

/* Ilustrasi (sprite: /illus.svg). Warna mengikuti variabel --il-* di atas. */
.illus { display: block; width: 168px; height: 126px; flex: none; }
.illus.sm { width: 112px; height: 84px; }
.illus.lg { width: 220px; height: 165px; }

/* Skala tipografi */
.t-display { font-family: var(--font-display); font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -.02em; }
.t-page { font-family: var(--font-display); font-size: 20px; line-height: 28px; font-weight: 700; letter-spacing: -.015em; }
.t-section { font-family: var(--font-display); font-size: 15px; line-height: 22px; font-weight: 700; letter-spacing: -.005em; }
.t-body { font-size: 14px; }
.t-cap { font-size: 12px; line-height: 16px; }
.t-muted { color: var(--text-3); }

/* ---------- Tombol ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: var(--text);
  font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(.985); }
.btn:disabled, .btn[aria-busy="true"] { cursor: not-allowed; opacity: .5; }
.btn[aria-busy="true"] { cursor: progress; opacity: 1; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--sh-2); }
.btn-primary:active:not(:disabled) { background: var(--primary-active); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #a9b5c9; }
.btn-ghost { color: var(--primary); padding: 0 10px; }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { background: var(--surface); border-color: #e6b8b3; color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); }
.btn-danger-solid { background: var(--bad); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: #96190f; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { height: var(--h-lg); font-size: 16px; border-radius: 12px; padding: 0 20px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* Memuat: spinner menggantikan ikon di tempat yang sama, jadi lebar tombol tidak berubah. */
.btn[aria-busy="true"] > .ic { display: none; }
.btn[aria-busy="true"]::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn-lg[aria-busy="true"]::before { width: 20px; height: 20px; }
/* Selesai: centang singkat menggantikan spinner tanpa menggeser label. */
.btn[data-state="done"] > .ic { display: none; }
.btn[data-state="done"]::before {
  content: ""; width: 18px; height: 18px; flex: none;
  background: currentColor; -webkit-mask: var(--mask-check) center / contain no-repeat; mask: var(--mask-check) center / contain no-repeat;
  animation: pop .26s var(--ease-out);
}
:root { --mask-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }

.link {
  border: 0; background: none; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1.5px;
}
.link:hover { color: var(--primary-hover); }

/* ---------- Input ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, .select {
  width: 100%; height: var(--h); padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  appearance: none; -webkit-appearance: none;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
.input::placeholder { color: #8b95a7; }
.input:hover, .select:hover { border-color: #a9b5c9; }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.select {
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2348546b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input.lg, .select.lg { height: var(--h-lg); font-size: 16px; border-radius: 12px; }
.field.invalid .input, .field.invalid .select { border-color: var(--bad); }
.field.invalid .input:focus, .field.invalid .select:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .22); }
.field-error { display: none; color: var(--bad-ink); font-size: 13px; font-weight: 500; }
.field.invalid .field-error { display: block; animation: shake .3s var(--ease); }
.help { font-size: 12px; color: var(--text-3); line-height: 17px; }
.input-affix { position: relative; }
.input-affix > .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-affix > .input { padding-left: 38px; }
.input-affix > .pre { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; pointer-events: none; }
.input-affix > .input.has-pre { padding-left: 38px; }

/* ---------- Badge status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
  transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; flex: none;
}
.badge.ok { background: var(--ok-soft); color: var(--ok-ink); }
.badge.info { background: var(--primary-soft); color: var(--primary-ink); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.bad { background: var(--bad-soft); color: var(--bad-ink); }
.badge.plain::before { display: none; }
/* Denyut hanya untuk keadaan yang benar-benar sedang berjalan (kamera aktif, sesi belum ditutup). */
.badge.live::before { animation: beat 2.4s var(--ease) infinite; }

/* ---------- Shift track: motif identitas (masuk → durasi → pulang) ---------- */
.track { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.track .node {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--ok); color: #fff; box-shadow: 0 0 0 4px var(--ok-soft);
  transition: background-color var(--dur-3) var(--ease), box-shadow var(--dur-3) var(--ease);
}
.track .node .ic { width: 14px; height: 14px; stroke-width: 2.6; }
.track .node.wait {
  background: var(--surface); color: transparent; border: 2px dashed var(--line-strong); box-shadow: none;
}
.track .node.now { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.track .node.now::after {
  content: ""; position: absolute; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--primary); animation: ripple 2.2s var(--ease-out) infinite;
}
.track .node.now { position: relative; }
.track .node.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.track .rail { height: 3px; border-radius: 2px; background: var(--line); position: relative; overflow: hidden; }
.track .rail i {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 2px; background: var(--ok);
  transition: width var(--dur-4) var(--ease-out);
}
.track .rail.run i { background: var(--primary); }
.track .rail.dash { background: repeating-linear-gradient(90deg, var(--line-strong) 0 5px, transparent 5px 10px); height: 2px; }

/* ---------- Toast ---------- */
.toasts {
  position: fixed; z-index: 100; top: calc(12px + env(safe-area-inset-top, 0px)); right: 16px;
  display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 12px 12px 14px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-left: 4px solid var(--text-3); border-radius: var(--r-md);
  box-shadow: var(--sh-3); font-size: 14px; line-height: 20px;
  animation: toast-in var(--dur-3) var(--ease-out);
}
.toast .ic { margin-top: 1px; }
.toast .msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .x { border: 0; background: none; padding: 2px; margin: -2px -2px 0 0; color: var(--text-3); cursor: pointer; border-radius: 4px; }
.toast .x:hover { color: var(--text); background: var(--surface-2); }
.toast.success { border-left-color: var(--ok); } .toast.success > .ic:first-child { color: var(--ok); }
.toast.error { border-left-color: var(--bad); } .toast.error > .ic:first-child { color: var(--bad); }
.toast.warning { border-left-color: var(--warn); } .toast.warning > .ic:first-child { color: var(--warn); }
.toast.info { border-left-color: var(--primary); } .toast.info > .ic:first-child { color: var(--primary); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
@media (max-width: 600px) { .toasts { right: 12px; left: 12px; width: auto; } }

/* ---------- Skeleton ---------- */
.skel {
  display: block; border-radius: var(--r-xs); min-height: 12px;
  background: linear-gradient(90deg, #e8ecf3 25%, #f4f6fa 37%, #e8ecf3 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
.skel.circle { border-radius: 50%; }

/* ---------- Dialog & modal ---------- */
dialog {
  border: 0; padding: 0; color: var(--text); background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); max-width: calc(100vw - 24px);
}
dialog::backdrop { background: rgba(10, 17, 34, .46); animation: fade-in var(--dur-3) var(--ease); }
dialog[open] { animation: modal-in var(--dur-3) var(--ease-out); }
dialog.closing { animation: modal-out var(--dur-2) var(--ease) forwards; }
dialog.closing::backdrop { animation: fade-out var(--dur-2) var(--ease) forwards; }
.dlg { width: 440px; max-width: 100%; }
.dlg-head { padding: 20px 20px 0; }
.dlg-body { padding: 16px 20px; display: grid; gap: 14px; }
.dlg-foot { padding: 12px 20px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.dlg-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error {
  display: none; padding: 10px 12px; border-radius: var(--r-md); background: var(--bad-soft); color: var(--bad-ink);
  font-weight: 500; font-size: 13px;
}
.form-error.show { display: block; animation: shake .3s var(--ease); }

/* ---------- Keadaan kosong / gagal (selalu punya ilustrasi + jalan keluar) ---------- */
.empty { padding: 44px 20px; text-align: center; display: grid; justify-items: center; gap: 4px; }
.empty .illus { margin-bottom: 10px; }
.empty b { font-family: var(--font-display); font-size: 16px; letter-spacing: -.01em; }
.empty p { color: var(--text-2); max-width: 380px; line-height: 20px; }
.empty .acts { margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.empty.compact { padding: 26px 16px; }

/* ---------- Masuknya konten: satu urutan, cepat, sekali jalan ---------- */
[data-rv] { opacity: 0; transform: translateY(8px); }
[data-rv].rv-on { opacity: 1; transform: none; transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes beat { 0%, 62%, 100% { opacity: .9; transform: scale(1); } 76% { opacity: .5; transform: scale(.8); } }
@keyframes ripple { 0% { opacity: .5; transform: scale(1); } 100% { opacity: 0; transform: scale(1.9); } }
@keyframes shake { 25% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 75% { transform: translateX(-2px); } }

/* ---------- Hormati prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .skel { animation: none; }
  [data-rv] { opacity: 1; transform: none; }
}
