/* Engineering Change detail panel — the stage rail itself is wizard.css's .stepper-nav; this file
   holds the header block, the collapsible Change Details strip, and the per-stage body wrapper. */

/* ─── Index workspace ────────────────────────────────────────────────────────────
   The three index sections wear the workspace archetype (shared.css): Stages beside
   the changes table, and a bare pane for the two configuration lists, which have
   nothing to filter. One open change isn't a workspace at all — changes.js takes
   `is-workspace` off the tab, so the detail panel keeps the centred column it had.
   ────────────────────────────────────────────────────────────────────────────── */

.eng-workspace { --rail-w: 12rem; grid-template-columns: var(--rail-col) minmax(0, 1fr); }
.eng-workspace--norail { grid-template-columns: minmax(0, 1fr); }

/* each section fills the tab's flex column, the same way Tasks' two boards do */
#eng-changes:not(.hidden),
#eng-task-templates:not(.hidden),
#design-parameters:not(.hidden),
.eng-full-section:not(.hidden) { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Nest Studio, NC Deploy and the Design Specification carry their own path bar — scope selects and
   actions the tab-level one has nowhere to put — so theirs stands in for Engineering's rather than under it */
#tab-engineering:has(> .eng-full-section:not(.hidden)) > .pathbar { display: none; }

/* the pane scrolls as a whole, as .bom-pane and .documents-pane do */
#tab-engineering .workspace-pane,
#tab-changes .workspace-pane { overflow-y: auto; padding-right: 0.25rem; }

/* For You · a change waiting on you carries a warning rule on its left edge, the way a flagged row does, and its badges ride beside its name */
.data-table tbody tr.is-for-you td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
/* The draft tree borrows the rail's rows, so in a pane it only needs a frame and a ceiling */
.eng-draft-tree { flex: none; max-height: 28rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
/* An ask's marker in the tree · the icon of what it asks, dashed, a click finds its row in the Asks table */
.eng-draft-tree .chip.is-asked { border-style: dashed; cursor: pointer; }
.eng-ask-actions { text-align: right; white-space: nowrap; }
.eng-ask-item { color: inherit; font-weight: 600; text-decoration: none; }
.eng-ask-item:hover { text-decoration: underline; }
/* A marker and its row point at each other with a brief flash */
@keyframes eng-flash { from { background: var(--row-selected); } to { background: transparent; } }
.is-flashed { animation: eng-flash 1.4s ease-out; }
.for-you-badges { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; margin-left: 0.4rem; vertical-align: 1px; }

/* one open change is a document, so it keeps the centred column — but owns it here now that the
   tab shell is full-bleed like every other, the same way .card-habitat owns a chooser's column */
#eng-change-detail:not(.hidden) { width: 100%; max-width: var(--tab-width); margin: 0 auto; }


/* ─── Header ─────────────────────────────────────────────────────────────────── */

/* no back button of its own any more: the path bar's crumb is the way out */
.eng-hdr { padding: 1rem 1.25rem 1.1rem; }

.eng-hdr-top { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.eng-hdr-top h2 { font-size: 1.2rem; font-weight: 650; letter-spacing: -0.01em; }
.eng-hdr-actions { margin-left: auto; display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }

/* Derived facts, not editable fields — the model comes from the linked kits, it isn't stored on the change */
.eng-hdr-meta { display: flex; gap: 0.35rem 1rem; flex-wrap: wrap; margin-top: 0.6rem; font-size: 0.78rem; color: var(--text-muted); }
.eng-hdr-meta b { color: var(--text-sub); font-weight: 600; }
.eng-hdr-meta .eng-meta-sep { color: var(--text-faint); }

/* ─── Change Details — change-level fields, collapsed to a one-line summary until needed. Lives
     outside the stage rail because these describe the change, not any one stage of it. ───────── */

.eng-details { border-top: 1px solid var(--border-light); background: var(--table-surface); }

.eng-details-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 1.25rem; cursor: pointer; }
.eng-details-head:hover { background: var(--row-hover); }

.eng-details-caret { color: var(--text-faint); font-size: 0.75rem; transition: transform 0.15s; }
.eng-details.is-open .eng-details-caret { transform: rotate(90deg); }

.eng-details-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Stands in for the fields while collapsed — hidden once they're actually on screen */
.eng-details-summary { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; }
.eng-details.is-open .eng-details-summary { display: none; }

.eng-details-body { display: none; padding: 0.25rem 1.25rem 1.05rem; }
.eng-details.is-open .eng-details-body { display: block; }

.eng-dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 1.5rem; }
/* read-only packs four to a row with tighter gaps, since values are short badges · editing keeps two for its inputs */
.eng-dgrid.is-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.45rem 1.25rem; }
.eng-dgrid.is-compact .eng-dfield-value { min-height: 0; padding: 0.1rem 0; }
@media (max-width: 700px) { .eng-dgrid.is-compact { grid-template-columns: 1fr 1fr; } }

