﻿/* ===== Production Tab ===== */

.summary-subheader {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.3rem;
}

/* Boxed Raw/Stacking/Finish sub-section of the Materials summary, laid out side by side — mirrors
   the Excel export's thick outline around each sub-block */
.mat-summary-section {
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
}
.mat-summary-section .summary-subheader {
  margin-bottom: 0.25rem;
}

/* Batch cutting lists: temporary on-hand entry panel — warning-tinted and dashed so it reads as a
   separate, client-side-only surface, distinct from the cutting list's real (DB-backed) data.
   Sits beside the summary tables above the list, sized to its own rows. */
#prod-batch-onhand {
  display: flex;
  flex: none;
  min-height: 0;
  align-self: stretch;
}
.batch-onhand-panel {
  border: 2px dashed var(--warning);
  border-radius: 6px;
  background: var(--warning-bg);
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  width: 100%;
}
.batch-onhand-panel .summary-subheader {
  color: var(--warning);
  flex-shrink: 0;
}
/* Only this inner area scrolls — the header stays put and isn't carried along with it */
.batch-onhand-scroll {
  overflow-y: auto;
  min-height: 0;
}
/* Locked/sticky column header so it stays visible while the part rows scroll beneath it — the
   archetype's own --surface-deep ground is already opaque, so only the pinning is declared here */
.batch-onhand-panel thead th {
  position: sticky;
  top: 0;
  z-index: var(--z-raise-1);
}

/* Kit-name divider row inside a split Materials sub-section table */
.mat-kit-label-row td {
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.2rem 0.4rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* ─── One workspace for the whole tab, a derivative of the .workspace archetype (shared.css) ───
   The rail stands beside every step, so the grid is two columns at the pickers and three once an
   editor puts an inspector up. The inspector holds a file list, a note list and a few fields now
   that the summary tables sit above the cut list, so it asks for much less width than they did. */
.prod-workspace {
  --rail-w: 15rem;  /* BOM's, because it is the same tree carrying the same revision badges */
  --panel-w: 19rem;
  grid-template-columns: var(--rail-col) minmax(0, 1fr);
}
.prod-workspace:has(> .workspace-panel:not(.hidden)) {
  grid-template-columns: var(--rail-col) minmax(0, 1fr) var(--panel-col);
}
/* Planning runs its own full-width grid, so the rail steps out and the pane takes the row */
.prod-workspace:has(> .workspace-rail.hidden) { grid-template-columns: minmax(0, 1fr); }

/* The pane scrolls as one column, exactly as BOM's does (.bom-pane) — a picker section is as tall
   as its rows, so a three-row variant list is a three-row box rather than a full-height frame with
   a field of nothing underneath it. */
.prod-pane { overflow-y: auto; padding-right: 0.25rem; }
.prod-pane-section > .table-scroll { margin-bottom: 0; }  /* .table-scroll's 2rem was for a page that scrolled past it */

/* What the cut list adds up to, above the list itself · the summary tables are up to four columns
   wide, which is why they sit across the pane rather than in the inspector. The batch on-hand panel
   sits beside them and keeps its own width. */
.prod-summaries-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.prod-summaries-row > #prod-summaries { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.75rem; }
/* each run of sub-sections lays out across and wraps, rather than scrolling sideways out of reach */
.prod-summary-group { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-start; }

/* Palette search + Add All, above the rail's scrolling list */
.prod-palette-header {
  display: flex;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  flex: none;
  align-items: center;
}
.prod-palette-header .pkg-palette-search { flex: 1; min-width: 0; margin: 0; }
.prod-palette-item {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-light);
  margin-bottom: 0.25rem;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.prod-palette-item:hover { background: var(--row-selected); border-color: var(--border); }
.prod-palette-item.dragging { opacity: 0.4; }
.prod-palette-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-palette-item.in-sheet { border-color: var(--primary); }
.prod-palette-in-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid var(--primary);
  border-radius: 3px;
  padding: 0 0.25rem;
  line-height: 1.4;
}
#prod-cutting-tbody.cutting-drop-active {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}
.prod-cutting-drop-indicator {
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  margin: 1px 0;
  pointer-events: none;
}
tr.row-selected > td {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
tr.row-selected.dragging { opacity: 0.45; }

/* Sheet type picker — moved to shared.css as .card/.card-grid, used across
   Production/Engineering/Design/Quality/Quote/System, not Production-specific */

/* The "add a note" composer, in the inspector under whichever note list it feeds · it wraps rather
   than running off the panel's 21-24rem, and its button sits on its own line once it does */
.prod-add-note {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-light);
}

