/**
 * 运行演示样式文件
 * 精美的交互式演示界面设计
 */

/* ========== 演示区域主容器 ========== */
.demo-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 15px;
  padding: 30px;
  margin: 30px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  color: white;
}

.demo-section h2 {
  color: white;
  font-size: 2em;
  margin-bottom: 10px;
  text-align: center;
}

.demo-section .section-intro {
  text-align: center;
  opacity: 0.9;
  margin-bottom: 30px;
}

/* ========== 场景选择器 ========== */
.demo-scenario-selector {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
}

.demo-scenario-selector label {
  font-weight: bold;
  margin-right: 10px;
}

.demo-scenario-selector select {
  padding: 10px 15px;
  border-radius: 5px;
  border: none;
  font-size: 16px;
  background: white;
  color: #2c3e50;
  cursor: pointer;
  min-width: 300px;
}

/* ========== 场景信息卡片 ========== */
.demo-scenario-info {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  color: #2c3e50;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.demo-scenario-info h3 {
  color: #667eea;
  margin: 0 0 10px 0;
  font-size: 1.5em;
  font-weight: bold;
}

.demo-subtitle {
  color: #7f8c8d;
  font-size: 1.1em;
  margin: 0 0 15px 0;
  font-weight: 500;
}

.demo-description {
  line-height: 1.6;
  margin-bottom: 15px;
  color: #34495e;
}

.demo-meta {
  display: flex;
  gap: 20px;
  font-size: 0.9em;
  flex-wrap: wrap;
}

.demo-steps,
.demo-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #f8f9fa;
  border-radius: 20px;
  color: #667eea;
  font-weight: 600;
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.demo-hint {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border: 1px solid rgba(102, 126, 234, 0.2);
}

/* ========== 流程图容器 ========== */
.demo-flow-container {
  background: white;
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
  overflow: visible;
}

.demo-flow-svg {
  min-height: 480px;
  max-width: 100%;
}

