/* Collabris — Professional Engineering UI */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Custom Theme ─────────────────────────────────────────── */
[data-theme="collabris"] {
  color-scheme: light;
  --p: 0.58 0.065 230;
  --pc: 0.985 0.003 230;
  --s: 0.52 0.04 235;
  --sc: 0.985 0.003 235;
  --a: 0.646 0.145 145;
  --ac: 0.985 0.003 145;
  --n: 0.28 0.035 245;
  --nf: 0.23 0.035 245;
  --nc: 0.985 0.003 245;
  --b1: 0.985 0.003 240;
  --b2: 0.965 0.005 240;
  --b3: 0.935 0.008 240;
  --bc: 0.18 0.025 245;
  --su: 0.586 0.158 145;
  --suc: 0.985 0.003 145;
  --wa: 0.666 0.148 55;
  --wac: 0.15 0.03 55;
  --er: 0.546 0.215 27;
  --erc: 0.985 0.003 27;
  --in: 0.58 0.065 230;
  --inc: 0.985 0.003 230;
  --rounded-box: 0.5rem;
  --rounded-btn: 0.375rem;
  --rounded-badge: 9999px;
  --animation-btn: 0.15s;
  --animation-input: 0.15s;
  --btn-focus-scale: 0.99;
  --border-btn: 1px;
  --tab-border: 1px;
  --tab-radius: 0.375rem;
}

/* ── Typography ───────────────────────────────────────────── */
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
}

code, pre, .font-mono {
  font-family: 'IBM Plex Mono', monospace;
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar-custom {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #2c3a54;
  border-bottom: 1px solid #232f43;
}

.navbar-brand {
  display: flex;
  align-items: center;
}

.navbar-logo {
  height: 2rem;
  width: auto;
}

.navbar-tagline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #8fb5d1;
}

.navbar-tagline a {
  color: #8fb5d1;
}

.navbar-tagline a:hover {
  color: #c5d8e8;
}

/* ── Project Header ──────────────────────────────────────── */
.project-header {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border-bottom: 1px solid #e2e8f0;
  padding: 1.25rem 0 1rem;
}

.project-header-title {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1e293b;
  letter-spacing: -0.01em;
  margin: 0;
}

/* ── Standard Selector (safety) ──────────────────────────── */
.standard-selector-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.625rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #e2e8f0;
  font-size: 0.75rem;
}

.standard-selector-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
}

.standard-selector-input {
  min-width: 14rem;
}

/* ── Pipeline ─────────────────────────────────────────────── */
.pipeline-nav {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 0 0.75rem;
  max-width: 60rem;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ── Top Row: 6 Stages ───────────────────────────────────── */
.pipeline-stages {
  display: flex;
  align-items: flex-start;
  flex: 1;
}

.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #cbd5e1;
  transition: color 0.15s;
  flex: 1;
  min-width: 0;
}