.prod-add-note input[type="text"],
.prod-add-note select {
  flex: 1 1 100%;
  min-width: 0;
  padding: 0.35rem 0.5rem;
}
.prod-add-note input[type="text"] { background: var(--bg); }
.prod-add-note input[type="text"]:focus { outline: none; border-color: var(--primary); }

/* Note rows */
.note-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  margin-bottom: 0.3rem;
  background: var(--surface);
}

.note-row.note-special {
  background: var(--warning-bg);
}


.btn-remove-note {
  margin-left: auto;
}

/* Prevent cell text wrapping in the cutting table; container already scrolls horizontally */
#prod-cutting-table th,
#prod-cutting-table td {
  white-space: nowrap;
}

/* Cut order input inside table */
.cut-order-input {
  width: 60px;
  background: var(--bg);
  text-align: center;
}
.cut-order-input:focus { outline: none; border-color: var(--primary); }
.cut-order-input::-webkit-inner-spin-button {
  opacity: 0.6;
  filter: invert(var(--spinner-invert, 0));
}
.cut-order-input::-webkit-outer-spin-button { opacity: 0; }

.cut-qty-input {
  width: 60px;
  background: var(--bg);
  text-align: center;
}
.cut-qty-input:focus { outline: none; border-color: var(--primary); }
.cut-qty-input::-webkit-inner-spin-button { opacity: 0.6; filter: invert(var(--spinner-invert, 0)); }
.cut-qty-input::-webkit-outer-spin-button { opacity: 0; }

.cut-file-num-cell { vertical-align: middle; }
.cut-qty-reset {
  padding: 0 2px;
}
.save-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  margin-left: 3px;
  vertical-align: middle;
}
.save-ratio-input {
  width: 46px;
  font-size: 0.75rem;
  text-align: center;
  background: var(--bg);
}
.save-ratio-input:focus { outline: none; border-color: var(--primary); }
.save-ratio-input::-webkit-inner-spin-button,
.save-ratio-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Left/Right Part-table split in the cutting editor — mirrors the Excel export's grouped Part N
   columns, with a thick divider between the Right and Left sections */
.cutting-part-group-header {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-faint);
}
.cutting-part-group-neither {
  color: var(--warning);
  background: var(--warning-bg) !important;
}
.cutting-part-divider {
  border-left: 2px solid var(--border) !important;
}

.cut-split-row td { background: var(--split-row-bg); border-color: var(--split-row-border); }
.cut-split-label {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 6px 0;
}
.cut-split-material {
  font-size: 0.8rem;
  max-width: 160px;
  white-space: nowrap;
}
.cut-split-material select { font-size: 0.8rem; max-width: 100%; }
.split-consumable-tag {
  font-size: 0.68rem;
  color: var(--text-faint);
  margin-left: 3px;
  cursor: help;
  vertical-align: middle;
}
.split-warning-tag {
  font-size: 0.75rem;
  color: var(--warning);
  cursor: help;
  vertical-align: middle;
}
.flip-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--on-primary);
  background: var(--accent);
  border-radius: 3px;
  padding: 1px 6px;
  line-height: 1.3;
}
.pseudo-mat-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--on-primary);
  background: var(--warning);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 3px;
  cursor: help;
  vertical-align: middle;
}

/* Run-order badge — shown next to Cut Order in the module job read-only cut list;
   one badge per time the file was actually run, in chronological order */
.run-order-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 3px;
  margin-left: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  vertical-align: middle;
}

/* ===== Packaging Map Grid ===== */

/* The grid table itself */
.pkg-map-table {
  border-collapse: collapse;
  min-width: 600px;
}

.pkg-map-table th,
.pkg-map-table td {
  vertical-align: top;
  white-space: nowrap;
}

.pkg-th-box   { min-width: 140px; }
.pkg-th-layer { width: 52px; text-align: center; }
.pkg-th-part  { min-width: 110px; }

/* Box cell spanning all layer rows */
.pkg-box-cell {
  background: var(--surface);
  padding: 0.5rem 0.6rem !important;
  border-right: 2px solid var(--border) !important;
  vertical-align: middle !important;
}

.pkg-box-name {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.2rem;
}

.pkg-box-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