/* 提示文字 */
.demo-hint-text {
  text-align: center;
  padding: 15px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
  border-radius: 10px;
  margin-bottom: 20px;
  color: #2c3e50;
  font-size: 1em;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.demo-hint-text i {
  font-size: 1.2em;
  color: #667eea;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* 流程图节点组 */
.flow-node-group {
  transition: all 0.3s ease;
}

/* 节点矩形 */
.node-rect {
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* 节点标签 */
.node-label {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: none;
}

/* 状态指示器 */
.status-indicator {
  transition: all 0.3s ease;
  pointer-events: none;
}

/* 流程图边 */
.flow-edge {
  transition: all 0.5s ease;
}

/* ========== 控制按钮区域 ========== */
.demo-controls {
  display: none; /* 隐藏，不再使用自动播放 */
}

/* ========== 步骤详情区域 ========== */
.demo-step-details {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  padding: 25px;
  color: #2c3e50;
}

.demo-step-title {
  color: #1a1a1a !important;
  font-size: 1.6em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-weight: bold;
}

.step-index {
  font-size: 0.7em;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  margin-left: auto;
}

.demo-step-description {
  font-size: 1.15em;
  margin-bottom: 25px;
  color: #2c3e50;
  line-height: 1.6;
}

/* ========== 代码展示区域 ========== */
.demo-code-container {
  background: linear-gradient(135deg, #1e2227, #282c34);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 25px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  border: 1px solid #3e4451;
}

.code-header {
  background: linear-gradient(135deg, #21252b, #2a2f36);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #4b5362;
}

.code-file {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #abb2bf;
  font-family: 'Courier New', monospace;
  font-size: 0.95em;
  font-weight: 500;
}

.code-file i {
  color: #61afef;
}

.code-function {
  display: flex;
  align-items: center;
  gap: 15px;
}

.function-name {
  color: #e5c07b;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 10px rgba(229, 192, 123, 0.3);
}

.line-number {
  color: #abb2bf;
  font-size: 0.9em;
  font-weight: 500;
}

.code-signature {
  background: #21252b;
  padding: 10px 20px;
  border-bottom: 1px solid #3e4451;
}

.code-signature code {
  color: #98c379;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.code-content-wrapper {
  max-height: 400px;
  overflow-y: auto;
  padding: 20px;
  background: #1e2227;
  border-radius: 8px;
}

.code-content {
  margin: 0;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: #abb2bf;
  white-space: pre;
}

.code-content code {
  color: #abb2bf;
}

/* Prism.js 语法高亮优化 */
.code-content .token.keyword {
  color: #c678dd !important;
  font-weight: bold;
}

.code-content .token.string {
  color: #98c379 !important;
}

.code-content .token.number {
  color: #d19a66 !important;
}

.code-content .token.comment {
  color: #5c6370 !important;
  font-style: italic;
}

.code-content .token.function {
  color: #61afef !important;
}

.code-content .token.operator {
  color: #56b6c2 !important;
}

.code-explanation {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-top: 15px;
  border-left: 4px solid #667eea;
}

.code-explanation h4 {
  color: #667eea;
  margin: 0 0 12px 0;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.explanation-content {
  color: #2c3e50;
  line-height: 1.7;
  font-size: 0.95em;
}

.explanation-content strong {
  color: #667eea;
  font-weight: bold;
}

.emoji {
  font-size: 1.2em;
}

/* ========== 数据流展示 ========== */
.demo-dataflow-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 25px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(248, 249, 250, 0.9), rgba(255, 255, 255, 0.95));
  border-radius: 12px;
  border: 2px solid #e9ecef;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.dataflow-section {
  margin-bottom: 15px;
}

.dataflow-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  border-left: 4px solid #95a5a6;
}

.dataflow-section.previous-output .dataflow-label {
  border-left-color: #3498db;
  color: #2980b9;
  background: rgba(52, 152, 219, 0.1);
}

.dataflow-section.next-input .dataflow-label {
  border-left-color: #2ecc71;
  color: #27ae60;
  background: rgba(46, 204, 113, 0.1);
}

.dataflow-section.final-output .dataflow-label {
  border-left-color: #f39c12;
  color: #d35400;
  background: rgba(243, 156, 18, 0.1);
}

.dataflow-main {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 25px;
  align-items: center;
  padding: 20px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  border: 1px solid #e9ecef;
}

.dataflow-card {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 18px;
  border: 2px solid #e9ecef;
  transition: all 0.3s ease;
}

.dataflow-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  border-color: #667eea;
}

.dataflow-card h4 {
  margin: 0 0 12px 0;
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1em;
  font-weight: 600;
}

.dataflow-card.input {
  border-color: #3498db;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.08), rgba(52, 152, 219, 0.02));
}

.dataflow-card.output {
  border-color: #2ecc71;
  background: linear-gradient(135deg, rgba(46, 204, 113, 0.08), rgba(46, 204, 113, 0.02));
}

.dataflow-json {
  background: white;
  padding: 12px;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.8em;
  color: #2c3e50;
  overflow-x: auto;
  margin: 0;
  border: 1px solid #dee2e6;
  line-height: 1.5;
}

.dataflow-transform {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #95a5a6;
  font-size: 0.85em;
  font-weight: 500;
  text-align: center;
  padding: 10px;
}

.dataflow-transform i {
  font-size: 2.5em;
  color: #667eea;
  animation: rotate 3s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ========== 调用栈展示 ========== */
.demo-callstack-container {
  background: linear-gradient(135deg, rgba(248, 249, 250, 0.9), rgba(255, 255, 255, 0.95));
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 25px;
  border: 2px solid #e9ecef;
}

.demo-callstack-container h4 {
  color: #2c3e50;
  margin: 0 0 15px 0;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.callstack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.callstack-item {
  background: white;
  border-left: 4px solid #667eea;
  padding: 12px 15px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.callstack-item:hover {
  transform: translateX(5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.callstack-level {
  color: #667eea;
  font-size: 0.8em;
  font-weight: bold;
  margin-bottom: 5px;
}

.callstack-method {
  color: #2c3e50;
  font-weight: 600;
  font-size: 0.95em;
  margin-bottom: 3px;
  font-family: 'Courier New', monospace;
}

.callstack-file {
  color: #7f8c8d;
  font-size: 0.85em;
}

/* ========== 教学提示 ========== */
.demo-tips-container {
  background: linear-gradient(135deg, rgba(255, 249, 230, 0.9), rgba(255, 255, 255, 0.95));
  border-radius: 12px;
  padding: 20px;
  border: 2px solid #f1c40f;
  box-shadow: 0 4px 15px rgba(241, 196, 15, 0.15);
}

.demo-tips-container h4 {
  color: #f39c12;
  margin: 0 0 15px 0;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.tips-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tips-list li {
  padding: 10px 0;
  padding-left: 28px;
  position: relative;
  color: #2c3e50;
  line-height: 1.7;
  font-size: 0.95em;
}

.tips-list li:before {
  content: "💡";
  position: absolute;
  left: 0;
  top: 10px;
  font-size: 1.1em;
}

/* ========== 响应式设计 ========== */
@media (max-width: 1024px) {
  .demo-flow-svg {
    min-height: 600px;
  }
  
  .dataflow-main {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .dataflow-transform {
    flex-direction: row;
    justify-content: center;
    padding: 15px;
  }
  
  .dataflow-transform i {
    font-size: 2em;
    animation: none;
  }
  
  .dataflow-label {
    font-size: 0.85em;
  }
}

@media (max-width: 768px) {
  .demo-section {
    padding: 20px;
  }
  
  .demo-section h2 {
    font-size: 1.5em;
  }
  
  .demo-scenario-info {
    padding: 15px;
  }
  
  .demo-scenario-info h3 {
    font-size: 1.3em;
  }
  
  .demo-flow-container {
    padding: 15px;
    overflow-x: auto;
  }
  
  .demo-step-title {
    font-size: 1.3em;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .step-index {
    margin-left: 0;
    margin-top: 5px;
  }
  
  .code-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
  
  .dataflow-main {
    padding: 10px;
  }
  
  .dataflow-json {
    font-size: 0.7em;
  }
}

/* ========== 代码高亮主题覆盖 ========== */
code[class*="language-"],
pre[class*="language-"] {
  text-shadow: none !important;
}

.token.comment,
.token.block-comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #5c6370 !important;
}

.token.punctuation {
  color: #abb2bf !important;
}

.token.property,
.token.number,
.token.boolean {
  color: #d19a66 !important;
}

.token.tag,
.token.selector,
.token.function {
  color: #e06c75 !important;
}

.token.keyword {
  color: #c678dd !important;
}

.token.string,
.token.char {
  color: #98c379 !important;
}

.token.operator {
  color: #56b6c2 !important;
}

.token.class-name {
  color: #e5c07b !important;
}

/* ========== 滚动条美化 ========== */
.code-content-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.code-content-wrapper::-webkit-scrollbar-track {
  background: #282c34;
  border-radius: 4px;
}

.code-content-wrapper::-webkit-scrollbar-thumb {
  background: #3e4451;
  border-radius: 4px;
}

.code-content-wrapper::-webkit-scrollbar-thumb:hover {
  background: #4b5362;
}
