﻿/* ===== BOM Tab ===== */

/* BOM table overrides */
#bom-table th,
#bom-table td {
  padding: 0.45rem 0.5rem;
  font-size: 0.82rem;
}

/* BOM Audit filter dropdowns — cap width instead of auto-sizing to the widest option
   (Model/Kit/Build/Module names can be long) so the filter row stays compact */
#bom-audit-section .filter-row select {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* BOM Audit table — fixed column widths so Model/Kit/Build/Module stay compact and
   Details (the longest content) gets the remaining room instead of everything auto-sizing */
#bom-audit-table {
  table-layout: fixed;
}
#bom-audit-table th:nth-child(1),
#bom-audit-table td:nth-child(1) { width: 3%; }   /* select checkbox */
#bom-audit-table th:nth-child(2),
#bom-audit-table td:nth-child(2) { width: 9%; }   /* Severity */
#bom-audit-table th:nth-child(3),
#bom-audit-table td:nth-child(3) { width: 10%; }  /* Issue */
#bom-audit-table th:nth-child(4),
#bom-audit-table td:nth-child(4) { width: 10%; }  /* Entity */
#bom-audit-table th:nth-child(5),
#bom-audit-table td:nth-child(5) { width: 9%; }   /* Model */
#bom-audit-table th:nth-child(6),
#bom-audit-table td:nth-child(6) { width: 9%; }   /* Kit */
#bom-audit-table th:nth-child(7),
#bom-audit-table td:nth-child(7) { width: 8%; }   /* Revision */
#bom-audit-table th:nth-child(8),
#bom-audit-table td:nth-child(8) { width: 9%; }   /* Build */
#bom-audit-table th:nth-child(9),
#bom-audit-table td:nth-child(9) { width: 9%; }   /* Module */
#bom-audit-table th:nth-child(10),
#bom-audit-table td:nth-child(10) { width: 18%; } /* Details */
#bom-audit-table th:nth-child(11),
#bom-audit-table td:nth-child(11) { width: 6%; }  /* action */

#bom-audit-table td {
  text-align: center;
  overflow-wrap: break-word;
}

/* Model picker spacing */
.model-picker {
  margin-bottom: 2rem;
}

/* Selected row highlight */
.row-selected {
  background: var(--row-selected) !important;
}

/* BOM Audit — critical (high-severity) row highlight, same warning language as a warning chip */
.row-flagged {
  background: var(--danger-bg) !important;
}

/* ── BOM structure tree ──────────────────────────────────────────────────────
   Only what this derivative adds to the workspace archetype in shared.css: the
   tree's twisty and branch rows, and the issue chip. Everything shaped like a
   path bar, rail, row or pane lives there and is shared with Nest Studio.
   ─────────────────────────────────────────────────────────────────────────── */

/* the tree column is all this derivative adds to .workspace */
.bom-workspace { --rail-w: 15rem; --panel-w: 24rem; grid-template-columns: var(--rail-col) minmax(0, 1fr); }
/* the solid panel's columns live in shared.css now, beside the parameter grids that share it */
.bom-pane { overflow-y: auto; padding-right: 0.25rem; }

/* the palette is the mockup's contextual right pane — hold it to a column rather than letting it grow */
.bom-parts-layout .bom-part-palette { flex: 0 0 auto; }

/* the audit's eight filters wrap, so let the row breathe rather than squeezing them onto one line */
#bom-audit-section .filter-row { flex-wrap: wrap; }

/* the archetype already collapses the rail and lets the tab scroll at this width */
@media (max-width: 940px) {
  .bom-pane { overflow-y: visible; }
}

/* Info button next to hierarchy steps — chrome shared with .pkg-cell-pencil / .btn-row-info in shared.css */
.btn-bom-info {
  margin-left: 0.25rem;
}

/* BOM info view modal body */
.bom-info-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bom-info-item {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
}

.bom-info-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 60px;
  flex-shrink: 0;
}

.bom-info-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.bom-info-branch {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  padding-left: 1.25rem;
  margin-left: 0.25rem;
}

.bom-info-branch::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6rem;
  bottom: 0.6rem;
  border-left: 2px solid var(--border);
}

.bom-info-path {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
}

.bom-info-path::before {
  content: '';
  position: absolute;
  left: -1.25rem;
  top: 0.6rem;
  width: 1rem;
  border-top: 2px solid var(--border);
}

.bom-info-path-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 0.15rem;
}

/* Odoo label button */
.btn-odoo-label {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  transition: opacity 0.15s;
}