.pipeline-stage:hover { color: #475569; }
.pipeline-stage.has-partial { color: #4a7a9b; }
.pipeline-stage.has-complete { color: #4a7a9b; }
.pipeline-stage.active { color: #1e293b; }

.stage-num {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  background: #f8fafc;
  color: #cbd5e1;
  transition: all 0.15s;
}

.pipeline-stage:hover .stage-num {
  border-color: #94a3b8;
}

.pipeline-stage.has-partial .stage-num {
  border-color: #93b5cc;
  background: #e6f1f8;
  color: #2f5f80;
  box-shadow: 0 1px 2px rgba(74, 122, 155, 0.12);
}

.pipeline-stage.has-complete .stage-num {
  border-color: #4a7a9b;
  background: #4a7a9b;
  color: #fff;
  box-shadow: 0 1px 2px rgba(74, 122, 155, 0.25);
}

.pipeline-stage.active .stage-num {
  border-color: #2c3a54;
  background: #2c3a54;
  color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2c3a54;
}

/* ── Stale: paired with the `may need to regenerate` warning banner. ──
   An upstream stage was regenerated, so this bubble's content is out of
   sync. Stale composes with has-complete (keep the blue fill so the user
   still sees "this stage has data") by switching only the ring + label
   tint to warning amber. On the active bubble, the active ring wins —
   the banner on that page already carries the same signal.            */
.pipeline-stage.stale { color: #d97706; }
.pipeline-stage.stale .stage-num {
  border-color: #d97706;
  background: #fffbeb;
  color: #d97706;
}
.pipeline-stage.stale.has-complete .stage-num {
  border-color: #d97706;
  background: #4a7a9b;
  color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #d97706;
}
.pipeline-stage.active.stale { color: #1e293b; }
.pipeline-stage.active.stale .stage-num {
  border-color: #2c3a54;
  background: #2c3a54;
  color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2c3a54;
}

.stage-label {
  margin-top: 0.375rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.15;
  max-width: 7rem;
}

.stage-line {
  height: 2px;
  flex: 1;
  background: #e2e8f0;
  margin-top: 1rem;
  min-width: 1rem;
}

.stage-line.complete { background: #4a7a9b; }

/* ── Sub-step Track (second row) ─────────────────────────── */
.substep-track {
  display: flex;
  align-items: flex-start;
  margin-top: 0.75rem;
  padding-top: 0.625rem;
  border-top: 1px solid #f1f5f9;
}

.substep-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #cbd5e1;
  transition: color 0.15s;
  flex: 1;
  min-width: 0;
}

.substep-node:hover { color: #475569; }
.substep-node.partial { color: #4a7a9b; }
.substep-node.complete { color: #4a7a9b; }
.substep-node.active { color: #1e293b; }

.substep-dot {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.5rem;
  font-weight: 500;
  background: #f8fafc;
  color: #cbd5e1;
  transition: all 0.15s;
}

.substep-node:hover .substep-dot {
  border-color: #94a3b8;
}

.substep-node.partial .substep-dot {
  border-color: #93b5cc;
  background: #e6f1f8;
  color: #2f5f80;
  box-shadow: 0 1px 2px rgba(74, 122, 155, 0.12);
}

.substep-node.complete .substep-dot {
  border-color: #4a7a9b;
  background: #4a7a9b;
  color: #fff;
  box-shadow: 0 1px 2px rgba(74, 122, 155, 0.25);
}

.substep-node.active .substep-dot {
  border-color: #2c3a54;
  background: #2c3a54;
  color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2c3a54;
}

/* Stale substeps mirror the top-row rules; see the `.pipeline-stage.stale`
   block above for the composition rationale.                           */
.substep-node.stale { color: #d97706; }
.substep-node.stale .substep-dot {
  border-color: #d97706;
  background: #fffbeb;
  color: #d97706;
}
.substep-node.complete.stale .substep-dot {
  border-color: #d97706;
  background: #4a7a9b;
  color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #d97706;
}
.substep-node.active.stale { color: #1e293b; }
.substep-node.active.stale .substep-dot {
  border-color: #2c3a54;
  background: #2c3a54;
  color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2c3a54;
}

.substep-label {
  margin-top: 0.25rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.5rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.15;
  max-width: 5rem;
}

.substep-line {
  height: 2px;
  flex: 1;
  background: #e2e8f0;
  margin-top: calc(1.5rem / 2);
  min-width: 0.5rem;
}

.substep-line.complete { background: #4a7a9b; }

.plant-model-nested-track {
  padding-top: 0.75rem;
  border-top: 1px dashed #bbf7d0;
}

.plant-step-node {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.plant-step-node .substep-label {
  max-width: 7rem;
}

/* ── Optional Sub-steps ──────────────────────────────────── */
.substep-node.optional .substep-dot {
  border-style: dashed;
}

.substep-node.optional .substep-label::after {
  content: " (opt)";
  font-size: 0.85em;
  opacity: 0.6;
}

.substep-node.optional.complete .substep-dot {
  border-style: solid;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header h1 {
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.page-header p {
  color: #64748b;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
}

/* ── Chapter Cards ────────────────────────────────────────── */
.chapter-card {
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.chapter-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 1px 6px 0 rgb(0 0 0 / 0.06);
}

.chapter-card.complete {
  border-left: 3px solid #4a7a9b;
}

.chapter-num {
  position: absolute;
  top: -0.5rem;
  right: 0.5rem;
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  color: #f1f5f9;
  pointer-events: none;
  user-select: none;
}

.chapter-card.complete .chapter-num {
  color: #c5d8e8;
}

.chapter-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  flex-shrink: 0;
}

.chapter-card.complete .chapter-icon {
  background: #c5d8e8;
}

.chapter-icon svg {
  width: 1rem;
  height: 1rem;
  color: #64748b;
}

.chapter-card.complete .chapter-icon svg {
  color: #4a7a9b;
}

/* ── Status Labels ────────────────────────────────────────── */
.status-complete {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #16a34a;
}

.status-pending {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #94a3b8;
}

/* ── Tables ───────────────────────────────────────────────── */
[data-table-scroll-bottom],
.overflow-x-auto:has(> .table) {
  max-height: 70vh;
  overflow: auto;
}

.table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748b;
  background: #f1f5f9;
  background-clip: padding-box;
  box-shadow: inset 0 -1px 0 rgba(100, 116, 139, 0.22), 0 1px 2px rgba(15, 23, 42, 0.08);
}

.table tbody td {
  font-size: 0.85rem;
}

/* ── Form Labels ──────────────────────────────────────────── */
.label-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #475569;
}

/* ── Semantic Badges ──────────────────────────────────────── */
.badge-hw {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.badge-signal {
  background: #eff6ff;
  color: #3d6d94;
  border: 1px solid #bfdbfe;
}

.badge-sw {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* ── Token Badge ──────────────────────────────────────────── */
.token-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  color: #64748b;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  border-style: dashed;
  border-color: #cbd5e1;
  background: #f8fafc;
}

/* ── Danger Zone ──────────────────────────────────────────── */
.danger-zone {
  border-color: #fecaca;
}

/* ── Issue Cards ──────────────────────────────────────────── */
.issue-card {
  border: 1px solid #e2e8f0;
}

/* ── Dividers ─────────────────────────────────────────────── */
.divider {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}

/* ── Stats ────────────────────────────────────────────────── */
.stat-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  font-weight: 600;
}

/* ── Safety Analysis Badges ───────────────────────────────── */
.badge-rpn-high   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.badge-rpn-medium { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.badge-rpn-low    { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.badge-risk-high   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.badge-risk-medium { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.badge-risk-low    { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

.badge-cat-detection     { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.badge-cat-redundancy    { background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }
.badge-cat-failsafe      { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.badge-cat-degradation   { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }

.badge-test-virtual  { background: #eff6ff; color: #3d6d94; border: 1px solid #bfdbfe; }
.badge-test-realhw   { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }

.badge-partition-hw { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-partition-sw { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }

tr.rpn-high   { border-left: 3px solid #dc2626; }
tr.rpn-medium { border-left: 3px solid #d97706; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #f1f5f9; }
th.sort-asc::after  { content: " ▲"; font-size: 0.7em; }
th.sort-desc::after { content: " ▼"; font-size: 0.7em; }

.safety-table-search {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  outline: none;
  width: 200px;
}
.safety-table-search:focus { border-color: #94a3b8; }

.safety-row-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

/* ── Safety Detail Rows ──────────────────────────────────── */
.safety-table-container tbody tr:not(.safety-detail-row) {
  cursor: pointer;
  transition: background 0.1s;
}

.safety-table-container tbody tr:not(.safety-detail-row):hover {
  background: #e2e8f0;
}

.safety-lifecycle-action.btn-outline:hover,
.safety-lifecycle-action.btn-outline:focus-visible {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.safety-detail-row td.safety-detail-cell {
  background: #e0ecf5;
  border-left: 3px solid #4a7a9b;
  padding: 0.75rem 1rem;
  white-space: normal;
  word-break: break-word;
}

.safety-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.safety-detail-grid p {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: #1e293b;
  line-height: 1.4;
}

.safety-detail-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .stage-label { font-size: 0.5rem; }
  .stage-num { width: 1.75rem; height: 1.75rem; font-size: 0.6rem; }
  .stage-line { margin-top: calc(1.75rem / 2); }
  .substep-label { font-size: 0.45rem; }
  .substep-dot { width: 1.25rem; height: 1.25rem; font-size: 0.45rem; }
  .substep-line { margin-top: calc(1.25rem / 2); }
}