/* One field, rendered once — .eng-dfield-value and an input are the same slot in two states, never
   two parallel copies of the form (which is how fields drifted between the old view/edit blocks) */
.eng-dfield label {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 0.2rem;
}
/* pre-wrap so a multi-line description reads as typed, harmless for the single-line fields */
.eng-dfield-value { font-size: 0.86rem; color: var(--text-sub); min-height: 1.6rem; padding: 0.2rem 0; white-space: pre-wrap; }
.eng-dfield input[type="text"],
.eng-dfield input[type="date"],
.eng-dfield input[type="number"],
.eng-dfield textarea,
.eng-dfield select {
  width: 100%;
  padding: 0.36rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
/* Vertical-only resize — a horizontal drag would break out of the grid column */
.eng-dfield textarea { min-height: 4.5rem; resize: vertical; line-height: 1.45; }
.eng-dfield input[type="text"]:focus,
.eng-dfield input[type="date"]:focus,
.eng-dfield input[type="number"]:focus,
.eng-dfield textarea:focus,
.eng-dfield select:focus { outline: none; border-color: var(--primary); }
.eng-dfield-wide { grid-column: 1 / -1; }

/* Dependency count beside a task name, tooltipped with what it waits on */
.eng-dep-cue {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.35rem;
  padding: 0 0.3rem;
  border-radius: 3px;
  background: var(--surface-deep);
  color: var(--text-faint);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  cursor: help;
}

.eng-dept-checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; padding-top: 0.15rem; }
.eng-dept-checks label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-sub);
  cursor: pointer;
  /* reset the uppercase field-label treatment inherited from .eng-dfield label */
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin: 0;
}

/* Save sits with the fields it writes, not in a page-global row below the kit facets */
.eng-details-foot { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; margin-top: 0.9rem; }

/* ─── Stage body ─────────────────────────────────────────────────────────────── */

.eng-stage-body { padding: 1.1rem 1.25rem 1.25rem; }

/* Only Order has more than one pane, so it's the only stage that renders a subtab bar */

/* Advance/regress travel together as one control group, shown only while checked in */
#eng-stage-nav { display: flex; gap: 0.45rem; align-items: center; }

@media (max-width: 768px) {
  .eng-dgrid { grid-template-columns: 1fr; }
  .eng-hdr, .eng-details-head, .eng-details-body, .eng-stage-body { padding-left: 1rem; padding-right: 1rem; }
  .eng-hdr-actions { margin-left: 0; width: 100%; }
}

/* ─── EC task list sections — tr.is-group derivative, interactive where the archetype is a
   static label. Alignment comes from the archetype now, so only the casing differs ─── */
.data-table tbody tr.eng-task-list-row td { text-transform: none; letter-spacing: normal; }
.eng-task-list-head { display: flex; align-items: center; gap: 0.45rem; }
/* the group band is a light ground now, so the count takes a light-ground muted tone */
.eng-task-list-head .list-count { color: var(--text-faint); }
.eng-task-list-actions { margin-left: auto; display: flex; align-items: center; gap: 0.1rem; }

/* a task ruled not applicable is still on the list, just not work · dimmed rather than struck through, which would read as done */
.data-table tbody tr.is-na td { opacity: 0.55; }
.data-table tbody tr.is-na td:last-child { opacity: 1; }

/* ─── Task template editor — one .tpl-list block per list, each holding its own .tpl-item-row set ─── */
.tpl-list { border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 0.6rem; }
.tpl-list-head {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.4rem 0.5rem; background: var(--surface-deep);
  border-bottom: 1px solid var(--border); border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.tpl-list-label { font-weight: 650; font-size: 0.82rem; }
.tpl-list-head .tpl-list-name { flex: 1; min-width: 0; }
.tpl-list-head .tpl-list-group { width: 160px; }
.tpl-list-items { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.5rem; }
.tpl-item-row { display: flex; align-items: center; gap: 0.5rem; }
.tpl-item-row .tpl-item-name { flex: 1; min-width: 0; }
.tpl-item-row .tpl-item-department { width: 160px; }
.tpl-add-task { margin: 0 0.5rem 0.5rem; }

@media (max-width: 768px) {
  .tpl-list-head, .tpl-item-row { flex-wrap: wrap; }
  .tpl-list-head .tpl-list-group, .tpl-item-row .tpl-item-department { width: 100%; }
}
