/* Absensi Wajah – Tugas 6 (Hadi Sanjaya, 09011282328112)
   Standar UI: Inter, ikon garis SVG, radius 4–8 px, tanpa emoji. Kamera gelap, lembar (sheet) terang.
   Tata letak: kamera layar penuh, dock mode gaya iOS di bawah, bubble status di atas dock. */

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("vendor/fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("vendor/fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("vendor/fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("vendor/fonts/inter-latin-700-normal.woff2") format("woff2"); }

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-sm: 4px; --r: 6px; --r-lg: 8px;
  --primary: #2563eb; --primary-weak: #dbeafe;
  --hadir: #16a34a; --sudah: #2563eb; --menunggu: #d97706; --asing: #dc2626; --kecil: #ca8a04;
  --dalam: #16a34a; --luar: #dc2626; --tidak-ada: #94a3b8;
  --cam-bg: #0b1220; --cam-ink: #f8fafc; --cam-muted: #94a3b8; --cam-line: rgba(255,255,255,.14);
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --line-2: #cbd5e1; --surface: #ffffff; --surface-2: #f8fafc;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--cam-bg); color: var(--cam-ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; display: inline-block; }
.muted { color: var(--cam-muted); }
.light .muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 12px; margin-top: 8px; }

/* ---------- Tata letak utama: kamera layar penuh di semua orientasi ---------- */
.app { height: 100dvh; }
.cam { position: relative; height: 100%; overflow: hidden; background: radial-gradient(ellipse at 50% 40%, #1e293b 0%, #0b1220 75%); }
.cam video, .cam .still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam video.mirror { transform: scaleX(-1); }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-lg); color: var(--cam-ink); }
.iconbtn.plain { background: transparent; color: var(--ink); }

/* ---------- Bagian bawah: bubble, kartu, kontrol, dock ---------- */
.bottom { position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 0 16px calc(var(--safe-b) + 18px); pointer-events: none; }
.bottom > * { pointer-events: auto; }

/* Kaca buram yang sama untuk dock, tombol bulat, dan shutter */
.dock, .roundbtn, .shutter { background: rgba(30,41,59,.42); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%); box-shadow: 0 10px 30px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.12); }

/* Dock: pil melengkung penuh yang membungkus isinya */
.dock { display: flex; gap: 4px; padding: 5px; border-radius: 999px; }
.dock button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 88px; height: 54px; padding: 0 16px; border-radius: 999px; color: rgba(248,250,252,.72); font-size: 11px; font-weight: 500; transition: background .2s, color .2s, transform .15s; }
.dock button .ic { width: 21px; height: 21px; }
.dock button:active { transform: scale(.94); }
.dock button.on { background: rgba(255,255,255,.95); color: var(--ink); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.18); }

/* Baris kontrol: pengaturan (kiri) · shutter · balik kamera (kanan) */
.controls { display: flex; align-items: center; gap: 32px; }
.roundbtn { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: var(--cam-ink); transition: transform .15s; }
.roundbtn .ic { width: 22px; height: 22px; }
.roundbtn:active { transform: scale(.9); }