.btn-odoo-label:hover { opacity: 0.7; }
.odoo-o   { color: #714B67; }
.odoo-doo { color: var(--text-faint); }

/* ─── BOM module labels + hierarchy ──────────────────────────────────────────── */

.bom-module-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.bom-module-desc {
  font-size: 0.825rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
}

/* Parts section two-column layout */
.bom-parts-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.bom-parts-area {
  flex: 1;
  min-width: 0;
}

.bom-part-palette {
  /* wider by default, and its left edge drags it wider still · shared/workspace.js data-resize="self" */
  width: 18rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  /* held in view while the table beside it scrolls · part_palette.js sizes it to the pane, and its list scrolls inside */
  position: sticky;
  top: 0.5rem;
  display: flex;
  flex-direction: column;
}

.bom-palette-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.bom-palette-file-badge {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0 3px;
  line-height: 1.5;
  white-space: nowrap;
}

#bom-parts-area.parts-drop-active {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  border-radius: 4px;
}

/* a file row lights the same way while a palette part is held over it */
#bom-tbody tr.parts-drop-active > td { background: var(--row-selected); box-shadow: inset 0 2px 0 var(--primary), inset 0 -2px 0 var(--primary); }

/* the palette's grip sits on the edge it pulls, the left one */
.bom-part-palette > .workspace-resize { left: 0; }

