/* Mermaid 图表样式 */
.mermaid-container {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 15px;
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* 强制 Mermaid 使用浅色背景 */
.mermaid-container .mermaid svg,
.mermaid .mermaid svg {
  background: transparent !important;
  fill: #333 !important;
}

.mermaid-container .mermaid .labelText,
.mermaid-container .mermaid .labelText tspan,
.mermaid .mermaid .labelText,
.mermaid .mermaid .labelText tspan {
  fill: #333 !important;
}

.mermaid-container .mermaid .node rect,
.mermaid-container .mermaid .node circle,
.mermaid-container .mermaid .node ellipse,
.mermaid-container .mermaid .node polygon {
  fill: #fff !important;
  stroke: #667eea !important;
}

.mermaid-container .mermaid .edgeLabel {
  background-color: #fff !important;
  color: #333 !important;
}

.mermaid-container .mermaid .edgePath .path {
  stroke: #667eea !important;
}

.mermaid-container .mermaid .arrowheadPath {
  fill: #667eea !important;
}

.mermaid-container .mermaid .cluster rect {
  fill: #f8f9fa !important;
  stroke: #dee2e6 !important;
}

.mermaid-container .mermaid .cluster text {
  fill: #333 !important;
}

.mermaid {
  display: flex;
  justify-content: center;
  font-family: 'Roboto', sans-serif;
}

/* 流程图节点样式 */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon {
  stroke-width: 2px;
  stroke: #3498db;
}

.mermaid .node .label {
  font-weight: 500;
  font-size: 14px;
}

/* 边的样式 */
.mermaid .edgePath .path {
  stroke: #2c3e50;
  stroke-width: 2px;
}

.mermaid .arrowheadPath {
  fill: #2c3e50;
}

/* 暗色模式支持 - 保持浅色背景 */
@media (prefers-color-scheme: dark) {
  .mermaid-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  }

  .mermaid .node rect,
  .mermaid .node circle,
  .mermaid .node ellipse,
  .mermaid .node polygon {
    stroke: #667eea;
    fill: #fff !important;
  }

  .mermaid .edgePath .path {
    stroke: #667eea;
  }

  .mermaid .arrowheadPath {
    fill: #667eea;
  }
}

/* 交互式图表容器 */
.interactive-diagram {
  position: relative;
  margin: 2rem 0;
}

.diagram-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.diagram-controls button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 5px;
  background: #3498db;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.diagram-controls button:hover {
  background: #2980b9;
  transform: translateY(-2px);
}

.diagram-controls button.active {
  background: #27ae60;
}

