/* ============================================================================
 *  style.css — dark technical UI for the co-extrusion simulator
 * ==========================================================================*/
:root {
  --bg: #0a0e17;
  --panel: #111725;
  --panel2: #0d1320;
  --line: #223049;
  --txt: #d8e2f0;
  --txt-dim: #8ea0bd;
  --accent: #35d0ff;
  --ok: #35ffa0;
  --warn: #ffcd3c;
  --danger: #ff5566;
  --ceramic: #2f7bd6;
  --electrode: #d94f4f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font: 13px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh; overflow-y: auto;
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: linear-gradient(90deg, #0d1424, #101a30);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; color: var(--accent); }
.topbar h1 { font-size: 17px; margin: 0; }
.topbar p { margin: 2px 0 0; color: var(--txt-dim); font-size: 12px; }

.indicator {
  padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 13px;
  border: 1px solid; white-space: nowrap;
}
.ind-ok { color: var(--ok); border-color: var(--ok); background: rgba(53,255,160,.08); }
.ind-warn { color: var(--warn); border-color: var(--warn); background: rgba(255,205,60,.08); }
.ind-danger { color: var(--danger); border-color: var(--danger); background: rgba(255,85,102,.1); }

/* ---- layout ---- */
.layout {
  height: calc(100vh - 58px); display: grid;
  grid-template-columns: 300px 1fr 340px;
  gap: 1px; background: var(--line); overflow: hidden; flex: none;
}
.panel { background: var(--panel); overflow-y: auto; padding: 14px 16px; }
.panel.center { background: var(--panel2); display: flex; flex-direction: column; padding: 12px; }

.panel h2 {
  font-size: 13px; text-transform: none; color: var(--accent);
  margin: 18px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.panel h2:first-child { margin-top: 0; }
.panel h2 small { color: var(--txt-dim); font-weight: 400; }

/* ---- form rows ---- */
.row { display: block; margin: 10px 0; color: var(--txt-dim); font-size: 12px; }
.row.big { font-size: 13px; color: var(--txt); }
.row .val { color: var(--accent); font-weight: 700; }
select, input[type=range] { width: 100%; margin-top: 5px; }
select {
  background: #0c1220; color: var(--txt); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; font-size: 12px;
}
input[type=range] { accent-color: var(--accent); height: 4px; }

/* ---- channel editors ---- */
.chanEdit {
  background: #0c1220; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; margin-bottom: 10px;
}
.chanHead { font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.rheo { color: var(--txt-dim); font-size: 11px; margin-top: 6px; line-height: 1.4; }
.rheo small { color: #6f82a0; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }

/* ---- 3D scene ---- */
.sceneHead { display: flex; justify-content: space-between; align-items: center; }
.sceneHead h2 { border: none; margin: 4px 0 8px; }
.toggles { display: flex; gap: 14px; font-size: 12px; color: var(--txt-dim); }
.toggles label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
#scene { flex: 1; width: 100%; min-height: 320px; border-radius: 10px; display: block; background: #060912; }
.sceneCtrl { padding-top: 10px; }
.hint { color: var(--txt-dim); font-size: 11px; margin: 2px 0 10px; font-style: italic; }

/* ---- results table ---- */
.results { width: 100%; border-collapse: collapse; font-size: 11px; }
.results th, .results td { padding: 5px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.results th { color: var(--txt-dim); font-weight: 600; }
.results td:first-child { text-align: left; white-space: nowrap; }
.totals { margin-top: 8px; font-size: 12px; color: var(--txt-dim); }
.totals b { color: var(--accent); }

/* ---- slice inset ---- */
.sliceWrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#sliceCanvas { border: 1px solid var(--line); border-radius: 50%; background: #060912; }
.sliceLabel { font-size: 11px; color: var(--txt-dim); }

/* ---- pair list ---- */
.pair {
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 6px;
  padding: 7px 9px; margin-bottom: 7px; font-size: 12px;
}
.pair.ind-ok { border-left-color: var(--ok); }
.pair.ind-warn { border-left-color: var(--warn); }
.pair.ind-danger { border-left-color: var(--danger); }
.pair small { color: var(--txt-dim); }

/* ---- heatmap ---- */
.heatWrap { position: relative; }
#heatCanvas { width: 100%; border: 1px solid var(--line); border-radius: 6px; display: block; }
.heatAxis { display: flex; justify-content: space-between; font-size: 10px; color: var(--txt-dim); margin-top: 4px; }

/* ---- button ---- */
.btn {
  width: 100%; margin-top: 16px; padding: 10px; cursor: pointer;
  background: linear-gradient(90deg, #1c8fbf, #35d0ff); color: #04121b;
  border: none; border-radius: 8px; font-weight: 700; font-size: 13px;
}
.btn:hover { filter: brightness(1.1); }
.btn-sm {
  margin-top: 10px; padding: 7px; font-size: 12px;
  background: linear-gradient(90deg, #1c7a4a, #35ffa0);
}

/* ---- drive mode selector ---- */
.driveSel { display: flex; flex-direction: column; gap: 6px; }
.driveSel label {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 12px; color: var(--txt); padding: 6px 8px;
  background: #0c1220; border: 1px solid var(--line); border-radius: 6px;
}
.driveSel input { accent-color: var(--accent); }

/* ---- pusher slider row inside channel editor ---- */
.pusherRow {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: 11px; color: var(--txt-dim);
}
.pusherRow .val { color: var(--accent); font-weight: 700; }
.pusherRow .pin, .pusherRow .pcalc {
  display: inline-block; font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 3px; vertical-align: middle;
}
.pusherRow .pin { background: #1c6b3a; color: #b8ffd0; }      /* input value */
.pusherRow .pcalc { background: #333; color: #9aa8c0; }        /* computed value */
.hide { display: none !important; }
.row small { color: var(--txt-dim); font-weight: 400; }

/* ---- syringe remaining bar ---- */
.bar {
  display: inline-block; width: 46px; height: 8px; border-radius: 4px;
  background: #0c1220; border: 1px solid var(--line); overflow: hidden;
  vertical-align: middle; margin-right: 4px;
}
.bar i { display: block; height: 100%; }
.bar i.ind-ok { background: var(--ok); }
.bar i.ind-warn { background: var(--warn); }
.bar i.ind-danger { background: var(--danger); }

/* ---- footer ---- */
.foot { padding: 7px 18px; background: #0b1120; border-top: 1px solid var(--line);
  color: var(--txt-dim); font-size: 11px; }

/* scrollbars */
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ---- editable rheology parameters ---- */
.rheoEdit { margin: 8px 0 6px; }
.customNameRow { margin: 8px 0 4px; }
.customNameRow label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 10px; color: var(--accent);
}
.customNameRow input.customName {
  background: #0c1220; color: var(--txt); border: 1px solid var(--accent);
  border-radius: 5px; padding: 5px 7px; font-size: 12px; width: 100%;
}
.customNameRow input.customName:focus { outline: none; border-color: #6cf; }
.rheoGrid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 5px 10px; margin-bottom: 5px;
}
.rheoGrid label {
  display: flex; flex-direction: column;
  font-size: 10px; color: var(--txt-dim); gap: 3px;
}
.rheoGrid input.rp {
  background: #0c1220; color: var(--txt); border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 6px; font-size: 12px; width: 100%;
}
.rheoGrid input.rp:focus { outline: none; border-color: var(--accent); }
.rheoMeta { font-size: 11px; color: var(--txt-dim); line-height: 1.4; margin: 2px 0; }
a.rheoReset {
  font-size: 10px; color: var(--txt-dim); text-decoration: none;
  display: inline-block; margin-top: 2px;
}
a.rheoReset:hover { color: var(--accent); }

/* ---- toolpath planner panel ---- */
.planner { background: var(--panel2); border-top: 2px solid var(--accent); padding: 16px 20px; }
.plannerHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.plannerHead h2 { font-size: 15px; margin: 0; color: var(--txt); }
.plannerHead h2 small { color: var(--txt-dim); font-weight: 400; font-size: 11px; }
.planIndicator {
  padding: 6px 14px; border-radius: 18px; font-weight: 600; font-size: 12px;
  border: 1px solid var(--line); white-space: nowrap;
}
.planIndicator.ind-ok { color: var(--ok); border-color: var(--ok); }
.planIndicator.ind-warn { color: var(--warn); border-color: var(--warn); }
.planIndicator.ind-danger { color: var(--danger); border-color: var(--danger); }
.planGrid { display: grid; grid-template-columns: 280px 1fr 1fr; gap: 16px; align-items: start; }
.planCtrl label.row { display: block; font-size: 12px; color: var(--txt-dim); margin: 8px 0; }
.planCtrl .val { color: var(--txt); font-weight: 600; }
.planCtrl input[type=range] { width: 100%; margin-top: 4px; }
.chkline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--accent); margin: 10px 0 4px; }
.stlInfo { font-size: 11px; color: var(--txt-dim); background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); border-radius: 6px; padding: 7px 9px; margin: 8px 0 2px; line-height: 1.5; }
.stlInfo b { color: var(--txt); }
.planCtrl input[type=file] { font-size: 11px; color: var(--txt-dim); }
.planBtns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.viewTitle { font-size: 12px; color: var(--txt-dim); margin-bottom: 6px; }
.viewTitle small { color: #5f7290; }
#planCanvas, .pathScene {
  width: 100%; background: #0c1220; border: 1px solid var(--line);
  border-radius: 8px; display: block;
}
.pathScene { height: 300px; }
.planMetrics { font-size: 11.5px; color: var(--txt-dim); margin-top: 10px; line-height: 1.5; }
.planMetrics .pm { margin: 3px 0; }
.planMetrics b { color: var(--txt); }
.planMetrics .ok { color: var(--ok); }
.planMetrics .warn { color: var(--warn); }
.planMetrics .danger { color: var(--danger); }
.pmtab { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 11px; }
.pmtab th, .pmtab td { border: 1px solid var(--line); padding: 4px 6px; text-align: center; }
.pmtab th { color: var(--txt-dim); background: #0d1626; }
#shapeParams label.row { display: block; font-size: 12px; color: var(--txt-dim); margin: 8px 0; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; grid-auto-rows: min-content; height: auto; overflow-y: visible; }
  body { overflow: auto; }
  #scene { min-height: 380px; }
  .planGrid { grid-template-columns: 1fr; }
}
