/* DigiForge — instant quote workspace.
   Three columns: parts rail, 3D viewer, configurator + price. */

/* 74px nav + 1px header border. Getting this wrong by a pixel gives the whole
   page a scrollbar, which defeats the fixed workspace layout. dvh keeps it
   correct while mobile browser chrome slides in and out. */
:root { --hdr-h:75px; }

.quote-app {
  display:grid;
  grid-template-columns:248px minmax(0,1fr) 408px;
  height:calc(100vh - var(--hdr-h));
  height:calc(100dvh - var(--hdr-h));
  background:var(--bg-soft);
  overflow:hidden;
}
.q-col { display:flex; flex-direction:column; min-height:0; background:#fff; }
.q-rail   { border-right:1px solid var(--line); }
.q-config { border-left:1px solid var(--line); }
.q-stage  { background:var(--bg-tint); min-width:0; }

.q-head {
  flex-shrink:0; padding:16px 18px; border-bottom:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between; gap:.6rem;
}
.q-head h2 { font-size:.82rem; text-transform:uppercase; letter-spacing:.09em;
  color:var(--muted); font-weight:700; }
.q-body { flex:1; overflow-y:auto; padding:16px 18px; }
.q-foot { flex-shrink:0; border-top:1px solid var(--line); padding:16px 18px;
  background:#fff; }

/* ── Parts rail ───────────────────────────────────────────────────────── */
.part-list { display:flex; flex-direction:column; gap:8px; }
.part-item {
  border:1.5px solid var(--line); border-radius:var(--radius); padding:11px 12px;
  cursor:pointer; position:relative; background:#fff;
  transition:border-color .15s, background .15s;
}
.part-item:hover { border-color:var(--navy-600); }
.part-item.active { border-color:var(--accent); background:var(--accent-soft); }
.part-item.error  { border-color:var(--red); background:#fdecea; }
.part-name { font-size:.85rem; font-weight:650; color:var(--ink);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding-right:18px; }
.part-sub { font-size:.75rem; color:var(--muted); margin-top:2px;
  display:flex; justify-content:space-between; gap:.4rem; align-items:baseline; }
/* Long process names must truncate rather than push the price onto a new line. */
.part-sub > span:first-child { min-width:0; overflow:hidden;
  text-overflow:ellipsis; white-space:nowrap; }
.part-price { font-weight:750; color:var(--accent-dark); font-size:.86rem;
  flex-shrink:0; }
.part-x { position:absolute; top:6px; right:7px; border:none; background:none;
  color:var(--muted); cursor:pointer; font-size:1rem; line-height:1; padding:2px 4px;
  border-radius:4px; }
.part-x:hover { color:var(--red); background:#fdecea; }
.rail-empty { color:var(--muted); font-size:.85rem; text-align:center;
  padding:26px 8px; line-height:1.5; }
.add-part { border:1.5px dashed var(--line); border-radius:var(--radius);
  padding:14px; text-align:center; color:var(--muted); cursor:pointer;
  font-size:.86rem; font-weight:600; transition:border-color .15s, color .15s; }
.add-part:hover { border-color:var(--accent); color:var(--accent-dark); }

/* ── Stage / viewer ───────────────────────────────────────────────────── */
.stage-wrap { position:relative; flex:1; min-height:0; }
#viewer-canvas { width:100%; height:100%; display:block; }

.stage-empty, .stage-busy, .stage-error {
  position:absolute; inset:0; display:none; flex-direction:column;
  align-items:center; justify-content:center; gap:14px; text-align:center;
  padding:32px; background:var(--bg-tint); z-index:3;
}
.stage-empty.show, .stage-busy.show, .stage-error.show { display:flex; }
.stage-empty .dz {
  display:block;   /* it's a <label>; inline would break the centred layout */
  border:2px dashed #c6d2e0; border-radius:var(--radius-lg); background:#fff;
  padding:46px 56px; cursor:pointer; transition:border-color .15s, background .15s;
  max-width:460px;
}
.stage-empty .dz:hover, .stage-empty .dz.over { border-color:var(--accent);
  background:var(--accent-soft); }
.stage-empty svg { color:var(--accent); margin:0 auto 12px; }
.stage-empty h3 { margin-bottom:.3rem; }

.spin { width:52px; height:52px; border-radius:50%; border:4px solid #d7e0eb;
  border-top-color:var(--accent); animation:spin 1s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.busy-bar { width:230px; height:5px; background:#d7e0eb; border-radius:3px; overflow:hidden; }
.busy-bar i { display:block; height:100%; width:0; background:var(--accent);
  transition:width .35s ease; }

.stage-error .ico { width:52px; height:52px; border-radius:50%; background:#fdecea;
  color:var(--red); display:flex; align-items:center; justify-content:center;
  font-size:1.6rem; font-weight:700; }
.stage-error p { max-width:52ch; font-size:.9rem; }

.viewer-chip { position:absolute; top:14px; left:16px; z-index:2;
  background:rgba(255,255,255,.94); border:1px solid var(--line);
  border-radius:999px; padding:.32rem .85rem; font-size:.8rem; font-weight:600;
  color:var(--ink); box-shadow:var(--shadow-sm); }
.viewer-chip.right { left:auto; right:16px; }
.viewer-tools { position:absolute; bottom:16px; left:50%; transform:translateX(-50%);
  display:flex; gap:6px; z-index:2; }
.viewer-tools button { background:rgba(255,255,255,.94); border:1px solid var(--line);
  border-radius:var(--radius); padding:.42rem .8rem; font-size:.78rem; font-weight:600;
  color:var(--ink); cursor:pointer; box-shadow:var(--shadow-sm); }
.viewer-tools button:hover { background:#fff; border-color:var(--navy-600); }
.viewer-legend { position:absolute; top:14px; left:50%; transform:translateX(-50%);
  display:flex; gap:6px; flex-wrap:wrap; justify-content:center; z-index:2;
  max-width:70%; pointer-events:none; }
.lg { display:flex; align-items:center; gap:4px; background:rgba(255,255,255,.92);
  border:1px solid var(--line); border-radius:999px; padding:.12rem .55rem;
  font-size:.7rem; color:var(--ink); }
.lg i { width:7px; height:7px; border-radius:50%; display:block; }

/* ── Configurator ─────────────────────────────────────────────────────── */
.q-tabs { display:flex; border-bottom:1px solid var(--line); flex-shrink:0; }
.q-tab { flex:1; padding:14px 4px; text-align:center; font-size:.85rem;
  font-weight:650; color:var(--muted); background:none; border:none;
  border-bottom:2px solid transparent; cursor:pointer; }
.q-tab.active { color:var(--ink); border-bottom-color:var(--accent); }
.q-pane { display:none; }
.q-pane.active { display:block; }

.proc-switch { display:grid; grid-template-columns:repeat(3,1fr); gap:6px;
  margin-bottom:1.1rem; }
.proc-switch button { padding:.6rem .3rem; font-size:.78rem; font-weight:650;
  border:1.5px solid var(--line); background:#fff; color:var(--body);
  border-radius:var(--radius); cursor:pointer; line-height:1.25; }
.proc-switch button.active { border-color:var(--accent); background:var(--accent-soft);
  color:var(--accent-dark); }
.proc-switch button:disabled { opacity:.4; cursor:not-allowed; }

.qty-row { display:grid; grid-template-columns:repeat(4,1fr); gap:6px; margin-top:.5rem; }
.qty-row button { padding:.45rem 0; font-size:.8rem; font-weight:650;
  border:1.5px solid var(--line); background:#fff; border-radius:var(--radius);
  cursor:pointer; color:var(--body); }
.qty-row button.active { border-color:var(--accent); background:var(--accent-soft);
  color:var(--accent-dark); }

/* ── Price panel ──────────────────────────────────────────────────────── */
.price-box { text-align:center; padding:4px 0 14px; }
.price-each { font-size:2.6rem; font-weight:800; color:var(--ink);
  letter-spacing:-.03em; line-height:1.05; }
.price-each small { font-size:1.1rem; font-weight:700; color:var(--muted); }
.price-note { font-size:.8rem; color:var(--muted); margin-top:.25rem; }
.price-total { font-size:.95rem; font-weight:650; color:var(--ink); margin-top:.5rem; }
.price-lead { display:flex; align-items:center; justify-content:center; gap:.4rem;
  font-size:.82rem; color:var(--muted); margin-top:.45rem; }

/* Part size sits with the price — it is the first thing anyone sanity-checks
   against the number, and against a material's build envelope. */
.price-dims { margin-top:.7rem; padding-top:.7rem; border-top:1px solid var(--line);
  display:flex; justify-content:center; gap:1.1rem; flex-wrap:wrap; }
.price-dims div { text-align:center; }
.price-dims b { display:block; font-size:.88rem; font-weight:700; color:var(--ink);
  font-family:var(--mono); white-space:nowrap; }
.price-dims span { font-size:.68rem; color:var(--muted); text-transform:uppercase;
  letter-spacing:.05em; }

.lines { font-size:.84rem; }
.lines .ln { display:flex; justify-content:space-between; gap:1rem;
  padding:.42rem 0; border-bottom:1px solid var(--line); }
.lines .ln:last-child { border-bottom:none; }
.lines .ln span:first-child { color:var(--body); }
.lines .ln span:last-child { font-family:var(--mono); color:var(--ink);
  font-weight:600; white-space:nowrap; }
.lines .ln.total { border-top:2px solid var(--ink); border-bottom:none;
  margin-top:.35rem; padding-top:.6rem; font-weight:750; }
.lines .ln.total span { color:var(--ink); font-size:.95rem; }

details.acc { border:1px solid var(--line); border-radius:var(--radius);
  margin-bottom:.7rem; overflow:hidden; }
details.acc > summary { padding:.7rem .9rem; font-size:.85rem; font-weight:650;
  color:var(--ink); cursor:pointer; background:var(--bg-soft); list-style:none; }
details.acc > summary::-webkit-details-marker { display:none; }
details.acc > summary::after { content:'▾'; float:right; color:var(--muted); }
details.acc[open] > summary::after { content:'▴'; }
details.acc .acc-body { padding:.9rem; }

/* ── DFM analysis pane ────────────────────────────────────────────────── */
.score-row { display:flex; align-items:center; gap:16px; margin-bottom:1.2rem; }
.score-ring { width:74px; height:74px; border-radius:50%; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; font-size:1.4rem;
  font-weight:800; border:4px solid; }
.s-great{color:var(--green);border-color:var(--green);background:#e6f6ef}
.s-good {color:var(--teal); border-color:var(--teal); background:#e5f6f4}
.s-ok   {color:var(--amber);border-color:var(--amber);background:#fdf3e0}
.s-poor {color:var(--red);  border-color:var(--red);  background:#fdecea}

.stat-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.stat { background:var(--bg-soft); border-radius:var(--radius); padding:10px 12px; }
.stat b { display:block; font-size:1.05rem; color:var(--ink); font-weight:750; }
.stat span { font-size:.74rem; color:var(--muted); }

.issue { display:flex; gap:9px; padding:.6rem 0; border-bottom:1px solid var(--line); }
.issue:last-child { border-bottom:none; }
.issue i { width:8px; height:8px; border-radius:50%; flex-shrink:0; margin-top:6px; }
.i-error{background:var(--red)} .i-warning{background:var(--amber)} .i-info{background:var(--teal)}
.issue .txt { font-size:.83rem; line-height:1.45; }
.issue .txt b { display:block; color:var(--ink); font-size:.8rem; }

table.mini { width:100%; border-collapse:collapse; font-size:.78rem; }
table.mini th { text-align:left; color:var(--muted); font-weight:650;
  padding:.3rem .5rem; border-bottom:1px solid var(--line); }
table.mini td { padding:.35rem .5rem; border-bottom:1px solid var(--line);
  color:var(--ink); }
table.mini tr:last-child td { border-bottom:none; }

.empty-note { color:var(--muted); font-size:.86rem; text-align:center; padding:28px 8px; }

/* ── RFQ modal ────────────────────────────────────────────────────────── */
.modal-back { position:fixed; inset:0; background:rgba(8,19,31,.55); z-index:200;
  display:none; align-items:center; justify-content:center; padding:24px;
  backdrop-filter:blur(3px); }
.modal-back.show { display:flex; }
.modal { background:#fff; border-radius:var(--radius-lg); max-width:520px; width:100%;
  max-height:90vh; overflow-y:auto; box-shadow:var(--shadow-lg); padding:30px; }
.modal h2 { font-size:1.35rem; margin-bottom:.4rem; }
.modal .close { float:right; border:none; background:none; font-size:1.4rem;
  color:var(--muted); cursor:pointer; line-height:1; }

/* ── Unmanufacturable parts ───────────────────────────────────────────── */
/* A part with a bend collision cannot be made at all, so it reads as a hard
   stop rather than another warning: red rail entry, no price, blocked CTA. */
.part-item.blocked { border-color:var(--red); background:#fdecea; }
.part-item.blocked.active { border-color:var(--red); background:#fbdbd7; }
.part-item.blocked .part-name { color:var(--red); }

.rfq-note { font-size:.78rem; color:var(--muted); text-align:center;
  margin-top:.6rem; line-height:1.45; }
.rfq-note.blocked { color:var(--red); font-weight:600; text-align:left;
  background:#fdecea; border:1px solid #f5c6c2; border-radius:var(--radius);
  padding:.6rem .7rem; }

/* Sits where the price would be, so it is impossible to miss. */
.price-void { display:inline-block; font-size:1.45rem; font-weight:800;
  color:var(--red); letter-spacing:-.02em; line-height:1.2;
  background:#fdecea; border:1.5px solid var(--red); border-radius:var(--radius);
  padding:.4rem 1rem; }

.blocked-banner { border:1.5px solid var(--red); background:#fdecea;
  border-radius:var(--radius); padding:14px; margin-bottom:1.2rem; }
.blocked-banner .bb-head { display:flex; gap:10px; align-items:flex-start; }
.blocked-banner .bb-x { flex-shrink:0; width:24px; height:24px; border-radius:50%;
  background:var(--red); color:#fff; display:flex; align-items:center;
  justify-content:center; font-size:.8rem; font-weight:700; }
.blocked-banner strong { display:block; color:var(--red); font-size:.95rem;
  margin-bottom:.15rem; }
/* Scoped to .bb-detail on purpose: a bare `.bb-head span` also matches the
   ✕ badge and, being more specific than `.bb-x`, silently un-centres and
   recolours it. */
.blocked-banner .bb-detail { font-size:.82rem; color:var(--body);
  line-height:1.45; display:block; }
.blocked-banner .bb-list { margin:.7rem 0 .6rem 1.1rem; padding:0;
  font-size:.82rem; color:var(--ink); }
.blocked-banner .bb-list li { margin-bottom:.35rem; line-height:1.45; }
.blocked-banner .bb-foot { font-size:.8rem; color:var(--body);
  border-top:1px solid #f5c6c2; padding-top:.6rem; }

/* ── Drop-anywhere overlay ────────────────────────────────────────────── */
/* The empty-state drop zone disappears once a part is loaded, so file drops
   are handled at the window level instead and this covers the whole page. */
.drop-overlay { position:fixed; inset:0; z-index:250; display:none;
  align-items:center; justify-content:center; padding:32px;
  background:rgba(11,27,51,.72); backdrop-filter:blur(4px); }
.drop-overlay.show { display:flex; }
.drop-overlay-card { background:#fff; border:3px dashed var(--accent);
  border-radius:var(--radius-lg); padding:56px 72px; text-align:center;
  box-shadow:var(--shadow-lg); max-width:520px; pointer-events:none; }
.drop-overlay-card svg { color:var(--accent); margin:0 auto 14px; }
.drop-overlay-card h2 { font-size:1.5rem; margin-bottom:.4rem; }

.toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  background:var(--navy-800); color:#fff; padding:.8rem 1.3rem; border-radius:var(--radius);
  font-size:.9rem; z-index:300; box-shadow:var(--shadow-lg); display:none; }
.toast.show { display:block; }
.toast.err { background:var(--red); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width:1180px) {
  .quote-app { grid-template-columns:210px minmax(0,1fr) 360px; }
}
@media (max-width:980px) {
  .quote-app { grid-template-columns:1fr; height:auto; overflow:visible; }
  .q-col { border:none; border-bottom:1px solid var(--line); }
  .q-rail { order:1; }
  .q-stage { order:2; height:56vh; }
  .q-config { order:3; }
  .q-body { overflow:visible; }
}
