/**
 * Narrative Engine — Default Theme (Light)
 *
 * Semantic CSS for NarrativeEngine HTML output.
 * All classes use the `ne-` prefix.
 *
 * The plan table is designed to blend into surrounding prose —
 * no heavy borders, no header bar. Each environment can add
 * weight via its own scoped overrides if needed.
 */

/* ── Plan Table ────────────────────────────── */

.ne-plan {
  margin: 4px 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ne-plan-table {
  width: 100%;
  border-collapse: collapse;
}

/* Step rows */
.ne-step td {
  padding: 4px 4px;
  vertical-align: middle;
}

.ne-step-status {
  width: 20px;
  text-align: center;
}

.ne-step-label {
  color: #374151;
  font-size: 13px;
}

.ne-step-progress {
  width: 56px;
  text-align: right;
}

/* Group rows */
.ne-step-group .ne-step-label {
  font-weight: 600;
}

.ne-group-arrow {
  color: #9ca3af;
  font-size: 9px;
  margin-right: 2px;
}

/* Instance rows (indented children) */
.ne-step-instance .ne-step-label {
  padding-left: 18px;
  font-size: 12px;
  color: #6b7280;
}

.ne-step-instance td {
  padding: 2px 4px;
}

/* ── Step Dots (small dots on the vertical line) ── */

.ne-check {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: #d1d5db;
}

.ne-check-sm {
  width: 6px;
  height: 6px;
}

.ne-check-completed {
  background: #86efac;
}
.ne-check-completed::after { content: none; }

.ne-check-in_progress {
  background: #93c5fd;
  animation: ne-pulse 1.5s infinite;
}

.ne-check-failed {
  background: #fca5a5;
}
.ne-check-failed::after { content: none; }

/* ── Status Badges ─────────────────────────── */

.ne-badge {
  display: inline-block;
  font-size: 10px;
  padding: 0 6px;
  border-radius: 8px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.6;
}

.ne-badge-sm {
  font-size: 9px;
  padding: 0 4px;
}

.ne-badge-completed { background: rgba(34, 197, 94, 0.1); color: #16a34a; }
.ne-badge-in_progress { background: rgba(59, 130, 246, 0.1); color: #2563eb; animation: ne-pulse 1.5s infinite; }
.ne-badge-failed { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
.ne-badge-pending { background: rgba(0, 0, 0, 0.03); color: #9ca3af; }

/* ── Narrative Bullets ─────────────────────── */

.ne-narrative-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0;
}

.ne-narrative-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.015);
  border-left: 2px solid rgba(0, 0, 0, 0.06);
  font-size: 13px;
  line-height: 1.5;
  color: #374151;
}

.ne-narrative-reasoning {
  font-style: italic;
  color: #6366f1;
  border-left-color: rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.03);
  border-radius: 0;
}

.ne-narrative-icon {
  flex-shrink: 0;
  opacity: 0.5;
  font-size: 10px;
  margin-top: 3px;
}

.ne-narrative-text {
  flex: 1;
}

/* ── Workflow Timeline ──────────────────────── */

.ne-timeline-node {
  position: relative;
  padding-left: 20px;
  padding-bottom: 4px;
  margin-bottom: 2px;
}

/* Vertical connector line — centered with dot */
.ne-timeline-node::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e5e7eb;
}

/* First node: line starts at the dot, not from the top */
.ne-timeline-node:first-child::before {
  top: 14px;
}

/* Last node: line ends at the dot */
.ne-timeline-node:last-child::before {
  bottom: calc(100% - 14px);
}

/* Node marker row: dot + label + time */
.ne-timeline-marker {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}

.ne-timeline-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: -16px; /* center dot over the connector line */
  position: relative;
  z-index: 1;
}

.ne-timeline-label {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.ne-timeline-sub-tag {
  font-size: 9px;
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 500;
}

.ne-timeline-time {
  font-size: 10px;
  color: #9ca3af;
  margin-left: auto;
}

/* Content area (start/complete messages + reasoning) */
.ne-timeline-content {
  padding: 0 0 2px 0;
}

.ne-timeline-msg {
  font-size: 12px;
  color: #6b7280;
  padding: 1px 0;
  line-height: 1.5;
}

.ne-timeline-start {
  color: #6b7280;
}

.ne-timeline-complete {
  color: #16a34a;
}

.ne-timeline-complete::before {
  content: '✓ ';
  font-size: 10px;
}

/* Agent reasoning / plan table sits inline */
.ne-timeline-reasoning {
  margin: 4px 0;
  font-size: 12px;
}

/* Normalize font sizes for content injected into the timeline */
.ne-timeline-reasoning .ne-plan-table td,
.ne-timeline-reasoning p,
.ne-timeline-reasoning div {
  font-size: inherit;
}

/* Narrative items inside timeline: small dots on a vertical line */
.ne-timeline-reasoning .ne-narrative-item {
  border-radius: 0;
  border-left: none;
  background: none;
  padding: 2px 0 2px 14px;
  position: relative;
  font-size: 12px;
  gap: 0;
}

/* Replace text icon with a small dot */
.ne-timeline-reasoning .ne-narrative-icon {
  position: absolute;
  left: 0px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d1d5db;
  font-size: 0;      /* hide the text icon */
  overflow: hidden;
  opacity: 1;
  margin: 0;
}

/* Vertical line connecting the dots */
.ne-timeline-reasoning .ne-narrative-list {
  position: relative;
  margin-left: 3px;
  padding-left: 0;
  gap: 0;  /* remove gap so the line is continuous */
}

.ne-timeline-reasoning .ne-narrative-item::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e5e7eb;
}

.ne-timeline-reasoning .ne-narrative-item:last-child::before {
  bottom: 50%;
}

/* Plan table inside timeline: connect dots with a vertical line, same as
   .ne-narrative-item dots. Group → instances are visually one stack. */
.ne-timeline-reasoning .ne-plan-table .ne-step-status {
  position: relative;
}

.ne-timeline-reasoning .ne-plan-table .ne-step-status::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #e5e7eb;
  transform: translateX(-50%);
  z-index: 0;
}

.ne-timeline-reasoning .ne-plan-table .ne-step:first-child .ne-step-status::before {
  top: 50%;
}

.ne-timeline-reasoning .ne-plan-table .ne-step:last-child .ne-step-status::before {
  bottom: 50%;
}

.ne-timeline-reasoning .ne-plan-table .ne-check {
  position: relative;
  z-index: 1;
}

/* Remove rounded corners from all bordered/boxed content inside the timeline */
.ne-timeline-content .rounded,
.ne-timeline-content .custom-narrative-start,
.ne-timeline-content .custom-narrative-complete,
.ne-timeline-content [class*="border-l-"],
.ne-timeline-content [class*="rounded"] {
  border-radius: 0 !important;
}

/* Normalize font size for injected content */
.ne-timeline-content .text-sm {
  font-size: 12px !important;
}

/* Nested subworkflow indentation */
.ne-timeline-nested {
  margin-left: 8px;
  padding-left: 12px;
  border-left: 2px solid #ede9fe;
}

/* ── Code Header Bar ───────────────────────── */

.code-header-bar {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  margin: -12px -14px 8px -14px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  font-size: 11px;
  color: #868e96;
  user-select: none;
}

.code-header-lang {
  font-weight: 500;
  text-transform: lowercase;
}

.code-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #adb5bd;
  padding: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.code-copy-btn:hover {
  color: #495057;
}

/* ── Animation ─────────────────────────────── */

@keyframes ne-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
