/* Anatomi — Atlas 3D. Gaya datar, ringkas, tanpa dekorasi. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --viewport: #eceff2;
  --line: #e3e6ea;
  --line-soft: #eef0f3;
  --ink: #1b1f24;
  --muted: #66707a;
  --faint: #9aa3ad;
  --navy: #16324f;
  --navy-hover: #1e4066;
  --teal: #0d9488;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; width: 100vw; height: 100vh; overflow: hidden; }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 14px; border-radius: 4px;
  font: 500 13px var(--font); cursor: pointer;
  border: 1px solid transparent; white-space: nowrap; user-select: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-hover); }
.btn-ghost { background: transparent; border-color: #c9cfd6; color: var(--ink); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-ghost.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-block { width: 100%; }
.btn-text {
  background: none; border: none; cursor: pointer;
  font: 500 13px var(--font); color: var(--muted); padding: 6px 8px; border-radius: 4px;
}
.btn-text:hover { color: var(--ink); background: var(--line-soft); }
.btn-text-sm { font-size: 12px; padding: 2px 4px; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 17px; line-height: 1; color: var(--faint); padding: 2px 6px; border-radius: 4px;
}
.btn-icon:hover { color: var(--ink); background: var(--line-soft); }

/* ---------- header ---------- */
#header {
  display: flex; align-items: center; gap: 24px;
  height: 52px; padding: 0 16px; flex-shrink: 0;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 150px; user-select: none; }
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--faint); }

