/* ============================================================================
 * DRW Scan — style.css
 * Tema gelap, mobile-first. Panggung kamera penuh + panel hasil di bawah.
 * ========================================================================== */

:root {
  --bg:        #0b1220;
  --panel:     #111a2e;
  --panel-2:   #16223c;
  --line:      #243049;
  --text:      #e8eef9;
  --muted:     #8aa0c2;
  --primary:   #2f7cf6;
  --primary-d: #1f63d6;
  --ok:        #22c55e;
  --new:       #facc15;
  --danger:    #ef4444;
  --radius:    16px;
  --safe-t:    env(safe-area-inset-top, 0px);
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}

#app {
  display: flex; flex-direction: column;
  height: 100dvh; max-width: 560px; margin: 0 auto;
  background: var(--bg);
}

/* ---------------------------- PANGGUNG KAMERA --------------------------- */
.stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  background: #000; overflow: hidden;
}
#video, .overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
#video { object-fit: cover; }
/* overlay memakai object-fit sama dgn video agar koordinat kotak sejajar */
.overlay { object-fit: cover; pointer-events: none; }

/* Bingkai pemindai */
.reticle {
  position: absolute; left: 50%; top: 46%;
  width: min(72vw, 320px); aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.reticle.wide { aspect-ratio: 4 / 3; width: min(82vw, 380px); }
.corner {
  position: absolute; width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 4px;
}
.corner.tl { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.corner.tr { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.corner.bl { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.corner.br { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.laser {
  position: absolute; left: 6%; right: 6%; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  box-shadow: 0 0 12px 2px rgba(47,124,246,.7);
  opacity: 0; border-radius: 2px;
}
.scanning .laser { animation: sweep 2.1s ease-in-out infinite; }
@keyframes sweep {
  0%   { top: 4%;  opacity: .2; }
  50%  { top: 94%; opacity: 1; }
  100% { top: 4%;  opacity: .2; }
}

/* Status kecil — overlay tengah-atas (indikator scan + engine) */
.statusbar {
  position: absolute; top: calc(8px + var(--safe-t)); left: 50%;
  transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(0,0,0,.42); border: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(6px);
}
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 0 rgba(34,197,94,.5);
}
.dot.live { background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70%  { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.engine { font-size: 10px; font-weight: 700; letter-spacing: .3px; color: var(--muted); }
.engine:empty { display: none; }

/* Rail kontrol kamera — overlay tepi kanan (di bawah profile chip) */
.rail {
  position: absolute; right: 10px; top: calc(56px + var(--safe-t));
  display: flex; flex-direction: column; gap: 8px; z-index: 7;
}
.icon-btn {
  width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px; background: rgba(0,0,0,.46); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(6px); transition: transform .08s, background .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.on { background: var(--primary); border-color: var(--primary); }
.icon-btn.danger { background: rgba(239,68,68,.5); border-color: rgba(239,68,68,.6); }

/* Penghitung live (mode multi) */
.live-count {
  position: absolute; top: calc(56px + var(--safe-t)); left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 6px;
  background: rgba(0,0,0,.5); padding: 6px 14px; border-radius: 999px;
  z-index: 5; backdrop-filter: blur(4px);
}
.live-count .num { font-size: 20px; font-weight: 800; color: var(--new); }
.live-count .lbl { font-size: 12px; color: var(--muted); }

/* Gerbang "aktifkan kamera" / pesan error */
.gate {
  position: absolute; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 80% at 50% 30%, #16223c, #0b1220);
}
.gate[hidden] { display: none; }
.gate-card { text-align: center; max-width: 340px; }
.gate-ico { color: var(--primary); }
.gate-title { margin: 10px 0 4px; font-size: 26px; }
.gate-sub { margin: 0 0 22px; color: var(--muted); line-height: 1.5; font-size: 14px; }

/* --------------------- DOK KONTROL BAWAH (overlay kamera) -------------- */
.dock {
  position: absolute; left: 0; right: 0; bottom: calc(12px + var(--safe-b));
  z-index: 6; display: flex; flex-direction: column; gap: 10px;
  padding: 0 14px; pointer-events: none;   /* area kosong tembus ke kamera */
}
.dock > * { pointer-events: auto; }

.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: rgba(8,14,28,.6); border: 1px solid rgba(255,255,255,.12);
  padding: 5px; border-radius: 14px; backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.seg-btn {
  border: 0; background: transparent; color: var(--text);
  padding: 11px; border-radius: 10px; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: background .15s, color .15s;
}
.seg-btn.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(47,124,246,.5); }

/* Tombol */
.btn {
  border: 0; border-radius: 12px; cursor: pointer;
  font-weight: 700; font-size: 15px; padding: 12px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost.danger { color: var(--danger); }
.btn-sm { padding: 7px 10px; font-size: 12.5px; border-radius: 9px; }
.btn-lg { padding: 14px 22px; font-size: 16px; }
.btn-action { width: 100%; font-size: 16px; padding: 14px; box-shadow: 0 10px 26px rgba(0,0,0,.5); }
.btn-action.stop { background: var(--danger); }
.btn-action.stop { box-shadow: 0 10px 26px rgba(239,68,68,.45); }

/* Hasil — kartu overlay melayang (1 shoot & multi) */
.single-result, .multi-result {
  background: rgba(12,20,36,.82); border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--radius); padding: 14px;
  backdrop-filter: blur(14px); box-shadow: 0 14px 34px rgba(0,0,0,.5);
}
.single-result { animation: pop .25s ease; }
.multi-result { max-height: 42dvh; overflow-y: auto; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sr-time { color: var(--muted); font-size: 12px; }
.sr-value {
  font-size: 16px; word-break: break-all; line-height: 1.45;
  background: #0c1424; border: 1px solid var(--line);
  padding: 12px; border-radius: 10px; margin-bottom: 12px;
  user-select: all; -webkit-user-select: all;
}
.sr-actions { display: flex; gap: 8px; }
.sr-actions .btn { flex: 1; }

.badge {
  font-size: 11px; font-weight: 800; letter-spacing: .4px;
  color: #cfe0ff; background: rgba(47,124,246,.18);
  border: 1px solid rgba(47,124,246,.4);
  padding: 3px 9px; border-radius: 999px; text-transform: uppercase;
}

/* Hasil multi */
.mr-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
}
.mr-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.mr-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mr-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }
.mr-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 10px 12px;
  animation: pop .2s ease;
}
.mr-item.fresh { border-color: var(--new); box-shadow: 0 0 0 1px rgba(250,204,21,.35); }
.mr-item .mi-main { flex: 1; min-width: 0; }
.mr-item .mi-val { font-size: 14px; word-break: break-all; line-height: 1.35; }
.mr-item .mi-sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.mr-item .mi-time { color: var(--muted); font-size: 11px; }
.mr-item .mi-copy {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  background: #0c1424; border: 1px solid var(--line); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}
.badge.sm { font-size: 9.5px; padding: 2px 6px; }

/* ----------------------------- LEMBAR ---------------------------------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  background: var(--panel); border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  padding: 10px 18px calc(20px + var(--safe-b));
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 44px; height: 5px; border-radius: 999px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.sheet .row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.sheet .row span { flex: 1; }
.sheet input[type=checkbox] { width: 44px; height: 26px; appearance: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; position: relative; cursor: pointer; transition: background .2s; }
.sheet input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.sheet input[type=checkbox]:checked { background: var(--primary); }
.sheet input[type=checkbox]:checked::after { transform: translateX(18px); background: #fff; }
.sheet-note { color: var(--muted); font-size: 12px; margin: 14px 0; }
.sheet .btn { width: 100%; margin-top: 6px; }

/* ----------------------------- TOAST ----------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(150px + var(--safe-b));
  transform: translateX(-50%) translateY(10px);
  background: #0c1424; color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  z-index: 60; opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

@media (min-width: 561px) {
  #app { box-shadow: 0 0 60px rgba(0,0,0,.5); }
}