/* Layer +/- controls inside box cell */
.pkg-layer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.pkg-add-layer,
.pkg-rem-layer {
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pkg-add-layer:hover { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.pkg-rem-layer:hover { background: var(--danger); color: var(--on-primary); border-color: var(--danger); }

.pkg-layer-label {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.15rem;
}

.pkg-layer-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 1.2rem;
  text-align: center;
}

/* Layer number cell */
.pkg-layer-cell {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  width: 52px;
  vertical-align: middle !important;
}

/* Separator between boxes */
.pkg-layer-row.pkg-first-layer td,
.pkg-layer-row.pkg-first-layer th {
  border-top: 2px solid var(--border) !important;
}

/* Part cells */
.pkg-part-cell {
  position: relative;
  min-width: 110px;
  padding: 0.3rem 0.4rem !important;
  vertical-align: top;
}

.pkg-cell-filled {
  background: var(--surface);
  vertical-align: middle;
  min-height: 38px;
}

.pkg-slot-empty {
  background: var(--surface);
  min-height: 38px;
  transition: background 0.1s;
}

.pkg-slot-empty.pkg-drop-active {
  background: var(--row-selected);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

/* Absolute slot number, top-left of every part cell — column headers just say "Part" since a
   wrapped row's column position no longer maps to one fixed part number (see _renderPackingGrid) */
.pkg-cell-slot {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.62rem;
  color: var(--text-faint);
  line-height: 1;
}

/* Pencil icon — top-left of filled cell. Chrome shared with .btn-bom-info / .btn-row-info in shared.css */
.pkg-cell-pencil {
  position: absolute;
  top: 3px;
  right: 15px;
  font-size: 0.7rem;
  padding: 1px 3px;
  opacity: 0;
  transition: opacity 0.5s, color 0.15s, background 0.15s;
}

/* Part name inside filled cell — centered both ways in the cell (marker/pencil/delete are all
   absolutely positioned, so they don't compete with this for space) */
.pkg-cell-name {
  display: block;
  font-size: 0.82rem;
  padding: 0 0.3rem;
  font-weight: 500;
  text-align: center;
}

/* Note text anchor — holds nothing in the closed state (see .pkg-note-marker) and the inline
   textarea editor while open */
.pkg-cell-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: normal;
  word-break: break-word;
}

.pkg-note-empty { min-height: 0; }

/* Footnote-style marker replacing full note text inline — right edge, vertically centered, clear
   of the top-left slot number (.pkg-cell-slot) and the top-right pencil/delete hover icons.
   Colored (not faint gray) so a noted part is easy to spot at a glance */
.pkg-note-marker {
  position: absolute;
  top: 50%;
  right: 3px;
  transform: translateY(-50%);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--primary);
  cursor: default;
}

/* Not-applicable filler cell — the side of the split table a given box's row doesn't use */
.pkg-cell-na {
  background: var(--surface);
  opacity: 0.4;
}

/* Left/Right group header row above the Part-N column headers — same convention as the cutting
   editor's .cutting-part-group-header/.cutting-part-divider */
.pkg-th-group {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-faint);
}
.pkg-th-group-divider {
  border-left: 2px solid var(--border) !important;
}

/* Same divider carried down through the Part-N sub-header and every data row's first Right-side
   cell, not just the group header — same color/weight as the cutting editor's own
   .cutting-part-divider, so both split tables use one consistent convention */
.pkg-th-part-divider,
.pkg-part-cell.pkg-side-divider {
  border-left: 2px solid var(--border) !important;
}

/* Note Key legend · now a section of the packing inspector, beside the Box Notes it explains.
   No fixed height — the panel body scrolls, so this just sizes to however many rows exist. */
