/* ============================================================
   Orchestrator View Styles
   ============================================================ */

.orchestrator-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 120px);
}

.orch-left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 500px;
  overflow: hidden;
}

.orch-right-panel {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

/* Toolbar */
.orch-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 0;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.orch-toolbar select {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.orch-task-input {
  flex: 1;
  min-width: 150px;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

/* Canvas */
.orch-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  margin: 8px 0;
}

.orch-svg {
  width: 100%;
  height: 100%;
  min-height: 300px;
}

.orch-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Node List */
.orch-node-list {
  max-height: none;
  overflow-y: visible;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  background: var(--bg-card);
}

.orch-node-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: background var(--transition);
}

.orch-node-item:hover {
  background: var(--bg-input);
}

.orch-node-item.selected {
  background: var(--accent-light, rgba(var(--accent-rgb), 0.1));
  border: 1px solid var(--accent);
}

/* —— 本体推导面板（命中配方 + 每步生成记录）—— */
.orch-ontology-panel {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text);
}
.oont-head {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--accent, #5b8def);
}
.oont-recipe {
  border: 1px solid var(--accent, #5b8def);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
  background: rgba(var(--accent-rgb, 91, 141, 239), 0.06);
}
.oont-recipe-title { font-weight: 600; margin-bottom: 6px; }
.oont-recipe-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.oont-tag {
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
  background: var(--bg-input); color: var(--text-muted);
}
.oont-tag.det { background: #2d6a4f; color: #fff; }
.oont-probes, .oont-phases {
  display: flex; gap: 5px; flex-wrap: wrap; align-items: center;
  margin-top: 4px; color: var(--text-muted);
}
.oont-probe, .oont-phase {
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
  background: var(--bg-input); color: var(--text);
}
.oont-phase { background: rgba(var(--accent-rgb, 91, 141, 239), 0.15); color: var(--accent); }
.oont-steps-head { font-weight: 600; margin: 4px 0 8px; color: var(--text-muted); }
.oont-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  margin-bottom: 8px;
}
.oont-step-head { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin-bottom: 5px; }
.oont-step-idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent, #5b8def); color: #fff; font-size: 11px; font-weight: 700;
}
.oont-src {
  font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}