/* 表格增强样式 */
.table-comparison {
  margin: 2rem 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.table-comparison thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.table-comparison thead th {
  border: none;
  padding: 1rem 1.25rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.table-comparison thead th .material-icons {
  margin-right: 4px;
  vertical-align: text-bottom;
}

.table-comparison tbody tr {
  transition: all 0.3s ease;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.table-comparison tbody tr:hover {
  background: linear-gradient(90deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  transform: scale(1.005);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.table-comparison tbody td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  border: none;
  color: #333;
}

.table-comparison tbody td strong {
  color: #667eea;
  font-weight: 600;
  font-size: 1.05rem;
}

/* 表格中的 code 样式 */
.table-comparison tbody td code {
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
  color: #e83e8c;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* 表格中的 badge 样式 */
.table-comparison tbody td .badge {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.85rem;
}

/* 斑马纹效果 */
.table-comparison tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

.table-comparison tbody tr:nth-of-type(even) {
  background-color: rgba(255, 255, 255, 0.5);
}

/* 第一列强调 */
.table-comparison tbody td:first-child {
  border-left: 3px solid #667eea;
  font-weight: 500;
}

/* 暗色模式支持 - 保持浅色背景 */
@media (prefers-color-scheme: dark) {
  .table-comparison {
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .table-comparison thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }

  .table-comparison tbody tr {
    border-bottom-color: rgba(0, 0, 0, 0.05);
  }

  .table-comparison tbody td {
    color: #333;
  }

  .table-comparison tbody td strong {
    color: #667eea;
  }

  .table-comparison tbody td code {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    color: #e83e8c;
    border-color: rgba(0, 0, 0, 0.08);
  }

  .table-comparison tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
  }

  .table-comparison tbody tr:nth-of-type(even) {
    background-color: rgba(255, 255, 255, 0.5);
  }

  .table-comparison tbody tr:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  }

  .table-comparison tbody td:first-child {
    border-left-color: #667eea;
  }
}

/* 序列图样式 */
.sequence-diagram-container {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 15px;
  padding: 2rem;
  margin: 2rem 0;
  overflow-x: auto;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Mermaid 序列图内部样式覆盖 */
.sequence-diagram-container .mermaid svg {
  background: transparent !important;
}

.sequence-diagram-container .mermaid .actor {
  fill: #667eea !important;
  stroke: #764ba2 !important;
}

.sequence-diagram-container .mermaid .actor-line {
  stroke: #667eea !important;
}

.sequence-diagram-container .mermaid .messageLine0 {
  stroke: #667eea !important;
}

.sequence-diagram-container .mermaid .messageLine1 {
  stroke: #667eea !important;
}

.sequence-diagram-container .mermaid .note {
  fill: #fff3cd !important;
  stroke: #ffc107 !important;
}

.sequence-diagram-container .mermaid .noteText {
  fill: #856404 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

.sequence-diagram-container .mermaid text {
  fill: #333 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

.sequence-diagram-container .mermaid .labelText,
.sequence-diagram-container .mermaid .labelText tspan {
  fill: #333 !important;
}

.sequence-diagram-container .mermaid .labelBox {
  fill: #e3f2fd !important;
  stroke: #667eea !important;
}

@media (prefers-color-scheme: dark) {
  .sequence-diagram-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  }
  
  /* 暗色模式下仍然保持浅色图表 */
  .mermaid-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: rgba(0, 0, 0, 0.1);
  }
  
  .mermaid-container .mermaid .node rect,
  .mermaid-container .mermaid .node circle,
  .mermaid-container .mermaid .node ellipse,
  .mermaid-container .mermaid .node polygon {
    fill: #fff !important;
  }
  
  .mermaid-container .mermaid .edgeLabel {
    background-color: #fff !important;
    color: #333 !important;
  }
  
  .mermaid-container .mermaid .cluster rect {
    fill: #f8f9fa !important;
  }
  
  .mermaid-container .mermaid .cluster text {
    fill: #333 !important;
  }
}

/* 可折叠图表区域 */
.collapsible-diagram {
  border: 1px solid #dee2e6;
  border-radius: 10px;
  margin: 1.5rem 0;
  overflow: hidden;
}

.collapsible-diagram .diagram-header {
  background: #f8f9fa;
  padding: 1rem 1.5rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.collapsible-diagram .diagram-header:hover {
  background: #e9ecef;
}

.collapsible-diagram .diagram-header h5 {
  margin: 0;
  font-weight: 600;
}

.collapsible-diagram .diagram-body {
  padding: 1.5rem;
  background: #fff;
}

/* 暗色模式下保持浅色背景 */
@media (prefers-color-scheme: dark) {
  .collapsible-diagram {
    border-color: rgba(0, 0, 0, 0.1);
  }

  .collapsible-diagram .diagram-header {
    background: #f8f9fa;
  }

  .collapsible-diagram .diagram-header:hover {
    background: #e9ecef;
  }

  .collapsible-diagram .diagram-body {
    background: #fff;
  }
}

/* 图表说明框 */
.diagram-legend {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 5px;
}

/* 饼图图例样式 */
.legend-item {
  transition: all 0.3s ease;
}

.legend-item:hover {
  transform: translateX(5px);
}

.legend-item p {
  font-size: 0.85rem;
  line-height: 1.4;
}

/* 饼图容器样式 */
.mermaid .pieCircle {
  stroke: #fff !important;
  stroke-width: 2px !important;
}

.mermaid .pieTitleText {
  fill: #333 !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

.mermaid .slice text {
  fill: #fff !important;
  font-weight: 600 !important;
  font-size: 14px !important;
}

.diagram-legend h6 {
  margin-bottom: 0.5rem;
  color: #856404;
}

.diagram-legend p {
  margin: 0;
  color: #856404;
}

@media (prefers-color-scheme: dark) {
  .diagram-legend {
    background: #fff3cd;
    border-left-color: #ffc107;
  }

  .diagram-legend h6,
  .diagram-legend p {
    color: #856404;
  }
}

/* 覆盖卡片样式 - 减少白色背景 */
.card {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 15px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.card-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom: none;
  font-weight: 600;
  padding: 1.25rem 1.5rem;
}

.card-header h4,
.card-header h4 .material-icons {
  color: white !important;
}

.card-header .material-icons {
  vertical-align: middle;
  margin-right: 8px;
}

.card-body {
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.95);
}

/* Section 背景样式 */
section.py-5:not(.bg-gradient):not(.bg-light) {
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
}

/* 暗色模式下的卡片 - 保持浅色背景 */
@media (prefers-color-scheme: dark) {
  .card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-color: rgba(0, 0, 0, 0.08);
  }
  
  .card-body {
    background: rgba(255, 255, 255, 0.95);
  }
}
