/* ══════════════════════════════════════════════════════════════
   STL Generator — Tufted Group
══════════════════════════════════════════════════════════════ */

/* ── Three-column layout ─────────────────────────────────────── */
.stl-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin: 2rem;
  min-height: 600px;
  align-items: start;
}

/* Force Chromium to always reserve scrollbar gutter space so layout
   width is stable whether or not a scrollbar appears */
html {
  scrollbar-gutter: stable;
}

.panel {
  background: var(--surface);
  padding: 1.5rem;
}

/* ── Panel header: label left, buttons right ─────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;       /* Prevent Chromium scrollbar-width from wrapping buttons */
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  min-width: 0;            /* Allow shrinking inside grid cell */
}

.panel-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  /* No bottom margin/border — handled by .panel-header */
  margin: 0;
  padding: 0;
  border: none;
  white-space: nowrap;
  min-width: 0;            /* Let label shrink so buttons stay on the same row */
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;          /* Buttons never shrink */
  align-items: center;
}

/* Compact button sizing inside the header */
.header-btns .btn {
  padding: 0.35rem 0.85rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
}


/* ── Model list (left sidebar) ───────────────────────────────── */
#modelsContainer {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#modelsContainer div {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.75rem;
  cursor: pointer;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
}

#modelsContainer div:hover { border-color: var(--accent); color: var(--text); }

#modelsContainer div.model-selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(74, 158, 255, 0.06);
}

#modelsContainer img {
  display: block;
  margin: 0 auto 0.5rem;
  width: 100%;
  max-width: 120px;
  height: 80px;
  object-fit: contain;
}


/* ── Status line ─────────────────────────────────────────────── */
#queueStatus {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 1.1em;
  margin-bottom: 0.75rem;
}


/* ── Blueprint container ─────────────────────────────────────── */
.blueprint-inline {
  width: 100%;
  aspect-ratio: 640 / 340;
  background: #0a1628;
  border: 1px solid #1e3a5f;
  display: flex;
  align-items: center;
  justify-content: center;
  /* overflow visible so foreignObject inputs aren't clipped */
  overflow: visible;
  margin-bottom: 1.25rem;
  position: relative;
}

.blueprint-inline svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.blueprint-inline .bp-empty {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #3a6a9f;
  text-align: center;
  padding: 2rem;
}


/* ── Parameter list (below blueprint) ────────────────────────── */
#paramForm {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

#paramForm:empty { display: none; }

#paramForm div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); /* minmax(0) prevents Chromium overflow blowout */
  align-items: center;
  gap: 0.5rem;
}

#paramForm label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.3;
}

#paramForm input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

#paramForm input::placeholder { color: var(--text-muted); opacity: 0.45; }
#paramForm input:focus { border-color: var(--accent); }


/* ── 3D preview canvas ───────────────────────────────────────── */
#preview {
  width: 100%;
  height: 500px;
  background: var(--surface2);
  border: 1px solid var(--border);
}


/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stl-layout { grid-template-columns: 1fr 1fr; margin: 1rem; }
  .stl-layout > .panel:first-child { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .stl-layout { grid-template-columns: 1fr; }
  #paramForm div { grid-template-columns: 1fr; }
}
