/* ══════════════════════════════════════════════════════════════════════
   GCode Merger — Design tokens
   ══════════════════════════════════════════════════════════════════════ */
:root {
  --ink:          #0A0E1A;
  --panel:        #121826;
  --panel-raised: #182136;
  --line:         #232D45;

  --text:         #E7EBF5;
  --text-muted:   #8996B3;
  --text-dim:     #56607A;

  --cyan:      #3FD6F0;  /* Step 1 */
  --amber:     #FFA63D;  /* Step 2 */
  --violet:    #B587FF;  /* Step 3 */
  --mint:      #35DE93;  /* Step 4 */
  --warn:      #FFCB57;
  --error:     #FF6B7F;

  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --transition: 150ms ease;
}

/* ── Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* SOLUSI BUG MODAL: Memaksa elemen dengan atribut hidden untuk hilang */
[hidden] { display: none !important; }

h1, h2, h3, h4 { font-family: var(--font-mono); font-weight: 600; margin: 0; }
p { margin: 0; }
button, input { font: inherit; }
a { color: var(--cyan); }

a:focus-visible, button:focus-visible, [tabindex]:focus-visible, input:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 2px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Background blueprint grid ───────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(63,214,240,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63,214,240,0.035) 1px, transparent 1px),
    linear-gradient(rgba(63,214,240,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63,214,240,0.07) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
}

/* ── Topbar ───────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10,14,26,0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 22px; color: var(--cyan); line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-family: var(--font-mono); font-weight: 600; font-size: 15px; letter-spacing: 0.02em; }
.brand-sub { font-size: 11px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.version-tag { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.btn-icon {
  background: transparent; border: 1px solid var(--line); color: var(--text-muted);
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color var(--transition), color var(--transition);
}
.btn-icon:hover { border-color: var(--cyan); color: var(--cyan); }

/* ── Page shell ───────────────────────────────────────────────────── */
.page { position: relative; z-index: 1; max-width: 800px; margin: 0 auto; padding: 40px 24px 60px; }

/* ── Hero ─────────────────────────────────────────────────────────── */
.hero { text-align: center; margin-bottom: 40px; }
.hero h1 { font-size: clamp(21px, 3.2vw, 28px); letter-spacing: -0.01em; line-height: 1.35; margin: 0 auto 14px; }
.hero p { color: var(--text-muted); font-size: 14.5px; max-width: 560px; margin: 0 auto; }

/* ── Panels (Steps) ───────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.panel[data-accent="cyan"]   { border-left-color: var(--cyan); }
.panel[data-accent="amber"]  { border-left-color: var(--amber); }
.panel[data-accent="violet"] { border-left-color: var(--violet); }
.panel[data-accent="mint"]   { border-left-color: var(--mint); }

.panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.step-badge {
  flex: none; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-weight: 700; font-size: 14px;
  color: var(--ink); background: var(--text-dim);
}
.panel[data-accent="cyan"] .step-badge   { background: var(--cyan); }
.panel[data-accent="amber"] .step-badge  { background: var(--amber); }
.panel[data-accent="violet"] .step-badge { background: var(--violet); }
.panel[data-accent="mint"] .step-badge   { background: var(--mint); }

.panel-head h2 { font-size: 16px; margin: 0 0 4px; }
.panel-desc { font-size: 13.5px; color: var(--text-muted); margin: 0; }

/* ── Dropzones ────────────────────────────────────────────────────── */
.dropzone {
  position: relative; min-height: 120px;
  border: 1.5px dashed var(--line); border-radius: var(--radius-md);
  cursor: pointer; transition: border-color var(--transition), background var(--transition);
  display: flex; margin-top: 10px;
}
.panel[data-accent="cyan"] .dropzone:hover, .panel[data-accent="cyan"] .dropzone:focus-visible { border-color: var(--cyan); background: rgba(63,214,240,0.05); }
.panel[data-accent="violet"] .dropzone:hover, .panel[data-accent="violet"] .dropzone:focus-visible { border-color: var(--violet); background: rgba(181,135,255,0.05); }

.dropzone-empty { margin: auto; text-align: center; padding: 20px; color: var(--text-muted); }
.dz-icon { width: 30px; height: 30px; color: var(--text-dim); margin-bottom: 8px; }
.dropzone-empty p { margin: 0 0 4px; font-size: 13px; color: var(--text); }
.dropzone-empty span { font-size: 11px; color: var(--text-dim); }

