/* ============================================================
   Orchestrator — 双视图工作流编排样式
   ============================================================ */

/* 视图切换 Tabs */
.orchestrator-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 12px;
}
.orchestrator-tab {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.orchestrator-tab:hover { color: var(--text); }
.orchestrator-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* 视图容器 */
.orchestrator-view {
  display: none;
  flex: 1;
  overflow: hidden;
}
.orchestrator-view.active { display: flex; }

/* ============================================================
   Timeline View 甘特图
   ============================================================ */

.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  font-size: 12px;
}
.timeline-toolbar .tl-btn {
  padding: 3px 12px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.timeline-toolbar .tl-btn:hover { background: var(--accent-soft); }
.timeline-toolbar .tl-date {
  font-weight: 600;
  min-width: 140px;
  text-align: center;
}

/* 甘特容器 */
.timeline-gantt {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.timeline-header {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--panel-soft);
  border-bottom: 2px solid var(--line);
}
.timeline-header-label {
  min-width: 160px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-right: 1px solid var(--line);
  flex-shrink: 0;
}
.timeline-header-days {
  display: flex;
  flex: 1;
}
.timeline-day-cell {
  flex: 1;
  min-width: 40px;
  padding: 6px 2px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  border-right: 1px solid rgba(0,0,0,0.05);
}
.timeline-day-cell.weekend { background: rgba(0,0,0,0.02); }
.timeline-day-cell.today {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* 轨道（每个 Agent 一行） */
.timeline-track {
  display: flex;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
  position: relative;
}
.timeline-track:hover { background: rgba(99,102,241,0.02); }
.timeline-track.highlight { background: rgba(99,102,241,0.06); }

.timeline-track-label {
  min-width: 160px;
  padding: 8px 12px;
  font-size: 12px;
  border-right: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--panel);
}
.timeline-track-label .agent-name {
  font-weight: 600;
  color: var(--text);
}
.timeline-track-label .agent-role {
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px;
}

.timeline-track-bars {
  flex: 1;
  position: relative;
  min-height: 48px;
}

/* 执行历史条形图 */
.tl-bar {
  position: absolute;
  top: 6px;
  height: 18px;
  border-radius: 4px;
  font-size: 9px;
  padding: 0 4px;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: opacity var(--transition);
  color: #fff;
}
.tl-bar:hover { opacity: 0.85; }
.tl-bar.success { background: #10b981; }
.tl-bar.failed { background: #ef4444; }
.tl-bar.running { background: #f59e0b; animation: tl-pulse 1.5s infinite; }
@keyframes tl-pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

/* Cron 定时标记 */
.tl-cron-marker {
  position: absolute;
  top: 28px;
  width: 16px;
  height: 16px;
  transform: translateX(-8px);
  cursor: pointer;
}
.tl-cron-marker::after {
  content: '';
  display: block;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 12px solid #6366f1;
  margin: 2px auto 0;
}
.tl-cron-label {
  position: absolute;
  top: 44px;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--accent);
  white-space: nowrap;
  font-weight: 600;
}

/* ============================================================
   Timeline 添加定时表单
   ============================================================ */

.timeline-add-schedule {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel-soft);
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.timeline-add-schedule input {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--panel);
  color: var(--text);
}
.timeline-add-schedule input.cron-input { width: 100px; font-family: monospace; }
.timeline-add-schedule input.name-input { width: 100px; }
.timeline-add-schedule .btn { font-size: 11px; padding: 3px 10px; }

/* ============================================================
   编排计划列表卡片
   ============================================================ */

.plan-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.plan-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.plan-card .plan-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.plan-card .plan-name { font-weight: 600; font-size: 14px; }
.plan-card .plan-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}
.plan-card .plan-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* 模式徽章 */
.pattern-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  margin-right: 6px;
}
.pattern-badge.pipeline { background: #667eea; }
.pattern-badge.parallel { background: #f093fb; }
.pattern-badge.verify { background: #fa709a; }
.pattern-badge.loop_until { background: #30cfd0; }

/* 空状态 */
.orchestrator-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.orchestrator-empty .empty-icon { font-size: 48px; margin-bottom: 12px; }
.orchestrator-empty h3 { color: var(--text); margin-bottom: 6px; }

/* ============================================================
   日编排编辑器 — 左右分栏 + 可缩放时间轴
   ============================================================ */

.tl-wrap { display: flex; gap: 12px; height: calc(100vh - 230px); min-height: 460px; }

.tl-left {
  width: 360px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--panel); overflow: hidden;
}
.tl-left-head { padding: 10px; border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.tl-left-scroll { flex: 1; overflow-y: auto; padding: 10px; }

.tl-right {
  flex: 1; position: relative; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--panel);
}

.tl-axis { position: relative; }

.tl-hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.tl-hour-label {
  position: absolute; left: 6px; top: -9px;
  font-size: 10px; color: var(--muted);
  background: var(--panel); padding: 0 4px; line-height: 1;
}

.tl-block {
  position: absolute; left: 44px; right: 12px; height: 22px;
  border-radius: 5px; padding: 0 8px; box-sizing: border-box;
  color: #fff; font-size: 11px; line-height: 22px;
  cursor: grab; display: flex; align-items: center; gap: 6px;
  overflow: hidden; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); z-index: 2;
}
.tl-block:hover { filter: brightness(1.08); }
.tl-block.paused { opacity: .45; }
.tl-block .tl-block-time { font-weight: 700; flex-shrink: 0; }
.tl-block .tl-block-name { overflow: hidden; text-overflow: ellipsis; }

.tl-cursor {
  position: absolute; left: 0; right: 0; height: 2px;
  background: #e67e22; z-index: 5; pointer-events: none;
}
.tl-cursor::after { content: '▼'; position: absolute; right: 8px; top: -11px; color: #e67e22; font-size: 12px; }

.tl-now-line { position: absolute; left: 0; right: 0; border-top: 2px solid #e74c3c; z-index: 3; pointer-events: none; }
.tl-now-label {
  position: absolute; right: 4px; top: 2px;
  font-size: 9px; color: #fff; background: #e74c3c; padding: 0 4px; border-radius: 3px;
}

.tl-chip {
  display: inline-block; padding: 3px 10px; margin: 2px;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent);
  font-size: 11px; cursor: grab; border: 1px dashed transparent; user-select: none;
}
.tl-chip:hover { border-color: var(--accent); }
.tl-chip.selected { background: var(--accent); color: #fff; }

.entry-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 6px; background: var(--panel-soft);
}
.entry-row.paused { opacity: .6; }
.entry-row .er-time { width: 78px; flex-shrink: 0; }
.entry-row .er-time input, .entry-row .er-wf select {
  width: 100%; padding: 4px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 12px; background: var(--panel); color: var(--text);
}
.entry-row .er-wf { flex: 1; min-width: 0; }
.entry-row .btn { flex-shrink: 0; padding: 2px 7px; font-size: 12px; }

.tl-zoombar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; font-size: 11px; color: var(--muted);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.tl-zoombar .zbtn {
  padding: 2px 9px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 12px;
}
.tl-zoombar .zbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