.shutter { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.shutter i { width: 56px; height: 56px; border-radius: 50%; background: #fff; display: block; transition: all .18s; }
.shutter:active i { transform: scale(.9); }
.shutter.rec i { width: 26px; height: 26px; border-radius: var(--r); background: var(--asing); }
.shutter.live i { background: var(--asing); }
.shutter:disabled { opacity: .35; }

/* Bubble status scan: pil kaca dengan cincin progres */
.bubble { display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 18px 0 8px; border-radius: 23px; background: rgba(255,255,255,.94); color: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,.28); font-size: 14px; font-weight: 600; white-space: nowrap; animation: pop .22s ease-out; }
.bubble .ring { width: 30px; height: 30px; flex: none; display: flex; align-items: center; justify-content: center; position: relative; color: var(--primary); }
.bubble .ring > .ic { display: block; }
.bubble .ring svg:not(.ic) { position: absolute; inset: 0; width: 30px; height: 30px; transform: rotate(-90deg); }
.bubble .ring .ic { width: 15px; height: 15px; }
.bubble .ring .bg { stroke: #e2e8f0; }
.bubble .ring .fg { stroke: currentColor; transition: stroke-dashoffset .12s linear; }
.bubble .pct { font-variant-numeric: tabular-nums; color: var(--primary); }
.bubble.ok .ring, .bubble.ok .pct { color: var(--hadir); }
.bubble.warn .ring { color: var(--menunggu); }

/* Kartu hasil scan / error */
.scan-card { width: min(440px, 100%); background: rgba(255,255,255,.97); color: var(--ink); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.28); animation: pop .22s ease-out; }
.scan-card .msg { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.scan-card .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.result { display: flex; gap: 12px; align-items: center; }
.result .avatar { width: 48px; height: 48px; font-size: 14px; }
.result b { display: block; font-size: 16px; }
.result .meta { font-size: 12.5px; color: var(--muted); }
.result .meta .ic { width: 14px; height: 14px; vertical-align: -2px; }
.result .st { font-weight: 600; }
.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.okmark { position: absolute; z-index: 4; left: 50%; top: 42%; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%; display: grid; place-items: center; color: #fff; box-shadow: 0 0 0 10px rgba(255,255,255,.12); animation: pop .25s ease-out; }
.okmark .ic { width: 40px; height: 40px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.toasts { position: absolute; z-index: 7; top: calc(var(--safe-t) + 16px); left: 12px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; max-width: 420px; padding: 9px 12px; border-radius: var(--r); background: var(--hadir); color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,.25); animation: pop .2s ease-out; }
.toast.err { background: var(--asing); }
.toast.info { background: #1e293b; }

/* ---------- Komponen umum (lembar terang) ---------- */
.light { color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: var(--r); background: var(--primary); color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn.sec { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
.btn.block { display: flex; width: 100%; }
.avatar { width: 34px; height: 34px; border-radius: var(--r); background: #cbd5e1; color: #475569; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-sm); font-size: 11.5px; font-weight: 600; color: #fff; white-space: nowrap; }
.list { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .tx small { color: var(--muted); font-size: 11.5px; }

.screen { position: fixed; inset: 0; z-index: 30; background: var(--surface); overflow: auto; }
.izin { min-height: 100%; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; padding: calc(var(--safe-t) + 48px) 24px calc(var(--safe-b) + 24px); }
.izin h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.logo { width: 52px; height: 52px; border-radius: var(--r-lg); background: var(--primary); color: #fff; display: grid; place-items: center; margin-bottom: 16px; }
.logo .ic { width: 28px; height: 28px; }
.perms { display: flex; flex-direction: column; gap: 10px; }
.perm { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-lg); }
.perm .ico { width: 38px; height: 38px; border-radius: var(--r); background: var(--primary-weak); color: var(--primary); display: grid; place-items: center; flex: none; }
.perm b { display: block; }
.perm p { font-size: 12.5px; color: var(--muted); }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(2,6,23,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 16px 18px calc(var(--safe-b) + 18px); display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font-size: 18px; font-weight: 700; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; }
.form { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.field span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.field input, .field select { width: 100%; height: 42px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--ink); }
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.test { font-size: 13px; font-weight: 600; min-height: 18px; }
.test.ok { color: var(--hadir); } .test.err { color: var(--asing); }
.loc { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--r); font-size: 13px; font-weight: 600; border: 1px solid currentColor; }
.loc:empty { display: none; }

/* HP lanskap pendek: dock dan bubble lebih ringkas */
@media (orientation: landscape) and (max-height: 599px) {
  .dock button { min-width: 78px; height: 46px; font-size: 10.5px; }
  .dock button .ic { width: 19px; height: 19px; }
  .bottom { gap: 8px; padding-bottom: calc(var(--safe-b) + 10px); }
  .shutter { width: 64px; height: 64px; }
  .shutter i { width: 48px; height: 48px; }
  .roundbtn { width: 44px; height: 44px; }
}

/* HP potret sempit (±360 px) */
@media (max-width: 480px) {
  .dock button { min-width: 80px; padding: 0 12px; }
  .controls { gap: 26px; }
}

/* Rekam wajah (pendaftaran template) di lembar Pengaturan */
.rekam { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.rekam-judul { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.rekam-judul .ic { color: var(--primary); }
.rekam .small { margin-top: 0; }
.row-rekam { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.row-rekam select { width: 100%; height: 42px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--ink); }
.bubble.rekam-bubble .ring, .bubble.rekam-bubble .pct { color: var(--primary); }


/* Lembar "Siapa Anda?" (pengguna baru) */
.pilih-box { max-height: 92dvh; }
.cari { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r); color: var(--muted); }
.cari input { flex: 1; border: 0; outline: 0; height: 100%; background: transparent; color: var(--ink); font-size: 15px; }
.pilih-list { overflow: auto; max-height: 52dvh; }
.pilih-list .item { cursor: pointer; }
.pilih-list .item:active { background: var(--surface-2); }
.badge.abu { background: #94a3b8; }
.scan-card .aksi { margin-top: 10px; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13px; }
