/* ──────────────────────────────────────────────────────────────────
   Structural Analyser — New Feature Styles
   Added alongside style.css; uses the same CSS variables.
   ────────────────────────────────────────────────────────────────── */

/* ── Performance Overlay (js/core/perf.js) ─────────────────────── */
.perf-overlay {
  position: fixed;
  bottom: 36px;
  right: 10px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font: 11px/1.5 monospace;
  padding: 3px 9px;
  border-radius: 5px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.9;
  transition: opacity 0.4s;
}
.perf-overlay.warn {
  background: rgba(198, 40, 40, 0.82);
  color: #ffe0e0;
}
.perf-overlay:empty { display: none; }

/* ── Section DB Search Modal ────────────────────────────────────── */
#modal-section-db .db-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
#modal-section-db .db-search-row input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
}
#modal-section-db .db-search-row select {
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--text);
}
#modal-section-db .db-results {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}
#modal-section-db .db-results table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
#modal-section-db .db-results th {
  position: sticky;
  top: 0;
  background: var(--panel-bg);
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#modal-section-db .db-results td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-light, #eee);
}
#modal-section-db .db-results tr:hover td {
  background: var(--hover-bg, rgba(21,101,192,0.06));
  cursor: pointer;
}
#modal-section-db .db-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
#modal-section-db .db-badge.steel    { background:#e3f2fd; color:var(--accent); }
#modal-section-db .db-badge.concrete { background:#fff3e0; color:#e65100; }
#modal-section-db .db-badge.timber   { background:#f1f8e9; color:#33691e; }
#modal-section-db .db-badge.other    { background:#fce4ec; color:#880e4f; }

/* ── Auto-save indicator ────────────────────────────────────────── */
#autosave-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success, #43a047);
  margin-left: 6px;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.3s;
}
#autosave-dot.saving  { background: #fb8c00; opacity: 1; }
#autosave-dot.saved   { background: #43a047; opacity: 1; }
#autosave-dot.error   { background: #e53935; opacity: 1; }

/* ── Extruded-view notice ───────────────────────────────────────────
   Explains which overlays the solid view suppresses. Bottom-left, clear of
   the ViewCube (top-right) and the drawing-plane bar (bottom-centre).      */
#extrude-hint {
  position: absolute;
  left: 12px;
  bottom: 58px;
  max-width: 270px;
  padding: 7px 10px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg-pane);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  pointer-events: none;
  user-select: none;
  z-index: 40;
}
#extrude-hint .eh-sub { opacity: 0.75; }

/* ── Worker progress bar ────────────────────────────────────────── */
#worker-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) var(--pct, 0%), transparent var(--pct, 0%));
  z-index: 10000;
  pointer-events: none;
  transition: --pct 0.2s;
  display: none;
}
#worker-progress.active { display: block; }

/* ── Frame Section List Items ───────────────────────────────────── */
.fsec-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  font-size: 11px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  user-select: none;
  color: var(--text);
  transition: background 0.1s;
}
.fsec-item:hover { background: rgba(21,101,192,0.07); }
.fsec-item.selected {
  background: rgba(21,101,192,0.15);
  font-weight: 600;
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: 6px;
}
.fsec-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.15);
}
.fsec-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsec-type {
  font-size: 9px;
  color: var(--text-sec);
  font-style: italic;
  background: rgba(0,0,0,0.05);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Shape Picker Grid ──────────────────────────────────────────── */
.shape-group-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sec);
  margin: 12px 0 5px;
  padding-bottom: 3px;
  border-bottom: 1.5px solid var(--border);
}
.shape-group-title:first-child { margin-top: 0; }
.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
  margin-bottom: 4px;
}
.shape-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 7px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  background: var(--bg-pane, #fff);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  min-height: 68px;
  text-align: center;
}
.shape-tile:hover {
  border-color: var(--accent);
  background: rgba(21,101,192,0.06);
  box-shadow: 0 1px 4px rgba(21,101,192,0.15);
}
.shape-tile.active {
  background: rgba(21,101,192,0.13);
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 1px 6px rgba(21,101,192,0.25);
}
.shape-icon {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.15;
  font-family: 'Arial Black', Arial, sans-serif;
  margin-bottom: 5px;
}
.shape-lbl {
  font-size: 9px;
  color: var(--text-sec);
  line-height: 1.25;
  word-break: break-word;
  text-align: center;
}
.shape-tile.active .shape-lbl { color: var(--accent); font-weight: 600; }
.shape-tile.active .shape-icon { filter: brightness(0.85); }

/* ── Dimension rows in section data dialog ──────────────────────── */
.dim-row          { display: contents; }
.dim-row.hidden   { display: none; }
.dim-row-hidden   { display: none; }

/* ── Command Palette (js/core/command-palette.js) ────────────────
   Ctrl+K search over every ribbon command. Sits above the dialogs
   (z 2000) but below nothing else, and is deliberately a size up from
   the rest of the UI — it is a reading surface, not a dense table. */
#cmdp-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2600;
  background: rgba(0, 0, 0, 0.42);
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
}
#cmdp-overlay.open { display: flex; }

.cmdp-box {
  width: 640px;
  max-width: 100%;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-modal);
  border: 1px solid var(--border-modal);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.cmdp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-tbl);
  background: var(--bg-pane);
}
.cmdp-search-icon { font-size: 17px; color: var(--text-muted); line-height: 1; }
#cmdp-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 2px 0;
  min-width: 0;
}
#cmdp-input::placeholder { color: var(--text-muted); }

.cmdp-list { overflow-y: auto; padding: 4px; flex: 1; }

.cmdp-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}

.cmdp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
}
/* Keyboard and mouse share one highlight: the row under the pointer is the
   row Enter runs, so there is never a second, competing "selected" row. */
.cmdp-item.active { background: var(--bg-tbl-sel); }

.cmdp-icon {
  flex: 0 0 18px;
  text-align: center;
  font-size: 14px;
  color: var(--text-sec);
}
.cmdp-item.active .cmdp-icon { color: inherit; }

.cmdp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cmdp-label { font-size: 13px; line-height: 1.25; }
.cmdp-label mark {
  background: none;
  color: var(--focus-ring);
  font-weight: 700;
}
.cmdp-item.active .cmdp-label mark { color: inherit; text-decoration: underline; }
.cmdp-desc {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmdp-item.active .cmdp-desc { color: var(--text-sec); }

/* Where the command lives in the ribbon — the palette's other job is to
   teach that, so the path is always visible, never on hover. */
.cmdp-path {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.cmdp-item.active .cmdp-path { color: var(--text-sec); }

.cmdp-key {
  flex: 0 0 auto;
  min-width: 18px;
  text-align: center;
  font-size: 10px;
  font-family: inherit;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--bg-panel);
  color: var(--text-sec);
}

.cmdp-empty {
  padding: 26px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.cmdp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  border-top: 1px solid var(--border-tbl);
  background: var(--bg-modal-ft);
  font-size: 10px;
  color: var(--text-muted);
}
.cmdp-legend kbd {
  font-family: inherit;
  font-size: 10px;
  padding: 0 4px;
  margin: 0 1px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-panel);
}

/* Narrow windows: the ribbon path is the first thing worth losing. */
@media (max-width: 560px) {
  #cmdp-overlay { padding-top: 6vh; }
  .cmdp-path { display: none; }
}
