/* =========================================================================
   shared/tool-ui.css — shared brand UI kit for the NZ structural tools.

   Extracted from WallBuildingConcept.html's inline <style> so that every tool
   renders identically (orange accent, Calibri Light, translucent blurred
   floating cards, sticky #ui-pin header, details.ctrl-group accordions,
   steppers, ⚙ keycard popover, #btn-v3 3D buttons, #site-select overlay and
   the #planPreview canvas).

   Warehoused here so warehouse.html consumes it today and WallBuildingConcept
   .html can drop its inline duplicate and link this file in a later refactor.
   Wall-table rules are kept so that drop-in stays a straight swap.
   ========================================================================= */
:root {
  --bg:#eceef0; --panel:#fff; --accent:#f37021; --accent-dark:#c85a10;
  --border:#d7dce0; --text:#111; --muted:#555; --ok:#1e8449; --danger:#c0392b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { overflow: hidden; background: var(--bg); font-family: "Calibri Light", Calibri, Arial, sans-serif;
  font-weight: 300; color: var(--text); line-height: 1.4; }
#canvas-container { width: 100vw; height: 100vh; }

/* --- Floating translucent card (brand style) shared by panels --- */
#ui, #site-panel, #keycard {
  background: rgba(255, 255, 255, 0.72); border: 1px solid #c9d0d6; border-radius: 8px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 24px rgba(0,0,0,.30); padding: 14px;
}
#ui {
  position: absolute; top: 20px; left: 20px; width: 360px;
  max-height: calc(100vh - 40px); overflow-y: auto; z-index: 10;
  scrollbar-width: none; -ms-overflow-style: none;   /* scrolls, no bar */
}
#ui::-webkit-scrollbar { display: none; }
/* Pinned header: title + live plan preview + result strip stay visible
   while the collapsible groups scroll beneath them. */
#ui-pin {
  position: sticky; top: -14px; margin: -14px -14px 8px;
  padding: 14px 14px 4px; z-index: 2;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 8px 8px 0 0;
}
#analysis-status { font-size: 11px; margin: 2px 0 8px; color: var(--muted); }
#massing-status { font-size: 11px; margin: 0 0 8px; color: var(--muted); }
#massing-status.hidden { display: none; }
h1 { font-size: 15px; font-weight: 400; margin: 0 0 10px;
  border-bottom: 3px solid var(--accent); padding-bottom: 6px; }
h2 { font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--muted); }
.control { margin-bottom: 10px; }
.control label { display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.control input[type=range] { width: 100%; accent-color: var(--accent); }
.control input[type=text], .control select, #site-search, #setback-row input, #keycard input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px;
  background: #fff; font: inherit; font-size: 13px; color: var(--text); }
.control select { cursor: pointer; }
.control input[type=text]:focus, .control select:focus, #site-search:focus, #keycard input:focus {
  border-color: var(--accent); outline: none; }
details.ctrl-group { margin: 8px 0 2px; border-top: 1px solid var(--border); padding-top: 6px; }
details.ctrl-group summary {
  cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .5px;
  color: var(--text); user-select: none; padding: 2px 0;
}
details.ctrl-group summary:hover { color: var(--accent-dark); }
details.ctrl-group[open] summary { margin-bottom: 6px; }

/* wall-parameter tables (EXTERNAL / INTERNAL WALLS in WallBuildingConcept) —
   kept here so that tool can drop its inline copy in a later refactor */
table.wall-table { width: 100%; border-collapse: collapse; margin: 2px 0 8px; }
table.wall-table th {
  font-size: 9px; font-weight: 600; color: var(--muted); text-align: left;
  padding: 1px 3px; letter-spacing: .3px; white-space: nowrap;
}
table.wall-table th.wt-row {
  color: var(--text); font-size: 11px; text-align: center; padding: 1px 2px; width: 14px;
}
table.wall-table td { padding: 2px 3px; vertical-align: middle; }
table.wall-table .stepper { margin: 0; width: 100%; }
table.wall-table .stepper .stepval { padding: 3px 0; font-size: 11px;
  border-right: 0; border-left: 0; }
