/* ==========================================================================
   turnstone console — page-specific styles
   Extends shared base.css with console-only layout and components
   ========================================================================== */

/* ==========================================================================
   Header overrides — wider padding for console layout
   ========================================================================== */
#header { padding: 10px 20px; gap: 16px; }
.header-dim {
  color: var(--fg-dim);
  font-weight: 400;
}
#cluster-summary {
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.03em;
}
#theme-toggle { color: var(--fg); }

/* ==========================================================================
   Main content
   ========================================================================== */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  padding-bottom: 60px;
  max-width: 1140px;
  margin: 0 auto;
  width: 100%;
}

/* ==========================================================================
   Breadcrumb
   ========================================================================== */
.breadcrumb {
  padding: 8px 20px;
  font-size: 11px;
  color: var(--fg-dim);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { margin: 0 8px; color: var(--fg-dim); opacity: 0.5; }

/* ==========================================================================
   Cluster Status Bar — the instrument panel
   Backlit, slightly raised, precision readouts
   ========================================================================== */
#cluster-status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 100;
  font-size: 12px;
  /* Subtle top glow — like backlit instruments */
  box-shadow:
    0 -1px 0 var(--border),
    0 -8px 24px -4px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
#cluster-status-bar::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow-strong), transparent);
  pointer-events: none;
}

.csb-states { display: flex; gap: 2px; align-items: center; }

.csb-state {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  color: var(--fg-dim);
  font-size: 12px;
  background: none;
  border: 1px solid transparent;
  font: inherit;
  font-family: var(--font-mono);
}
.csb-state:hover {
  background: var(--bg-highlight);
  border-color: var(--border-strong);
  color: var(--fg-bright);
}
.csb-state:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.csb-state.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.csb-state.active .csb-state-count { color: var(--accent); }
.csb-state.active .csb-state-label { color: var(--accent); opacity: 0.8; }

/* State indicator dots — LED effect with glow */
.csb-state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.csb-state-dot[data-state="running"]   { background: var(--green); border-radius: 2px; box-shadow: 0 0 6px var(--green-glow); }
.csb-state-dot[data-state="thinking"]  { background: var(--cyan); box-shadow: 0 0 6px var(--cyan-glow); }
.csb-state-dot[data-state="attention"] { background: var(--yellow); border-radius: 1px; transform: rotate(45deg); box-shadow: 0 0 6px var(--yellow-glow); }
.csb-state-dot[data-state="idle"]      { background: var(--fg-dim); opacity: 0.5; }
.csb-state-dot[data-state="error"]     { background: var(--red); border-radius: 0; box-shadow: 0 0 6px var(--red-glow); }

.csb-state-count { font-weight: 600; color: var(--fg-bright); font-variant-numeric: tabular-nums; }
.csb-state-count.zero { color: var(--fg-dim); font-weight: 400; opacity: 0.6; }

.csb-state-label {
  color: var(--fg-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-display);
  font-weight: 500;
}

.csb-divider { width: 1px; height: 22px; background: var(--border-strong); flex-shrink: 0; }

.csb-metrics {
  display: flex;
  gap: 16px;
  align-items: center;
  color: var(--fg-dim);
  font-size: 11px;
  margin-left: auto;
  white-space: nowrap;
}
.csb-metric { display: flex; align-items: center; gap: 5px; }
.csb-metric-value { color: var(--fg-bright); font-weight: 500; font-variant-numeric: tabular-nums; }
.csb-metric-label {
  color: var(--fg-dim);
  font-size: 10px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

.csb-loading { color: var(--fg-dim); font-size: 11px; font-style: italic; opacity: 0.8; }

#cluster-status-bar.stale { border-top-color: var(--yellow); }
#cluster-status-bar.stale::after {
  content: 'STALE';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--yellow);
  letter-spacing: 0.1em;
  background: var(--bg-surface);
  padding: 0 8px;
  line-height: 1;
}

/* ==========================================================================
   Section headers
   ========================================================================== */
.section-header {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

/* ==========================================================================
   Node table — column headers
   ========================================================================== */
.node-colheaders {
  display: grid;
  grid-template-columns: 1fr 50px 50px 50px 70px 60px 140px;
  padding: 6px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-strong);
  font-size: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: sticky;
  top: 0;
  z-index: 10;
}
.ncol-ws, .ncol-run, .ncol-attn, .ncol-tokens { text-align: right; }
.ncol-health, .node-cell-health { padding-left: 10px; }

/* ==========================================================================
   Node rows — individual instrument readouts
   ========================================================================== */