.dropzone-loaded { width: 100%; padding: 16px; }
.loaded-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.loaded-check {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(53,222,147,0.15); color: var(--mint); font-size: 12px; font-weight: 700;
}
.loaded-name-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.loaded-name-wrap strong { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.link-btn {
  background: none; border: none; padding: 0; font-size: 11px;
  color: var(--text-dim); text-decoration: underline; cursor: pointer; width: fit-content;
}
.link-btn:hover { color: var(--cyan); }

.stat-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-family: var(--font-mono); font-size: 12px; }
.stat-list dt { color: var(--text-muted); }
.stat-list dd { margin: 0; font-weight: 600; }
.stat-list dd.warn-text { color: var(--warn); }
.stat-list dd.mint-text { color: var(--mint); }

/* ── Buttons & Forms ──────────────────────────────────────────────── */
.btn {
  font-family: var(--font-sans); font-weight: 600; font-size: 13px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: none;
  cursor: pointer; transition: filter var(--transition), transform 80ms ease; color: var(--ink);
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { background: var(--panel-raised) !important; color: var(--text-dim) !important; cursor: not-allowed; }
.btn-amber { background: var(--amber); }
.btn-mint { background: var(--mint); }
.btn-large { padding: 16px 24px; font-size: 16px; width: 100%; border-radius: var(--radius-md); margin-top: 20px; }

.panel-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-left: 40px; }
.panel-note { font-size: 12px; color: var(--text-dim); }

/* Toggle */
.switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  position: relative; width: 36px; height: 20px; background: var(--line);
  border-radius: 999px; transition: background var(--transition); flex: none;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; background: var(--text); border-radius: 50%;
  transition: transform var(--transition);
}
.switch-row input:checked + .switch { background: var(--mint); }
.switch-row input:checked + .switch::after { transform: translateX(16px); background: var(--ink); }
.switch-label { font-size: 13px; font-weight: 600; }

/* ── Options Split Grid (Step 4 UI) ── */
.options-grid-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-left: 40px; /* Sejajar dengan teks judul panel */
  padding: 20px 24px;
  background: var(--panel-raised);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  margin-bottom: 24px;
}
.opts-col { display: flex; flex-direction: column; }
.opts-heading {
  font-size: 11.5px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin: 0 0 16px 0; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* Checkbox spacing */
.opts-col .checkbox-row { margin-bottom: 12px; }
.opts-col .checkbox-row:last-child { margin-bottom: 0; }

/* Bed Size Layout */
.bed-size-wrapper {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-muted);
  margin-left: 46px; /* 36px (lebar switch) + 10px (gap) agar sejajar dengan teks Auto-center */
}
.bed-inputs { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.bed-inputs input {
  width: 60px; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-family: var(--font-mono); font-size: 13px; padding: 4px 8px; border-radius: var(--radius-sm); text-align: center;
}

/* ── Custom Tooltip ── */
.tooltip-wrapper {
  position: relative; display: inline-flex; align-items: center; margin-left: 6px;
}
.tooltip-icon {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-dim); color: var(--ink);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: help; transition: background 150ms ease, transform 150ms ease;
}
.tooltip-wrapper:hover .tooltip-icon { background: var(--cyan); transform: scale(1.1); }
.tooltip-text {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(6px);
  background: var(--text); color: var(--ink);
  padding: 6px 12px; border-radius: var(--radius-sm); font-size: 11.5px;
  white-space: nowrap; opacity: 0; visibility: hidden; transition: 200ms ease;
  box-shadow: 0 8px 16px rgba(0,0,0,0.3); z-index: 10; pointer-events: none;
  font-weight: 500; font-family: var(--font-sans);
}
/* Segitiga panah ke bawah untuk tooltip */
.tooltip-text::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border-width: 5px; border-style: solid;
  border-color: var(--text) transparent transparent transparent;
}
.tooltip-wrapper:hover .tooltip-text {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}

/* ── Responsive Adjustment for Step 4 ── */
@media (max-width: 640px) {
  .options-grid-split {
    grid-template-columns: 1fr; /* Berubah jadi 1 kolom bertumpuk di HP */
    gap: 24px; margin-left: 0; padding: 16px;
  }
  .bed-size-wrapper { margin-left: 0; margin-top: 4px; }
}
.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px;}
.checkbox-row input { accent-color: var(--mint); width: 15px; height: 15px; }