table.wall-table .stepbtns { display: flex; flex-direction: column; width: 18px; }
table.wall-table .stepbtns button { width: 18px; padding: 0; margin: 0;
  font-size: 10px; line-height: 12px; border-radius: 0; }
table.wall-table .stepbtns button:first-child { border-bottom: 1px solid var(--border); }
table.wall-table input[type=range] { width: 100%; accent-color: var(--accent);
  margin: 0; height: 14px; }
table.wall-table .wt-len-cell { min-width: 48px; }
table.wall-table .wt-len { display: block; min-width: 22px; text-align: right;
  font-size: 9px; color: var(--muted); line-height: 10px; }
table.wall-table .wt-thick-cell { min-width: 44px; }
table.wall-table input[type=number] { width: 100%; box-sizing: border-box;
  padding: 2px 2px; font-size: 10px; text-align: center; color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; background: #fff;
  -moz-appearance: textfield; appearance: textfield; }
table.wall-table input[type=number]:focus { border-color: var(--accent); outline: none; }
table.wall-table input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* compact merged group (tight, boxed controls) */
details.ctrl-group.compact .control { margin-bottom: 6px; }
details.ctrl-group.compact .control label { font-size: 10px; margin-bottom: 2px; }
details.ctrl-group.compact .control input[type=range] { height: 16px; }
details.ctrl-group.compact .control input[type=text],
details.ctrl-group.compact .control select { padding: 4px 6px; font-size: 12px; }
details.ctrl-group.compact summary { font-size: 11px; padding: 1px 0; }
/* side-by-side control rows */
.ctl-row { display: flex; gap: 6px; }
.ctl-row .control { flex: 1; min-width: 0; margin-bottom: 6px !important; }
.ctl-row .ctl-narrow { flex: 0 0 78px; }
/* small stepper variant */
.stepper.sm button { width: 22px; font-size: 12px; }
.stepper.sm .stepval { font-size: 12px; padding: 3px 0; }
/* section subheadings inside a merged ctrl-group */
.subhead { font-size: 10px; font-weight: 600; letter-spacing: .5px; color: var(--muted);
  margin: 10px 0 6px; padding-top: 8px; border-top: 1px solid var(--border); }

/* generic edit overlay (wall / bay / custom) */
#wall-overlay, #bay-overlay, #overlay {
  position: fixed; z-index: 60; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.18); padding: 8px 10px;
  font-size: 11px; display: grid; gap: 3px; width: 150px;
}
#wall-overlay.hidden, #bay-overlay.hidden, #overlay.hidden { display: none; }
#wall-overlay label, #bay-overlay label, #overlay label { font-weight: 600; color: var(--muted); }
#wall-overlay input, #bay-overlay input, #overlay input { width: 100%; padding: 3px 6px; font-size: 12px; }
#wall-overlay .wo-row, #bay-overlay .wo-row, #overlay .wo-row { display: flex; gap: 6px; margin-top: 3px; }
#wall-overlay button, #bay-overlay button, #overlay button { flex: 1; margin: 0; padding: 4px; font-size: 11px; width: auto; }
#wo-del { background: #fbeae4; color: #c0392b; border-color: #e6b8ab; }

/* failing-member summary (FRAME RESULTS) */
table.fail-table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
table.fail-table th { font-size: 9px; font-weight: 600; color: var(--muted);
  text-align: left; padding: 1px 3px; border-bottom: 1px solid var(--border); }