.oont-src-recipe { background: #5b8def; color: #fff; }
.oont-src-llm_route { background: #9d4edd; color: #fff; }
.oont-src-keyword { background: #f08c00; color: #fff; }
.oont-src-fallback { background: #868e96; color: #fff; }
.oont-src-explicit { background: #2d6a4f; color: #fff; }
.oont-src-unknown { background: #868e96; color: #fff; }
.oont-step-phase { color: var(--text-muted); font-size: 11px; }
.oont-line { margin: 2px 0; line-height: 1.5; }
.oont-tools { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.oont-tool {
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
  background: var(--bg-input); color: var(--text);
}
.oont-tool em { color: var(--accent, #5b8def); font-style: normal; font-weight: 600; }

.orch-node-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.orch-node-label {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
}

.orch-node-type-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-input);
  color: var(--text-muted);
  flex-shrink: 0;
}

.orch-node-type-badge.supervisor {
  background: #8b5cf6;
  color: #fff;
}

.orch-node-type-badge.approval {
  background: #f59e0b;
  color: #fff;
}

.orch-node-type-badge.loop {
  background: #06b6d4;
  color: #fff;
}

.orch-node-type-badge.tool {
  background: #10b981;
  color: #fff;
}

.orch-node-type-badge.ont {
  background: #6366f1;
  color: #fff;
}

.orch-node-ont-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #6366f1;
  color: #fff;
  margin-left: 6px;
  flex-shrink: 0;
}

/* Node Editor */
.orch-node-editor {
  flex-shrink: 0;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  margin-top: 8px;
}

.orch-node-editor h4 {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--text-primary);
}

/* Exec Result */
.orch-exec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.orch-exec-result {
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.orch-exec-placeholder {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 0;
}

.orch-exec-result .success {
  color: var(--success, #22c55e);
}

.orch-exec-result .error {
  color: var(--danger, #ef4444);
}

.orch-exec-result .info {
  color: var(--accent);
}

/* Checkpoints */
.orch-checkpoints {
  flex-shrink: 0;
  max-height: 180px;
  overflow-y: auto;
  font-size: 11px;
}

.orch-checkpoints h5 {
  margin: 0 0 6px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.orch-checkpoint-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-light);
  font-size: 11px;
}

.orch-checkpoint-row code {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 1px 4px;
  border-radius: 2px;
}

/* 架构参数面板（P0：六类编排器可视化） */
.orch-arch-config {
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--bg-input, #16203a);
  border: 1px solid var(--border, #2a3550);
  border-radius: 8px;
}
.orch-arch-config:empty { display: none; }
.oac-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  flex-wrap: wrap;
}
.oac-row > label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 64px;
  font-weight: 600;
}
.oac-row select,
.oac-row input[type="number"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border, #2a3550);
  background: var(--bg-card, #0f1830);
  color: var(--text-primary);
  font-size: 12px;
}
.oac-hint {
  font-size: 11px;
  color: var(--text-muted);
}
.oac-routes-head { justify-content: space-between; }
.oac-routes { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.oac-route {
  display: flex;
  align-items: center;
  gap: 6px;
}
.orch-route-kw {
  flex: 1;
  min-width: 120px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border, #2a3550);
  background: var(--bg-card, #0f1830);
  color: var(--text-primary);
  font-size: 12px;
}
.orch-route-target {
  min-width: 160px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border, #2a3550);
  background: var(--bg-card, #0f1830);
  color: var(--text-primary);
  font-size: 12px;
}

/* Preset Grid */
.orch-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px 0;
}

.orch-preset-card {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.orch-preset-card:hover {
  border-color: var(--accent);
  background: var(--bg-input);
}

.orch-preset-card strong {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.orch-preset-card .desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* SVG Canvas Nodes */
.orch-node {
  position: absolute;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 11px;
  min-width: 120px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  z-index: 2;
}

.orch-node:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.orch-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light, rgba(var(--accent-rgb), 0.2));
}

.orch-node.connecting {
  border-color: var(--success, #22c55e);
}

.orch-node-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.orch-node-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 12px;
}

.orch-node-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.orch-node-actions {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
}

.orch-node-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  cursor: crosshair;
  transition: all var(--transition);
}

.orch-node-handle:hover {
  background: var(--accent);
  transform: scale(1.3);
}

.orch-node-handle.in {
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
}

.orch-node-handle.in:hover {
  transform: translateX(-50%) scale(1.3);
}

.orch-node-handle.out {
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
}

.orch-node-handle.out:hover {
  transform: translateX(-50%) scale(1.3);
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  transition: all var(--transition);
}

.modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Exec Stats */
.exec-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
}

.exec-stat strong {
  color: var(--text-primary);
}

/* Node Item: name+badge row wrap for tool chips */
.orch-node-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

/* Node-bound tool chips */
.orch-node-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-light);
}

.orch-node-tools.compact {
  border-top: none;
  margin-top: 4px;
  padding-top: 0;
  justify-content: center;
}

.orch-node-tools-label {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.orch-tool-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.orch-tool-chip:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* Tool Test Modal */
.orch-tool-test-modal {
  max-width: 560px;
  width: 92%;
}

.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-header-row h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text-primary);
}

.ott-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.ott-meta code {
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--accent);
  font-size: 12px;
}

.ott-form {
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.ott-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-family: var(--font-mono, monospace);
}

.ott-type {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

.ott-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 4px;
  line-height: 1.4;
}

.ott-result-wrap {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.ott-result {
  border-radius: var(--radius);
  padding: 10px;
  border: 1px solid var(--border);
}

.ott-result.success {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.4);
}

.ott-result.error {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.4);
}

.ott-result-head {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.ott-result-body {
  margin: 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  font-family: var(--font-mono, monospace);
  color: var(--text-secondary);
}
