/* COST Pembaca QR & Barcode - lanjutan dari style.css (token COST yang sama) */

/* Bar mode: muat pas isi 2 tombol, rata tengah di panel */
.tabs {
  grid-template-columns: repeat(2, max-content);
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
}

.tab { padding: 8px 16px; }

/* Isi panel kiri: rata tengah semua */
.tabpane {
  padding-left: 0;
  padding-right: 0;
  text-align: center;
}

.tabpane .btn-primary { width: 50%; padding: 11px 22px; }

/* ---------- Dropbox pilih berkas ---------- */

.field label.dropzone {
  display: flex;
  flex-direction: column;
  width: min(100%, 260px);
  aspect-ratio: 1 / 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 auto;
  font-weight: 400;
  font-size: 14px;
  padding: 20px 14px;
  border: 1.5px dashed var(--blue);
  border-radius: var(--r-card);
  background: rgba(26, 86, 176, 0.05);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}

.field label.dropzone:hover { background: rgba(26, 86, 176, 0.11); }

@media (min-width: 900px) {
  .field label.dropzone { width: min(100%, 340px); }
}

.field label.dropzone.is-drag {
  background: rgba(26, 86, 176, 0.16);
  border-style: solid;
  outline: 2px dashed var(--blue);
  outline-offset: 5px;
}

.field label.dropzone:has(.file-hidden:focus-visible) {
  outline: 2.5px solid var(--blue);
  outline-offset: 2px;
}

.dropzone-icon {
  width: 34px;
  height: 34px;
  color: var(--blue);
}

.dropzone-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--blue-deep);
}

/* ---------- Area pindai ---------- */

.scan-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(100%, 360px);
  min-height: 240px;
  margin: 0 auto;
}

#qr-reader {
  position: relative;
  width: 100%;
  background: var(--ink);
  border-radius: 8px;
  overflow: hidden;
}

#qr-reader video {
  display: block;
  width: 100% !important;
  height: auto !important;
}

#qr-reader canvas { display: none; }
#qr-reader #qr-shaded-region { pointer-events: none; }

/* Sudut jendela bidik: satu momen kuat di halaman ini */
.scan-frame {
  position: absolute;
  inset: 10px;
  display: none;
  pointer-events: none;
  z-index: 2;
}

.scan-stage.is-live .scan-frame { display: block; }

.scan-frame i {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid var(--signal);
}

.scan-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.scan-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.scan-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

.scan-stage.hit { box-shadow: 0 0 0 3px var(--signal); }

/* [hidden] harus menang: aturan display di bawah jangan buat gambar kosong tampil */
#stage-img[hidden] { display: none; }

#stage-img {
  display: block;
  width: 100%;
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  background: var(--card);
}

.scan-stage .qr-empty {
  width: 100%;
  padding: 24px 16px;
}

#stage-status { text-align: center; }

/* ---------- Hasil ---------- */

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.result-kind {
  flex: none;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 600;
  color: #ffffff;
  background: var(--blue);
  border-radius: 999px;
  padding: 2px 9px;
}

.result-text {
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-actions .btn { text-decoration: none; }

/* Hasil terbaru: kartu terang dengan bilah biru, isi paling lengkap */
.result-hero {
  background: var(--card);
  border: 1.5px solid var(--rule);
  border-top: 4px solid var(--blue);
  border-radius: var(--r-card);
  padding: 16px 18px;
  margin-bottom: 10px;
}

.result-hero .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.result-hero .time {
  font-size: 12.5px;
  color: var(--ink-soft);
}

.result-hero .payload {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.45;
  overflow-wrap: anywhere;
  margin: 0 0 12px;
}

.result-hero .verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.result-hero .result-why {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.result-hero .result-actions {
  margin: 0;
  gap: 8px;
}

/* Arsip: baris satu baris, garis rambut, klik untuk tampilkan sebagai hasil terbaru */
.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 10px 4px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.result-row:hover { background: rgba(26, 86, 176, 0.06); }
.result-row:focus-visible { outline: 2.5px solid var(--blue); outline-offset: -2px; }

.result-row .time {
  flex: none;
  font-size: 12px;
  color: var(--ink-soft);
}

.result-row .result-text { flex: 1 1 auto; }

.result-safe {
  flex: none;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 9px;
}

.result-safe.is-ok { color: var(--blue-deep); background: rgba(26, 86, 176, 0.12); }
.result-safe.is-warn { color: #7a5c00; background: rgba(255, 210, 63, 0.45); }
.result-safe.is-bad { color: var(--danger); background: var(--danger-soft); }

/* Kosong: bingkai empat sudut, undangan buat mulai memindai */
#res-empty {
  position: relative;
  margin: 14px 0;
  padding: 30px 24px;
  text-align: center;
}

#res-empty i {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(26, 86, 176, 0.45);
}

#res-empty i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
#res-empty i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
#res-empty i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
#res-empty i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

#res-empty p { margin: 0; }

/* ---------- Mobile ---------- */

@media (max-width: 899px) {
  .panel-preview { order: 1; }
}