/* ── Merge Status ─────────────────────────────────────────────────── */
.merge-status { text-align: center; margin: 12px 0 0; font-size: 13.5px; color: var(--text-dim); }
.merge-status.ready { color: var(--mint); font-weight: 600; }
.merge-status.error { color: var(--error); }

/* ── Log panel ────────────────────────────────────────────────────── */
.log-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; margin-top: 32px; }
.log-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel-raised); border-bottom: 1px solid var(--line);
  font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em;
}
.log-output { height: 220px; overflow-y: auto; padding: 12px 16px; font-family: var(--font-mono); font-size: 12px; line-height: 1.7; }
.log-line { white-space: pre-wrap; overflow-wrap: anywhere; animation: log-in 150ms ease; }
@keyframes log-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
.log-info    { color: var(--text-muted); }
.log-success { color: var(--mint); }
.log-warning { color: var(--warn); }
.log-error   { color: var(--error); }
.log-head-line { color: var(--cyan); font-weight: 600; }
.log-center  { color: var(--mint); }
.log-stl     { color: var(--amber); }

/* ── Toasts & Modal ───────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px;
  z-index: 100; max-width: min(340px, calc(100vw - 40px));
}
.toast {
  background: var(--panel-raised); border: 1px solid var(--line); border-left: 3px solid var(--mint);
  border-radius: var(--radius-md); padding: 12px 36px 12px 14px; position: relative; font-size: 13px;
  animation: toast-in 200ms ease; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast strong { display: block; margin-bottom: 3px; }
.toast p { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.toast-error { border-left-color: var(--error); }
.toast-warning { border-left-color: var(--warn); }
.toast-close {
  position: absolute; top: 8px; right: 8px; background: none; border: none; color: var(--text-dim);
  font-size: 16px; cursor: pointer; padding: 4px;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,7,13,0.7); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  max-width: 560px; width: 100%; max-height: 82vh; display: flex; flex-direction: column;
  animation: modal-in 180ms ease;
}
@keyframes modal-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; padding: 4px 8px; }
.modal-body { padding: 18px 22px 24px; overflow-y: auto; font-size: 13px; color: var(--text-muted); }
.modal-body h3 { font-size: 13px; color: var(--text); margin: 20px 0 6px; }
.modal-body h3:first-child { margin-top: 0; }
.mh-cyan { color: var(--cyan); } .mh-amber { color: var(--amber); } .mh-violet { color: var(--violet); } .mh-mint { color: var(--mint); }
.modal-body p { margin: 0 0 10px; line-height: 1.6; }
.modal-body ul { margin: 0 0 10px; padding-left: 18px; }
.modal-body li { margin-bottom: 4px; }
.modal-body strong { color: var(--text); }
.page-footer { text-align: center; padding: 22px 24px 40px; font-size: 12px; color: var(--text-dim); }

@media (max-width: 640px) {
  .page { padding: 28px 16px 48px; }
  .panel-row, .options-grid { margin-left: 0; }
  .panel-head { flex-direction: column; gap: 8px; }
}

/* ── Styling tambahan khusus untuk elemen Markdown di dalam Modal ── */
.modal-body hr { border: none; border-top: 1px dashed var(--line); margin: 24px 0; }
.modal-body blockquote {
  margin: 14px 0; padding: 12px 16px;
  background: rgba(255, 166, 61, 0.08);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 12.5px;
}
.modal-body code {
  background: var(--panel-raised); padding: 2px 6px;
  border-radius: 4px; font-family: var(--font-mono);
  font-size: 11.5px; border: 1px solid var(--line);
}

/* ── Progress Indicators (Visual Feedback) ── */
.panel {
  transition: border-color var(--transition), background var(--transition);
}
.step-badge {
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1), background 200ms ease;
}

/* State ketika sebuah langkah selesai (complete) */
.panel.panel-complete {
  border-left-color: var(--mint) !important;
  border-color: rgba(53, 222, 147, 0.3);
  background: rgba(53, 222, 147, 0.03);
}
.panel.panel-complete .step-badge {
  background: var(--mint) !important;
  color: var(--ink) !important;
  transform: scale(1.15);
}