#search-container { position: relative; flex: 1; max-width: 480px; }
.search-input-wrapper {
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid #c9cfd6; border-radius: 4px; padding: 0 10px;
}
.search-input-wrapper:focus-within { background: #fff; border-color: var(--teal); }
.search-icon { color: var(--faint); flex-shrink: 0; }
#search-input {
  flex: 1; border: none; background: transparent; outline: none;
  padding: 7px 8px; font: 13px var(--font); color: var(--ink); min-width: 0;
}
#search-input::placeholder { color: var(--faint); }
.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 360px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 8px 24px rgba(20, 30, 40, 0.12); z-index: 50;
}
.search-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line-soft);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--line-soft); }
.search-item-info { display: flex; flex-direction: column; min-width: 0; }
.search-item-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-meta { font: 11px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-badge { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.search-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* ---------- layout 3 kolom ---------- */
#main-content { display: flex; flex: 1; min-height: 0; }
.sidebar {
  background: var(--panel); display: flex; flex-direction: column;
  min-height: 0; z-index: 10;
}
#systems-panel { width: 264px; min-width: 264px; border-right: 1px solid var(--line); }
#info-panel { width: 320px; min-width: 320px; border-left: 1px solid var(--line); }

.sidebar-header { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.sidebar-title-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.sidebar-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.count-text { font: 12px var(--mono); color: var(--faint); }
.sidebar-quick-actions { display: flex; align-items: center; gap: 6px; }
.action-sep { color: var(--line); }

.systems-list { flex: 1; overflow-y: auto; padding: 6px 8px; display: flex; flex-direction: column; }
.system-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 4px; cursor: pointer; user-select: none;
  border-left: 2px solid transparent;
}
.system-row:hover { background: var(--line-soft); }
.system-row.active { border-left-color: var(--teal); background: var(--line-soft); }
.system-checkbox { width: 14px; height: 14px; accent-color: var(--navy); cursor: pointer; flex-shrink: 0; }
.system-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.18); }
.system-info-col { flex: 1; min-width: 0; }
.system-name-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.system-name-id { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.system-mesh-count { font: 11px var(--mono); color: var(--faint); flex-shrink: 0; }
.system-status-row { display: flex; align-items: baseline; gap: 6px; }
.system-name-en { font-size: 11px; color: var(--faint); }
.system-status-badge { font-size: 11px; }
.status-active { color: var(--green); }
.status-hidden { color: var(--faint); }
.status-loading { color: var(--amber); }
.status-unloaded { color: var(--faint); }

/* ---------- viewport ---------- */
.viewport-container { flex: 1; position: relative; background: var(--viewport); min-width: 0; overflow: hidden; }
#webgl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

/* bar kuis: menempel di atas viewport */
.quiz-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 25;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.quiz-label { font-weight: 700; }
.quiz-stats { color: var(--muted); font-size: 12px; white-space: nowrap; }
.quiz-target { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-target strong { font-weight: 700; }
.quiz-feedback { color: var(--muted); font-size: 12px; flex: 1; min-width: 0; }
.quiz-feedback.correct { color: var(--green); font-weight: 600; }
.quiz-feedback.wrong { color: var(--red); font-weight: 600; }
.quiz-bar .btn-text { margin-left: auto; flex-shrink: 0; }

/* bar bedah: menempel di bawah viewport */
.explode-bar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 15;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: var(--panel); border-top: 1px solid var(--line);
}
.explode-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.segmented { display: flex; border: 1px solid #c9cfd6; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.seg-btn {
  background: var(--panel); border: none; cursor: pointer;
  font: 500 12px var(--font); color: var(--muted); padding: 5px 12px;
}
.seg-btn + .seg-btn { border-left: 1px solid #c9cfd6; }
.seg-btn:hover { background: var(--line-soft); }
.seg-btn.active { background: var(--navy); color: #fff; }
.slider { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; background: #c9cfd6; outline: none; min-width: 80px; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--teal); border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25); cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--teal); border: 2px solid #fff; cursor: pointer;
}
.explode-value { font: 600 12px var(--mono); color: var(--muted); min-width: 38px; text-align: right; }
.viewport-hints { font-size: 11px; color: var(--faint); white-space: nowrap; margin-left: auto; user-select: none; }

/* loader: tanpa kartu */
.startup-loader {
  position: absolute; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--viewport); text-align: center; padding: 0 40px;
}
.loader-spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid #c9cfd6; border-top-color: var(--navy);
  animation: spin 0.8s linear infinite; margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-title { font-size: 14px; font-weight: 600; }
.loader-desc { font-size: 12px; color: var(--muted); min-height: 18px; }
.progress-bar-bg { width: 220px; height: 3px; background: #d4d9df; border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress-bar-fill { height: 100%; background: var(--navy); transition: width 0.2s ease; }
.loader-counter { font: 12px var(--mono); color: var(--faint); }

/* ---------- panel info ---------- */
.info-empty-state {
  display: flex; align-items: center; justify-content: center;
  height: 100%; padding: 32px; text-align: center;
}
.info-empty-text { font-size: 13px; color: var(--faint); line-height: 1.6; }
.info-content { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.info-card-header { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.info-badge-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.system-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.info-title-id { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.info-latin { font-size: 13px; font-style: italic; color: var(--muted); margin-top: 2px; }
.info-dataset { margin-top: 8px; font-size: 11px; color: var(--faint); }
.info-dataset-key { margin-right: 4px; }
.info-dataset-val { font-family: var(--mono); color: var(--muted); word-break: break-all; }
.info-card-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.info-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin-bottom: 4px; }
.info-desc-text { font-size: 13px; line-height: 1.65; }
.info-fact-box { border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; background: var(--bg); }
.info-fact-text { font-size: 12.5px; line-height: 1.6; }
.info-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meta-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 4px; }
.meta-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.meta-value { font: 600 12px var(--mono); word-break: break-all; }
.info-card-footer { padding: 10px 16px; border-top: 1px solid var(--line); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 28, 38, 0.45);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--panel); width: 340px; border-radius: 6px; padding: 22px;
  border: 1px solid var(--line); text-align: center;
}
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.modal-score { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 6px; }
.modal-score-den { font-size: 15px; font-weight: 500; color: var(--faint); }
.modal-summary { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.modal-metrics { display: flex; gap: 8px; margin-bottom: 16px; }
.metric {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 4px; padding: 8px;
}
.metric-label { font-size: 11px; color: var(--faint); }
.metric-val { font-size: 15px; font-weight: 700; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }

/* ---------- footer ---------- */
#footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 28px; padding: 0 14px; flex-shrink: 0;
  background: var(--panel); border-top: 1px solid var(--line);
  font-size: 11px; color: var(--faint); user-select: none;
}
.footer-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.footer-left span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-note { white-space: nowrap; }
.footer-right { font-family: var(--mono); white-space: nowrap; }

/* elemen khusus mobile: sembunyi di desktop */
.btn-menu, #btn-close-drawer, .reset-m, .drawer-scrim, .sheet-handle { display: none; }
.sidebar-title-row .count-text { margin-left: auto; }
#btn-close-drawer { margin-left: 2px; }

/* scrollbar tipis */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9cfd6; border-radius: 4px; border: 2px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ==================== mobile (<=820px) ==================== */
@media (max-width: 820px) {
  #app { height: 100vh; height: 100dvh; }

  /* header jadi dua baris */
  #header { flex-wrap: wrap; height: auto; min-height: 52px; padding: 8px 10px; gap: 8px 10px; }
  .btn-menu { display: inline-flex; }
  .brand { min-width: 0; }
  .brand-sub { display: none; }
  #search-container { order: 5; flex: 1 1 100%; max-width: none; }
  #btn-reset-view { display: none; }
  .header-actions { margin-left: auto; }

  /* panel sistem jadi drawer kiri */
  #systems-panel {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
    width: 300px; min-width: 0; max-width: 86vw;
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 24px rgba(20, 30, 40, 0.18);
  }
  body.drawer-open #systems-panel { transform: translateX(0); }
  #btn-close-drawer { display: inline-flex; }
  .drawer-scrim {
    display: none;
    position: fixed; inset: 0; z-index: 55;
    background: rgba(20, 28, 38, 0.4);
  }
  body.drawer-open .drawer-scrim { display: block; }

  /* panel info jadi bottom sheet */
  #info-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 70;
    width: auto; min-width: 0; max-height: 54dvh;
    border-left: none; border-top: 1px solid var(--line);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 24px rgba(20, 30, 40, 0.16);
    transform: translateY(105%);
    transition: transform 0.22s ease;
  }
  body.sheet-open #info-panel { transform: translateY(0); }
  #info-empty { display: none !important; }
  .sheet-handle {
    display: block; width: 36px; height: 4px; border-radius: 2px;
    background: #c9cfd6; margin: 8px auto 0; flex-shrink: 0;
  }
  .info-card-header { padding-top: 8px; }

  /* bar bedah: padat, tanpa hints */
  .explode-bar { gap: 8px; padding: 8px 10px; }
  .viewport-hints { display: none; }
  .reset-m { display: inline-flex; flex-shrink: 0; }
  .explode-label { display: none; }
  .slider { min-width: 60px; }

  /* bar kuis boleh wrap */
  .quiz-bar { flex-wrap: wrap; gap: 4px 12px; padding: 8px 10px; font-size: 12px; }
  .quiz-feedback { flex: 1 1 100%; order: 5; }

  /* footer hemat tempat */
  #footer { font-size: 10px; padding: 0 10px; }
  .footer-note { display: none; }

  .modal-card { width: calc(100vw - 48px); max-width: 340px; }
}
