/* ============================================================
   GT71R Extractor — visual identity
   Terinspirasi panel instrumen industrial: monospace untuk data,
   warna gelap netral dengan accent amber (mengacu pada warna LED/
   indikator panel data logger), garis tipis presisi, tanpa gradient
   dekoratif yang tidak perlu.
   ============================================================ */

@font-face {
  font-family: 'system-ui-stack';
  src: local('system-ui');
}

:root {
  --bg: #14171a;
  --bg-panel: #1b1f23;
  --bg-panel-raised: #20252b;
  --line: #2b3138;
  --line-soft: #23282e;
  --text: #e8e6e0;
  --text-dim: #9aa0a6;
  --text-faint: #5c6369;
  --accent: #e8a23d;
  --accent-dim: #8a6526;
  --accent-text: #1a1408;
  --ok: #5fb98a;
  --warn: #e8a23d;
  --err: #d9684e;
  --mono: 'JetBrains Mono', 'SF Mono', 'Roboto Mono', 'Courier New', monospace;
  --sans: -apple-system, 'Inter', 'Segoe UI', system-ui-stack, sans-serif;
  --radius: 3px;
}

* { box-sizing: border-box; }

/* Pastikan atribut [hidden] selalu menyembunyikan elemen, walau ada class
   seperti .panel--center yang men-set display:flex (tanpa ini, specificity
   class menimpa display:none bawaan [hidden] sehingga panel "Membongkar..."
   tetap terlihat di belakang panel hasil). */
[hidden] { display: none !important; }

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

body {
  min-height: 100vh;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}

.app {
  max-width: 880px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 20px;
}

/* ---------- Header ---------- */

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.brand h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--text);
}

.brand__sub {
  margin: 1px 0 0;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 5px 12px 5px 9px;
  white-space: nowrap;
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(95, 185, 138, 0.15);
  flex-shrink: 0;
}

/* ---------- Main / panels ---------- */

.app__main {
  flex: 1;
  padding: 36px 0 60px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 18px;
}

/* ---------- Dropzone ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 64px 24px;
  cursor: pointer;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  margin: 16px;
  transition: border-color 120ms ease, background 120ms ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent-dim);
  background: rgba(232, 162, 61, 0.04);
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(232, 162, 61, 0.08);
}

.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropzone__icon {
  color: var(--text-faint);
}

.dropzone.is-dragover .dropzone__icon,
.dropzone:hover .dropzone__icon {
  color: var(--accent);
}

.dropzone__title {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.dropzone__title code {
  font-family: var(--mono);
  background: var(--bg-panel-raised);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 13px;
  color: var(--accent);
}

.dropzone__sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-faint);
}

/* ---------- Options (advanced, collapsed by default) ---------- */

.options {
  border-top: 1px solid var(--line);
  padding: 4px 20px;
}

.options summary {
  cursor: pointer;
  padding: 14px 0;
  font-size: 13px;
  color: var(--text-dim);
  list-style: none;
  user-select: none;
}

.options summary::-webkit-details-marker { display: none; }

.options summary::before {
  content: '▸ ';
  color: var(--text-faint);
}

.options[open] summary::before {
  content: '▾ ';
}

.options__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding-bottom: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 12px;
  color: var(--text-dim);
}

.field select,
.field input[type="text"],
.field input[type="number"] {
  background: var(--bg-panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 10px;
  font-size: 13px;
  font-family: var(--sans);
}

.field select:focus,
.field input:focus {
  outline: none;
  border-color: var(--accent-dim);
}

/* ---------- Processing ---------- */

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.processing__text {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- Error ---------- */

.panel--error {
  padding: 40px;
}

.error-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.error-box__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--err);
}

.error-box__detail {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--bg-panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  width: 100%;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 120ms ease;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn--primary:hover { filter: brightness(1.08); }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
}

.btn--ghost:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

/* ---------- Result header ---------- */

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
}

.result-header__eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ok);
  font-family: var(--mono);
}

.result-header h2 {
  margin: 0;
  font-size: 17px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.result-header__range {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Warnings ---------- */

.warnings {
  margin: 16px 22px 0;
  padding: 12px 14px;
  background: rgba(232, 162, 61, 0.08);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--warn);
}

/* ---------- CSV data preview ---------- */

.preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 0;
}

.preview-head__title {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-family: var(--mono);
}

.preview-head__note {
  font-size: 11.5px;
  color: var(--text-dim);
  font-family: var(--mono);
  text-align: right;
}

.table-wrap {
  padding: 10px 22px 22px;
  overflow: auto;
  max-height: 60vh;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: right;
  font-weight: 600;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 8px 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table th:first-child,
.data-table th:nth-child(2) { text-align: left; }

.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

.data-table td.col-time {
  text-align: left;
  color: var(--text-dim);
}

.data-table td.cell-empty {
  color: var(--text-faint);
}

.data-table tbody tr:hover td {
  background: var(--bg-panel-raised);
}

/* ---------- Footer ---------- */

.app__footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 18px 0 28px;
  font-family: var(--mono);
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .app__header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .result-header { flex-direction: column; }
  .result-actions { width: 100%; }
  .result-actions .btn { flex: 1; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--line); }
}