.node-row {
  display: grid;
  grid-template-columns: 1fr 50px 50px 50px 70px 60px 140px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  border-left: 3px solid transparent;
  position: relative;
}
.node-row:nth-child(odd) { background: var(--bg); }
.node-row:nth-child(even) { background: var(--row-alt); }
.node-row:hover {
  background: var(--bg-highlight);
  box-shadow: inset 0 0 0 1px var(--border);
}
.node-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.node-row.has-attention { border-left-color: var(--yellow); background: linear-gradient(90deg, var(--yellow-glow), transparent 30%); }
.node-row.has-running   { border-left-color: var(--green); background: linear-gradient(90deg, var(--green-glow), transparent 30%); }
.node-row.has-thinking  { border-left-color: var(--cyan); background: linear-gradient(90deg, var(--cyan-glow), transparent 30%); }
.node-row.has-error     { border-left-color: var(--red); background: linear-gradient(90deg, var(--red-glow), transparent 30%); }
.node-row.has-attention:hover, .node-row.has-running:hover,
.node-row.has-thinking:hover, .node-row.has-error:hover {
  background: var(--bg-highlight);
}

.node-cell { font-size: 12px; display: flex; align-items: center; }
.node-cell-name {
  color: var(--fg-bright);
  font-weight: 500;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-cell-name .node-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 4px var(--green-glow);
}
.node-cell-name .node-dot.unreachable {
  background: var(--red);
  box-shadow: 0 0 4px var(--red-glow);
}
.node-cell-name .node-dot.degraded {
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent-glow-strong);
}
.node-degraded-badge {
  font-size: 9px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.6;
  flex-shrink: 0;
}