table.fail-table td { font-size: 11px; font-weight: 600; padding: 2px 3px; color: #c0392b; }
#z-readout { font-size: 13px; font-weight: 600; margin: 4px 0 10px; }
#seis-period { font-size: 13px; font-weight: 600; margin: 4px 0 2px; }
#results-readout { font-size: 12px; color: var(--muted); margin: 4px 0; }
#results-readout b { color: var(--text); }

/* plan preview inset (live, colour-coded) */
#planPreview { width: 100%; display: block; margin: 2px 0 10px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; }
/* integer stepper (counts / steps) */
.stepper { display: flex; align-items: stretch; border: 1px solid var(--border);
  border-radius: 4px; overflow: hidden; background: #fff; }
.stepper button { width: 28px; margin: 0; padding: 5px 0; background: #fff;
  color: var(--text); border: 0; border-radius: 0; font-size: 14px; font-weight: 400; }
.stepper button:not(:disabled):hover { background: #f2f4f6; }
.stepper .stepval { flex: 1; text-align: center; padding: 6px 0; font-size: 13px;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border); }

button {
  width: 100%; margin-top: 4px; padding: 7px 12px;
  background: var(--accent); color: #fff; border: 0; border-radius: 5px;
  font-family: inherit; font-weight: 400; font-size: 13px; cursor: pointer;
  transition: background .15s ease;
}
button:not(:disabled):hover { background: var(--accent-dark); }
button:disabled { background: #c8cdd2; cursor: not-allowed; }
#status { font-size: 12px; margin-top: 6px; color: var(--muted); }
.toggle-btn, .review-btn, .kc-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.toggle-btn:not(:disabled):hover, .review-btn:not(:disabled):hover, .kc-ghost:not(:disabled):hover { background: #f2f4f6; }
.toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.hidden { display: none !important; }

.subhead.locked { color: #b6bcc2; }
.wall-table.locked { opacity: 0.45; pointer-events: none; }
#reset-layout-btn { width: auto; margin: 6px 10px 2px; padding: 4px 10px; font-size: 11px; }


/* --- Phase A: site selection map --- */
#site-select { position: fixed; inset: 0; z-index: 20; }
/* z-index:1 isolates Leaflet's panes in their own stacking context so they can
   never paint over the floating site panel. */
#map { position: absolute; inset: 0; background: #dfe6e9; z-index: 1; }
#site-panel { position: absolute; top: 20px; left: 20px; width: 340px; z-index: 1100; }
#site-readout { font-size: 12px; margin: 8px 0 4px 0; }
#set-site-btn:disabled { cursor: not-allowed; }
#site-info { font-size: 12px; color: var(--muted); margin: 8px 0 2px 0;
  border-top: 1px solid var(--border); padding-top: 6px; }
#site-info table { width: 100%; border-collapse: collapse; }
#site-info td { padding: 1px 2px; }
#site-info td:first-child { color: var(--muted); width: 42%; }

/* --- Settings gear + LINZ key card (unobtrusive, top-right) --- */
#gear-btn { position: fixed; top: 16px; right: 16px; z-index: 1200; width: 38px; height: 38px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; margin: 0; padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.18); }
#gear-btn:hover { background: #f2f4f6; }
#keycard { position: fixed; top: 62px; right: 16px; z-index: 1200; width: 300px; }
#keycard label { font-size: 11px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
#keycard .kc-row { display: flex; gap: 6px; margin-top: 6px; }
#keycard button { width: auto; flex: 1; margin: 0; padding: 5px; }
#kc-status, #kc-status-lds { font-size: 12px; color: var(--muted); margin-top: 6px; }
#keycard .kc-sep { border-top: 1px solid var(--border); margin: 10px 0 8px 0; }
.kc-check { display: flex; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 600;
  color: var(--text); cursor: pointer; }
.kc-check input { width: auto; margin: 0 6px 0 0; vertical-align: middle; }
.kc-check .kc-note { font-weight: 400; color: var(--muted); }

/* --- 3D terrain view (MapLibre GL, LINZ DEM + aerial) --- */
#glmap { position: fixed; inset: 0; z-index: 5; display: none; background: #dce9ed; }
#btn-v3, #btn-v3base { position: fixed; top: 16px; z-index: 1300; height: 38px; padding: 0 10px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit; font-weight: 600; margin: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.18); }
#btn-v3 { right: 62px; width: 38px; padding: 0; font-size: 12px; }
#btn-v3base { right: 108px; width: 38px; min-width: 38px; padding: 0; line-height: 36px; font-size: 12px; }
#btn-v3:hover, #btn-v3base:hover { background: #f2f4f6; }
#btn-v3.active { background: var(--accent); color: #fff; border-color: var(--accent); }
/* 3D on during site-select: the invisible site-select overlay must not swallow
   clicks meant for the GL map. */
body.v3-on #site-select { pointer-events: none; }
body.v3-on #site-panel { pointer-events: auto; }

