/* 打字机光标动画 */
@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

.streaming-cursor {
  animation: blink 1s infinite;
}

/* 呼吸灯动画 */
@keyframes breathe {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
    transform: scale(1.1);
  }
}

/* 时间线节点圆点状态样式 */
.timeline-dot {
  transition: all 0.3s ease;
}

.timeline-dot.running {
  border-color: #3b82f6 !important;
  background: #3b82f6 !important;
  animation: breathe 1.5s ease-in-out infinite;
}

.timeline-dot.succeeded {
  border-color: #10b981 !important;
  background: #10b981 !important;
}

.timeline-dot.failed {
  border-color: #f43f5e !important;
  background: #f43f5e !important;
}

/* 节点卡片悬停效果 */
.node-card:hover .node-content {
  box-shadow: 0 2px 8px -2px rgb(0 0 0 / 0.1);
}

/* 节点卡片选中高亮效果 */
@keyframes highlightPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.node-card.node-highlight .node-content {
  animation: highlightPulse 1s ease-in-out 2;
  border-color: #3b82f6;
  background: linear-gradient(to right, #eff6ff, #ffffff);
}

/* 工作流分隔标题展开/收缩 */
.workflow-divider {
  user-select: none;
}

.workflow-divider .workflow-toggle-icon {
  transition: transform 0.2s ease;
}

.workflow-divider:hover .workflow-toggle-icon {
  color: #64748b;
}

/* 节点时间线展开/收缩动画 */
.node-timeline {
  transition: all 0.3s ease;
  overflow: hidden;
}

.node-timeline.hidden {
  display: none;
}

/* 下方时间线工作流分隔样式 */
.workflow-divider {
  position: relative;
  padding: 12px 16px;
  margin: 8px 0;
  background: linear-gradient(to right, #f8fafc, #ffffff);
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.workflow-divider::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 8px 0 0 8px;
}

/* 工作流1分隔线颜色 */
.workflow-divider:first-of-type::before {
  background: linear-gradient(to bottom, #3b82f6, #60a5fa);
}

/* 工作流2分隔线颜色 */
.workflow-divider.mt-4::before {
  background: linear-gradient(to bottom, #10b981, #34d399);
}

/* Loop 节点内部子节点缩进样式 */
.node-card.loop-child {
  border-left: 2px solid #f59e0b;
  padding-left: 8px;
}

/* Loop 节点内部子节点时间线圆点位置修正 */
.node-card.loop-child .timeline-dot {
  left: -38px;
}

/* Loop 节点特殊样式 */
.node-card[data-node-type="loop"] .node-content,
.node-card[data-node-type="iteration"] .node-content {
  border-left: 3px solid #f59e0b;
  background: linear-gradient(to right, #fffbeb, #ffffff);
}

/* 顶部导航工作流标签样式 */
.workflow-nav-label {
  flex-shrink: 0;
}

/* 顶部导航 Loop 迭代节点样式 */
.top-nav-node.loop-iteration-node .nav-title {
  color: #d97706;
  font-weight: 600;
}

.top-nav-node.loop-iteration-node .nav-icon {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
}

/* Loop 导航容器样式 */
.loop-nav-container {
  min-width: fit-content;
  max-width: 100%;
  flex: 0 1 auto;
}

.loop-nav-container .loop-nav-header {
  user-select: none;
}

.loop-nav-container .loop-iterations-container {
  scrollbar-width: thin;
  scrollbar-color: #fcd34d transparent;
}

.loop-nav-container .loop-iterations-container::-webkit-scrollbar {
  width: 4px;
}

.loop-nav-container .loop-iterations-container::-webkit-scrollbar-track {
  background: transparent;
}

.loop-nav-container .loop-iterations-container::-webkit-scrollbar-thumb {
  background-color: #fcd34d;
  border-radius: 2px;
}

/* 迭代行样式 */
.loop-iteration-row {
  transition: opacity 0.3s ease, border-color 0.3s ease;
  width: fit-content;
  min-width: 100%;
}

.loop-iteration-row .iteration-nodes {
  scrollbar-width: none;
  flex-wrap: nowrap;
}

.loop-iteration-row .iteration-nodes::-webkit-scrollbar {
  display: none;
}

/* 迭代内节点悬停效果 */
.loop-iter-node:hover {
  background-color: #f1f5f9;
}

.loop-iter-node:hover .iter-node-icon {
  transform: scale(1.1);
}

/* 顶部导航滚动容器 */
#top-timeline-nav [data-workflow] {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

#top-timeline-nav [data-workflow]::-webkit-scrollbar {
  height: 4px;
}

#top-timeline-nav [data-workflow]::-webkit-scrollbar-track {
  background: transparent;
}

#top-timeline-nav [data-workflow]::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 2px;
}

/* 加载动画 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  animation: spin 1s linear infinite;
}

/* 渐入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.node-card {
  animation: fadeIn 0.15s ease-out;
}

/* 状态徽章过渡 */
.workflow-status-badge,
.node-status-badge {
  transition: all 0.2s ease;
}

/* 表单验证错误样式 */
.form-group input:invalid:not(:placeholder-shown),
.form-group textarea:invalid:not(:placeholder-shown) {
  border-color: #f43f5e;
}

.form-group input:valid:not(:placeholder-shown),
.form-group textarea:valid:not(:placeholder-shown) {
  border-color: #10b981;
}

/* 思考过程区域样式 */
.reasoning-section .reasoning-content {
  max-height: 160px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.5;
}

/* 输出区域样式 */
.output-section {
  margin-top: 0.5rem;
}

/* 节点展开图标旋转 */
.node-expand-icon {
  transition: transform 0.2s ease;
}

/* 图片上传区域拖拽效果 */
.image-upload-area.drag-over {
  border-color: hsl(214, 78%, 46%);
  background-color: hsl(214, 78%, 98%);
}

/* 代码块样式优化 */
pre code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 10px;
  line-height: 1.4;
}

/* JSON 语法高亮 */
.json-key {
  color: #0066cc;
  font-weight: 500;
}

.json-string {
  color: #22863a;
}

.json-number {
  color: #005cc5;
}

.json-boolean {
  color: #d73a49;
}

.json-null {
  color: #6f42c1;
}

/* 平滑滚动 */
html {
  scroll-behavior: smooth;
}

/* 响应式优化 */
@media (max-width: 768px) {
  #config-panel {
    flex-basis: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
  }

  #resizer {
    display: none !important;
  }

  #execution-panel {
    display: none;
  }

  main {
    flex-direction: column;
  }
}

/* 打印样式 */
@media print {
  header,
  #config-panel,
  #resizer,
  button {
    display: none;
  }

  body {
    background: white;
  }

  #execution-panel {
    flex: 1;
  }

  .node-formatted,
  .node-details {
    max-height: none !important;
  }
}