/* Version drift */
.node-cell-version {
  font-size: 11px;
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.node-cell-version.drift { color: var(--yellow); }
.ncol-version { text-align: right; }
.node-version-drift-badge {
  font-size: 9px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--yellow);
  background: var(--yellow-glow);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.6;
  flex-shrink: 0;
}
.csb-version-drift .drift-warn {
  color: var(--yellow);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.node-cell-num {
  color: var(--fg-dim);
  font-size: 11px;
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
}
.node-cell-num.has-value { color: var(--fg-bright); }
.node-cell-health { gap: 8px; font-size: 11px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }

/* Health bar — precision gauge */
.health-bar {
  width: 80px;
  height: 4px;
  background: var(--bg-highlight);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.health-bar-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.health-bar-fill.low { background: var(--green); box-shadow: 0 0 4px var(--green-glow); }
.health-bar-fill.mid { background: var(--yellow); box-shadow: 0 0 4px var(--yellow-glow); }
.health-bar-fill.high { background: var(--red); box-shadow: 0 0 4px var(--red-glow); }

/* ==========================================================================
   Node groups — rack panel sections
   ========================================================================== */
.node-group { margin-bottom: 1px; }

.node-group-header {
  display: grid;
  grid-template-columns: 1fr 50px 50px 50px 70px 60px 140px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  background: var(--bg-surface);
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.node-group-header::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.node-group-header:hover { background: var(--bg-highlight); }
.node-group-header:hover::before { opacity: 1; }
.node-group-header:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.node-group-header.has-attention { border-left-color: var(--yellow); }
.node-group-header.has-running   { border-left-color: var(--green); }
.node-group-header.has-thinking  { border-left-color: var(--cyan); }
.node-group-header.has-error     { border-left-color: var(--red); }

.node-group-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-bright);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-group-chevron {
  font-size: 10px;
  color: var(--fg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  width: 14px;
  display: inline-block;
  text-align: center;
}
.node-group-chevron.expanded { transform: rotate(90deg); }
.node-group-badge {
  font-size: 10px;
  font-family: var(--font-display);
  color: var(--fg-dim);
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.node-group-cell { font-size: 12px; display: flex; align-items: center; }
.node-group-cell.num { color: var(--fg-dim); font-size: 11px; justify-content: flex-end; font-variant-numeric: tabular-nums; }
.node-group-cell.num.has-value { color: var(--fg-bright); }

.node-group-body { overflow: hidden; }
.node-group-body.collapsed { display: none; }
.node-group-body .node-colheaders { position: static; z-index: auto; opacity: 0.85; }
.node-group-body .node-row { padding-left: 32px; }
.node-group-single .node-row { padding-left: 16px; }

/* ==========================================================================
   Dashboard table — console overrides
   ========================================================================== */
.dash-row.has-link { cursor: pointer; }
.dash-row.has-link::after {
  content: "\2197";
  position: absolute;
  right: 12px;
  top: 10px;
  font-size: 10px;
  color: var(--fg-dim);
  opacity: 0;
  transition: opacity 0.15s;
}
.dash-row.has-link:hover::after,
.dash-row.has-link:focus-visible::after { opacity: 0.6; }

.dash-cell-node {
  color: var(--accent);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.1s;
}
.dash-cell-node:hover { text-decoration: underline; color: var(--fg-bright); }

/* ==========================================================================
   Node link
   ========================================================================== */
.node-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--accent);
  font-size: 11px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
.node-link:hover { border-bottom-color: var(--accent); }

/* ==========================================================================
   Pagination
   ========================================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0;
  font-size: 12px;
  color: var(--fg-dim);
}
.pagination button {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--fg-bright);
  border-radius: var(--radius-sm);
  padding: 5px 14px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: var(--font-display);
  font-weight: 500;
}
.pagination button:hover { background: var(--bg-highlight); border-color: var(--accent-dim); }
.pagination button:disabled { opacity: 0.25; cursor: not-allowed; }

/* ==========================================================================
   Toast override — position above cluster status bar
   ========================================================================== */
#toast { bottom: 56px; z-index: 200; color: var(--fg-bright); border-color: var(--border-strong); }

/* ==========================================================================
   Header accent button (+ new)
   ========================================================================== */
#header .header-btn-accent {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
#header .header-btn-accent:hover {
  background: var(--accent-dim);
  color: var(--accent);
}
#header .header-btn-accent:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   New Workstream Modal
   ========================================================================== */
#new-ws-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
#new-ws-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 32px;
  width: 380px;
  max-width: 90vw;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 24px 48px -12px rgba(0, 0, 0, 0.5),
    0 0 80px -20px var(--accent-dim);
  position: relative;
}
#new-ws-box::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 1px;
}
#new-ws-box h2 {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: 0.02em;
}
#new-ws-box label {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 14px;
  margin-bottom: 5px;
}
.label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.6;
}
#new-ws-box select,
#new-ws-box input[type="text"],
#new-ws-box textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#new-ws-box textarea { resize: vertical; min-height: 40px; }
#new-ws-box textarea::placeholder { color: var(--fg-dim); opacity: 0.6; }
#new-ws-box select:focus,
#new-ws-box input:focus,
#new-ws-box textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
#new-ws-box input::placeholder { color: var(--fg-dim); opacity: 0.6; }
#new-ws-box select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a93ad' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
#new-ws-error {
  display: none;
  color: var(--red);
  font-size: 12px;
  margin-bottom: 6px;
}
#new-ws-buttons {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  justify-content: flex-end;
}
#new-ws-buttons button {
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-highlight);
  color: var(--fg);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.02em;
}
#new-ws-cancel:hover { background: var(--bg-elevated); border-color: var(--border-strong); }
#new-ws-submit {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
#new-ws-submit:hover { filter: brightness(1.1); }
#new-ws-submit:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
#new-ws-submit:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
@media (max-width: 380px) { #new-ws-box { padding: 24px 18px; } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 700px) {
  :root { --dash-grid: 68px 110px 1fr 56px 44px; }
  .dash-col-model, .dash-cell-model, .dash-col-node, .dash-cell-node { display: none; }
  .node-colheaders, .node-row { grid-template-columns: 1fr 40px 40px 40px 60px; }
  .node-group-header { grid-template-columns: 1fr 40px 40px 40px 60px; }
  .node-group-header .node-group-cell:last-child { display: none; }
  .ncol-version, .node-cell-version { display: none; }
  .ncol-health, .node-cell-health { display: none; }
  #main { padding: 16px; padding-bottom: 60px; }
}
@media (max-width: 480px) {
  :root { --dash-grid: 50px 1fr 50px; }
  .dash-col-model, .dash-cell-model, .dash-col-node, .dash-cell-node, .dash-col-task, .dash-cell-task, .dash-col-ctx, .dash-cell-ctx { display: none; }
  #cluster-status-bar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 6px; }
  .csb-states { flex-wrap: wrap; gap: 2px; }
  .csb-state { padding: 4px 6px; font-size: 11px; }
  .csb-divider { display: none; }
  .csb-metrics { width: 100%; justify-content: center; }
  #main { padding-bottom: 80px; }
  #header h1 { font-size: 13px; }
}

/* ==========================================================================
   Reduced motion — console-specific
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .node-group-chevron { transition: none; }
  .health-bar-fill { transition: none; }
  .csb-state, .node-row, .node-group-header { transition: none; }
  .node-link, .dash-cell-node, .pagination button { transition: none; }
  .dash-row.has-link::after, .node-group-header::before { transition: none; }
  #new-ws-box select, #new-ws-box input, #new-ws-buttons button { transition: none; }
}
