/* ===== StageOne — Minimal CSS (Tailwind handles most layout/spacing) ===== */

/* --- Status color system (used by dynamic JS class names) --- */
:root {
  --status-pending-bg: #f7f7f7;
  --status-pending-border: #d7d7d7;
  --status-pending-text: #4a4a4a;
  --status-running-bg: #fff5e8;
  --status-running-border: #dcbf93;
  --status-running-text: #6a4708;
  --status-completed-bg: #eef8f1;
  --status-completed-border: #a9c9b2;
  --status-completed-text: #255a35;
  --status-awaiting-bg: #eef3ff;
  --status-awaiting-border: #b5c1e6;
  --status-awaiting-text: #244577;
  --status-failed-bg: #fdeeee;
  --status-failed-border: #d8a6a6;
  --status-failed-text: #7a1f1f;
}

/* --- Utility --- */
.hidden { display: none !important; }

/* --- Navigation tabs --- */
.nav-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(0,0,0,0.08);
  background: #fff;
  color: #6b7280;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.nav-btn:hover { background: #f9fafb; color: #111827; }
.nav-btn.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

/* --- Status tags (dynamically generated class names) --- */
.status-tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.02em;
  border-radius: 4px;
  border: 1px solid var(--status-pending-border);
  background: var(--status-pending-bg);
  color: var(--status-pending-text);
  white-space: nowrap;
}
.tag-pending   { border-color: var(--status-pending-border); background: var(--status-pending-bg); color: var(--status-pending-text); }
.tag-stopped   { border-color: var(--status-pending-border); background: #f2f2f2; color: #555; }
.tag-starting  { border-color: var(--status-awaiting-border); background: #eef3ff; color: #244577; }
.tag-running   { border-color: var(--status-running-border); background: var(--status-running-bg); color: var(--status-running-text); }
.tag-queued    { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.tag-cancelling { border-color: var(--status-running-border); background: #fff7ef; color: #7d4b00; }
.tag-completed { border-color: var(--status-completed-border); background: var(--status-completed-bg); color: var(--status-completed-text); }
.tag-awaiting_approval { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.tag-awaiting_requirements { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.tag-failed    { border-color: var(--status-failed-border); background: var(--status-failed-bg); color: var(--status-failed-text); }

/* --- Progress bar step segments --- */
.step-segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  font-size: 10px;
  font-weight: 500;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.03em;
  transition: opacity 0.15s;
  overflow: hidden;
}
.step-segment:first-child { border-radius: 4px 0 0 4px; }
.step-segment:last-child { border-radius: 0 4px 4px 0; }
.step-segment:hover { opacity: 0.85; }

.step-segment.pending       { background: var(--status-pending-bg); color: var(--status-pending-text); border-right: 1px solid var(--status-pending-border); }
.step-segment.running       { background: var(--status-running-bg); color: var(--status-running-text); border-right: 1px solid var(--status-running-border); }
.step-segment.queued        { background: var(--status-awaiting-bg); color: var(--status-awaiting-text); border-right: 1px solid var(--status-awaiting-border); }
.step-segment.cancelling    { background: #fff7ef; color: #7d4b00; border-right: 1px solid var(--status-running-border); }
.step-segment.completed     { background: var(--status-completed-bg); color: var(--status-completed-text); border-right: 1px solid var(--status-completed-border); }
.step-segment.awaiting_approval { background: var(--status-awaiting-bg); color: var(--status-awaiting-text); border-right: 1px solid var(--status-awaiting-border); }
.step-segment.awaiting_requirements { background: var(--status-awaiting-bg); color: var(--status-awaiting-text); border-right: 1px solid var(--status-awaiting-border); }
.step-segment.failed        { background: var(--status-failed-bg); color: var(--status-failed-text); border-right: 1px solid var(--status-failed-border); }
.step-segment.stopped       { background: #f2f2f2; color: #555; border-right: 1px solid var(--status-pending-border); }
.step-segment:last-child    { border-right: none; }

/* --- Step chips (used in expanded details) --- */
.step-chip {
  border: 1px solid var(--status-pending-border);
  padding: 6px 8px;
  background: var(--status-pending-bg);
  color: var(--status-pending-text);
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.4;
  border-radius: 6px;
}
.step-chip strong { display: block; font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.step-chip small { display: block; margin-top: 2px; font-size: 10px; opacity: 0.8; }
.step-chip.pending       { border-color: var(--status-pending-border); background: var(--status-pending-bg); color: var(--status-pending-text); }
.step-chip.running       { border-color: var(--status-running-border); background: var(--status-running-bg); color: var(--status-running-text); }
.step-chip.queued,
.step-chip.cancelling    { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.step-chip.completed     { border-color: var(--status-completed-border); background: var(--status-completed-bg); color: var(--status-completed-text); }
.step-chip.awaiting_approval { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.step-chip.awaiting_requirements { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.step-chip.failed        { border-color: var(--status-failed-border); background: var(--status-failed-bg); color: var(--status-failed-text); }
.step-chip.stopped       { border-color: var(--status-pending-border); background: #f2f2f2; color: #555; }

/* --- Overflow dropdown menu --- */
.overflow-menu { position: relative; }
.overflow-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  color: #6b7280;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1;
}
.overflow-trigger:hover { background: #f9fafb; color: #111827; }
.overflow-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
  z-index: 50;
  padding: 4px 0;
  font-family: inherit;
}
.overflow-dropdown hr { margin: 4px 0; border-color: rgba(0,0,0,0.06); }
.overflow-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 400;
  color: #374151;
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.1s;
}
.overflow-item:hover { background: #f3f4f6; }
.overflow-item.danger-item { color: #991b1b; }
.overflow-item.danger-item:hover { background: #fef2f2; }

/* --- Microphone icon (CSS-drawn) --- */
.mic-icon {
  position: relative;
  width: 10px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 6px;
  display: inline-block;
}
.mic-icon::before {
  content: "";
  position: absolute;
  left: 50%; bottom: -6px;
  width: 2px; height: 6px;
  transform: translateX(-50%);
  background: currentColor;
}
.mic-icon::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -8px;
  width: 10px; height: 5px;
  border: 2px solid currentColor;
  border-top: none;
  border-radius: 0 0 8px 8px;
  transform: translateX(-50%);
}

/* --- Markdown rendered output --- */
.details,
.details > div,
.console-container,
.md-render {
  min-width: 0;
}

.md-render {
  font-size: 13px;
  line-height: 1.7;
  max-width: 100%;
  overflow: hidden;
}
.md-render p, .md-render ul, .md-render ol { margin: 0 0 8px; }
.md-render h1, .md-render h2, .md-render h3, .md-render h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}
.md-render code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 3px;
}
.md-render pre {
  background: #f9fafb;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.md-render pre,
.md-render code {
  overflow-wrap: anywhere;
}
.md-render pre code { background: transparent; padding: 0; }
.md-render a { color: #2563eb; text-decoration: underline; }
.md-render blockquote {
  margin: 0 0 8px;
  padding-left: 12px;
  border-left: 3px solid rgba(37, 99, 235, 0.18);
  color: #4b5563;
}
.md-render table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 8px;
  font-size: 12px;
}
.md-render th,
.md-render td {
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.md-render th {
  background: rgba(0, 0, 0, 0.03);
  font-weight: 600;
}

.step-detail-output,
.step-detail-error {
  max-height: 320px;
  overflow: auto;
}

/* --- Live console --- */
.live-console {
  margin: 0;
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  padding: 10px 12px;
  background: #111827;
  color: #d1d5db;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 8px;
}
.live-console.empty { color: #6b7280; }

/* --- Toast notification --- */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  font-family: 'Inter', sans-serif;
}

/* --- Focus step (live board) --- */
.focus-step {
  border: 1px solid var(--status-pending-border);
  padding: 6px 8px;
  background: var(--status-pending-bg);
  color: var(--status-pending-text);
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.4;
  border-radius: 6px;
}
.focus-step b { display: block; margin-bottom: 2px; font-weight: 600; font-size: 11px; }
.focus-step.pending       { border-color: var(--status-pending-border); background: var(--status-pending-bg); color: var(--status-pending-text); }
.focus-step.running       { border-color: var(--status-running-border); background: var(--status-running-bg); color: var(--status-running-text); }
.focus-step.queued,
.focus-step.cancelling    { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.focus-step.completed     { border-color: var(--status-completed-border); background: var(--status-completed-bg); color: var(--status-completed-text); }
.focus-step.awaiting_approval { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.focus-step.awaiting_requirements { border-color: var(--status-awaiting-border); background: var(--status-awaiting-bg); color: var(--status-awaiting-text); }
.focus-step.failed        { border-color: var(--status-failed-border); background: var(--status-failed-bg); color: var(--status-failed-text); }
.focus-step.stopped       { border-color: var(--status-pending-border); background: #f2f2f2; color: #555; }