.pkg-note-key {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.pkg-note-key .note-row {
  cursor: grab;
}

.pkg-note-key-num {
  font-weight: 700;
  color: var(--primary);
  margin-right: 0.2rem;
  min-width: 1.1rem;
  display: inline-block;
}

.pkg-note-key-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.pkg-note-key-edit {
  font-size: 0.75rem;
  padding: 1px 5px;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
}
.pkg-note-key-edit:hover { color: var(--primary); }

.pkg-note-key-editor-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Remove-slot button — top-right of filled cell */
.pkg-del-slot {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.65rem;
  padding: 1px 3px;
  opacity: 0;
  transition: opacity 0.5s;
}

.pkg-part-cell:hover .pkg-del-slot { opacity: 1; }
.pkg-part-cell:hover .pkg-cell-pencil { opacity: 1; }


/* Inline note editor */
.pkg-note-editor {
  width: 100%;
  font-size: 0.78rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  resize: none;
  box-sizing: border-box;
}

.pkg-note-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.pkg-note-actions button {
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
}

/* Drag handle for box rows */
.pkg-box-drag {
  vertical-align: middle !important;
  cursor: grab;
}

.pkg-box-drag.dragging { opacity: 0.35; }

/* Delete-box button cell spans every layer row — same rowspan alignment quirk as .pkg-box-drag above */
#prod-packing-table .col-action { vertical-align: middle !important; }

/* Insertion-strip indicators on filled cells — inset shadow, no layout shift */
.pkg-cell-filled.pkg-insert-left  { box-shadow: inset 3px 0 0 var(--primary); }
.pkg-cell-filled.pkg-insert-right { box-shadow: inset -3px 0 0 var(--primary); }

/* Create-box strip, pinned under the scrolling grid rather than after it */
.pkg-create-box-strip {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex: none;
  padding: 0.5rem 0.6rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 6px;
}
.pkg-box-number-input { width: 60px; text-align: center; }

.pkg-strip-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.pkg-create-box-strip input {
  flex: 1;
  min-width: 0;
  max-width: 160px;
  padding: 0.3rem 0.45rem;
  background: var(--bg);
  font-size: 0.85rem;
}

/* The scrolling list inside a drag-source palette · BOM's parts palette wears these too, so they
   stay a base pair rather than becoming something only these two editors have. */
.pkg-palette-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0.25rem 0.4rem 0.4rem;
}
.pkg-palette-search {
  margin: 0.4rem 0.5rem 0.25rem;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  background: var(--surface);
}

/* Both palettes are a tab of the inspector now — you drag leftward out of the panel into the table,
   which is the direction they always ran. The panel body is already a scrolling column, so the
   palette only has to say which of its parts stretches: the list does, nothing else. */
.prod-palette-pane { padding: 0; gap: 0; }
.prod-palette-source { flex: none; }
.prod-palette-source .tab-btn { flex: 1; justify-content: center; padding: 0.3rem 0.25rem; font-size: 0.7rem; }

.pkg-palette-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.45rem;
  margin-bottom: 0.25rem;
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pkg-palette-item:hover     { border-color: var(--primary); background: var(--row-hover); }
.pkg-palette-item.dragging  { opacity: 0.5; cursor: grabbing; }
/* Already-placed indicator — reuses .prod-palette-in-badge/-item-label, same convention as the
   module sheets file palette's in-sheet count badge */
.pkg-palette-item.in-sheet  { border-color: var(--primary); }

/* Lightweight ghost element used as the drag image for palette chips and grid cells */
.pkg-drag-ghost {
  position: fixed;
  top: -1000px;
  left: -1000px;
  background: var(--primary);
  color: var(--on-primary);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
}

/* ─── Planning worker grid ────────────────────────────────────────────────────────────────────
   Planning is a section of the Production panel, not a workspace: it scrolls as ordinary page
   content beside a sticky palette. It used to wear the packaging editor's .pkg-grid-wrap /
   .pkg-table-area / .pkg-palette, which meant moving that editor into a workspace silently moved
   Planning too. These are the same rules, under its own names. */
.planning-grid-wrap {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-top: 0.75rem;
}
.planning-table-area { flex: 1; min-width: 0; }

.planning-palette {
  width: 180px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  position: sticky;
  top: 0.25rem;  /* sticky to .prod-scroll-section, which is what scrolls now — not to the viewport */
  max-height: calc(100vh - var(--navbar-h) - 4rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.planning-palette-search {
  margin: 0.4rem 0.5rem 0.25rem;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  background: var(--surface);
}
.planning-palette-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem 0.4rem 0.4rem;
}

/* Chips + rotation-driven off-duty columns */
.planning-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  margin: 0.1rem;
  font-size: 0.8rem;
  cursor: grab;
}
.planning-chip.dragging { opacity: 0.4; }
.planning-chip-remove {
  border: none;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0;
}
.planning-cell { min-width: 110px; vertical-align: top; }
.planning-shift-inactive { color: var(--text-faint); }
.planning-cell-inactive {
  background: color-mix(in srgb, var(--text-faint) 8%, transparent);
  opacity: 0.55;
}