/* The Files palette · the kit's parts as a tree, Subkit › Component › Segment */
.bom-palette-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.75rem; color: var(--text-faint); }
.bom-palette-tools label { display: flex; align-items: center; gap: 0.25rem; }
.bom-palette-node { display: flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.35rem; font-size: 0.8rem; color: var(--text-sub); border-radius: 3px; }
.bom-palette-node--subkit { font-weight: 600; color: var(--text); }
.bom-palette-node[draggable="true"] { cursor: grab; }
.bom-palette-node[draggable="true"]:hover { background: var(--row-selected); }
.bom-palette-node.dragging { opacity: 0.4; }
.bom-palette-children { padding-left: 0.85rem; }
.bom-palette-twisty { flex: 0 0 0.8rem; background: none; border: 0; padding: 0; color: var(--text-faint); cursor: pointer; font: inherit; }
.bom-palette-unfiled { color: var(--warning); display: inline-flex; align-items: center; gap: 0.15rem; font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.bom-palette-nested,
.bom-palette-placed { color: var(--success); }
.bom-palette-placed.is-off { visibility: hidden; }
.bom-palette-tally { font-size: 0.7rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.bom-palette-tally.is-full { color: var(--success); }
/* the counter on a batch program's part · the quote's qty stepper, shrunk to a palette row */
.bom-palette-qty { display: inline-flex; align-items: center; gap: 0.15rem; margin-left: 0.15rem; }
.bom-palette-qty-btn { width: 1.05rem; height: 1.05rem; border: 1px solid var(--border); border-radius: 3px; background: var(--bg); color: var(--text); font-size: 0.75rem; line-height: 1; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.bom-palette-qty-btn:hover:not(:disabled) { background: var(--row-hover); }
.bom-palette-qty-btn:disabled { opacity: 0.35; cursor: default; }
.bom-palette-qty-val { min-width: 1.4rem; text-align: center; font-size: 0.72rem; font-variant-numeric: tabular-nums; color: var(--text); }

/* Part modal — component subkit row */
.component-subkit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.component-subkit-row select {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
}

.component-subkit-row.hidden { display: none; }

/* Dim label used in component section (subkit row label, new-component header) */
.form-sublabel {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Divider before the new-component creation row */
.new-component-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  margin-bottom: 0.25rem;
}

.new-component-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Inline new-component row (name + subkit + create button) */
.new-component-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.new-component-row input {
  flex: 1;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.new-component-row select {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}

/* ===== BOM Import Briefing ===== */

.import-lede {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 0.75rem;
}

/* Summary tiles — hairline grid, so the row reads as one object rather than six cards */
.import-ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1px;
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 0.9rem;
}

.import-tile {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.5rem 0.7rem;
  background: var(--surface);
}

.import-tile-k {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.import-tile-v {
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.import-tile-n {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.import-tile--danger  { background: var(--danger-bg); }
.import-tile--danger .import-tile-v,
.import-tile--danger .import-tile-k  { color: var(--danger); }
.import-tile--warning { background: var(--warning-bg); }
.import-tile--warning .import-tile-v,
.import-tile--warning .import-tile-k { color: var(--warning); }

/* Per-tab count, matching the tab-bar's own weight */
.import-count {
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--surface-deep);
  color: var(--text-sub);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.import-count.count-danger  { background: var(--badge-danger-bg);  color: var(--danger); }
.import-count.count-warning { background: var(--badge-warning-bg); color: var(--warning); }

/* The review's tabs stay put while a long pane scrolls under them */
.import-review > .tab-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

/* Tabs that open the review fill .modal-body's top padding too, so nothing scrolls by above them */
.import-review > .tab-bar:first-child {
  top: -1.25rem;
  margin-top: -1.25rem;
  padding-top: 1.25rem;
}

.import-pane {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.85rem;
}

/* Banner explaining what a pane is showing */
.import-callout {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-md);
  padding: 0.5rem 0.7rem;
  background: var(--surface-deep);
}

.import-callout strong { display: block; font-size: 0.82rem; }
.import-callout p { margin-top: 0.2rem; font-size: 0.8rem; color: var(--text-sub); }
.import-callout--danger  { border-color: var(--danger-border); background: var(--danger-bg); }
.import-callout--warning { border-color: var(--warning); background: var(--warning-bg); }
.import-callout--muted   { border-color: var(--border); background: var(--surface-deep); }

.import-section {
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.import-section span {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text-faint);
  margin-left: 0.4rem;
}

.import-why { color: var(--text-muted); font-size: 0.78rem; }
.import-none { font-size: 0.82rem; color: var(--text-muted); }

.import-pick { width: 1.6rem; padding-right: 0 !important; }

/* Bulk tick controls above a tickable table, acting only on the rows the filter leaves shown */
.import-pickbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.import-pick-filter { flex: 0 1 14rem; min-width: 8rem; }

/* A group head row and the rows it ticks, indented under it */
.import-group td { background: var(--surface-deep); font-weight: 600; }
.import-member-name { padding-left: 1.6rem !important; }
.import-row-folded { display: none; }
.import-fold { margin-right: 0.3rem; }
.import-assign { min-width: 7rem; }

.import-pick-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* An unticked row stays visible — the reviewer needs to see what they left out */
.import-row-off td { opacity: 0.45; }

.import-options {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border-light);
}

.import-options label {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  font-size: 0.82rem;
  color: var(--text-sub);
}

.import-warnline { color: var(--danger); font-weight: 600; }

/* One field's before/after inside the Updating pane */
.import-change {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  margin: 0.1rem 0.25rem 0.1rem 0;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  background: var(--table-surface);
  font-size: 0.74rem;
  color: var(--text-sub);
}

.import-change-f {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.62rem;
}

/* Tab icons sit at the same size the app's other tab bars use */
#import-briefing .tab-btn .icon-slot { margin-right: 0.3rem; }
#import-briefing .tab-btn svg { width: 13px; height: 13px; vertical-align: -2px; }

/* How the sheet was read, under the panes — plain text, it is diagnostic rather than a control */
.import-read {
  margin-top: 0.7rem;
  font-size: 0.72rem;
  color: var(--text-faint);
}

.import-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }

/* Entities pane — a run of consecutive names shown as the span it was typed as */
.import-entity-group { margin-bottom: 0.9rem; }
.import-runs { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: flex-start; }
.import-run-wrap { display: inline-flex; flex-direction: column; }

.import-run {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.45rem;
  border-radius: 3px;
  border: 1px solid var(--success);
  background: var(--success-bg);
  color: var(--success);
  cursor: pointer;
}

/* A single name is a fact, not a control — no border colour, no pointer */
.import-run.is-single {
  border-color: var(--border);
  background: var(--surface-deep);
  color: var(--text-sub);
  cursor: default;
}

.import-run.is-standard { border-color: var(--primary); background: var(--export-bg); color: var(--primary); }
.import-run-n { opacity: 0.7; margin-left: 0.3rem; }

.import-run-names {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
  padding: 0.4rem 0.5rem;
  border: 1px dashed var(--border);
  border-radius: 3px;
  background: var(--surface-deep);
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  color: var(--text-sub);
}

.import-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.import-options label { flex: 1 1 18rem; }

/* Two readings of one quantity share a cell · side by side, since stacking them set every row's height */
.measured-pair { white-space: nowrap; }
.measured-pair-read {
  margin-left: 0.35rem;
  padding-left: 0.35rem;
  border-left: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.measured-pair-off { color: var(--danger); font-weight: 600; }

/* Kit Odoo link modal · structure only, polish is its own pass */
.odoo-link { display: flex; flex-direction: column; gap: var(--space-3); }
.odoo-link-head, .odoo-link-parts-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.odoo-link-head .btn-rules { margin-left: auto; }
.odoo-link-label { color: var(--text-muted); }
.odoo-link-product { font-weight: 600; }
.odoo-link-parts-head h4 { margin: 0; }
.odoo-link-parts-head .btn-link-matches { margin-left: auto; }
.odoo-link-results { list-style: none; margin: 0; padding: 0; max-height: 14rem; overflow-y: auto; }
.odoo-link-results li, .odoo-link-offer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-1) 0; }
.odoo-link-empty { color: var(--text-muted); }
.odoo-link-depth-1 { padding-left: 1.25rem; }
.odoo-link-depth-2, .odoo-link-depth-3 { padding-left: 2.5rem; }

/* BOM's shared table rows mark their edit and remove actions by name, not data-edit-only */
#tab-bom.is-readonly [data-kit-edit-only],
#tab-bom.is-readonly [data-row-action="edit"],
#tab-bom.is-readonly [data-row-action="remove"],
#tab-bom.is-readonly [data-row-action="addChild"] { display: none; }
