/* Mermaid图表主题样式
 * 支持亮色/暗色主题切换
 */

/* 图表容器样式 */
.mermaid-figure {
  margin: 2rem auto;
  display: flex;
  justify-content: center;
  width: 100%;
  overflow-x: auto;
}

.mermaid-svg-container {
  display: flex;
  justify-content: center;
  width: 100%;
  max-height: 80vh; /* 限制容器最大高度为视窗高度的80% */
}

/* 错误信息样式 */
.mermaid-error-message {
  color: #e53e3e;
  padding: 1rem;
  border: 1px dashed #e53e3e;
  border-radius: 0.5rem;
  margin: 1rem 0;
  text-align: center;
}

/* 基础样式 - 亮色主题 */
.mermaid-svg {
  /* 全局图表容器样式 */
  max-width: 100%;
  height: auto !important; /* 强制高度为自动，覆盖内联样式 */
  max-height: 80vh; /* 限制最大高度为视窗高度的80% */
  width: auto; /* 允许宽度自适应内容 */
  overflow: visible;
  /* 移除背景色，使用透明背景 */
  background-color: transparent;
}

/* 节点样式 */
.mermaid-svg .node rect,
.mermaid-svg .node circle,
.mermaid-svg .node ellipse,
.mermaid-svg .node polygon,
.mermaid-svg .node path {
  fill: #f8fafc;
  stroke: #94a3b8;
  stroke-width: 1px;
}

/* 基本填充和背景色 */
.mermaid-svg .basic {
  fill: #f8fafc;
  stroke: #94a3b8;
}

.mermaid-svg .labelBkg {
  background-color: transparent;
}

/* 集群样式 */
.mermaid-svg .cluster rect {
  fill: #f1f5f9;
  stroke: #cbd5e1;
  stroke-width: 1px;
}

/* 边标签样式 */
.mermaid-svg .edgeLabel rect {
  fill: transparent;
  background-color: transparent;
}

/* 文本样式 */
.mermaid-svg text {
  fill: #334155;
  font-family: var(--font-sans);
}

.mermaid-svg .label {
  color: #334155;
  background-color: transparent;
}

.mermaid-svg .nodeLabel {
  color: #334155;
  background-color: transparent;
}

.mermaid-svg .cluster text {
  fill: #475569;
}

/* 连线样式 */
.mermaid-svg .edgePath .path {
  stroke: #94a3b8;
  stroke-width: 1.5px;
}

.mermaid-svg .flowchart-link {
  stroke: #94a3b8;
  fill: none;
}

.mermaid-svg marker {
  fill: #94a3b8;
}

/* 箭头路径 */
.mermaid-svg .arrowMarkerPath {
  fill: #94a3b8;
  stroke: #94a3b8;
}

/* 特殊节点样式 */
.mermaid-svg .node.clickable {
  cursor: pointer;
}

.mermaid-svg .node.clickable:hover rect,
.mermaid-svg .node.clickable:hover circle,
.mermaid-svg .node.clickable:hover ellipse,
.mermaid-svg .node.clickable:hover polygon {
  stroke-width: 2px;
  opacity: 0.9;
}

/* ======= 暗色主题样式 ======= */
[data-theme="dark"] .mermaid-svg {
  background-color: transparent;
}

[data-theme="dark"] .mermaid-svg .node rect,
[data-theme="dark"] .mermaid-svg .node circle,
[data-theme="dark"] .mermaid-svg .node ellipse,
[data-theme="dark"] .mermaid-svg .node polygon,
[data-theme="dark"] .mermaid-svg .node path {
  fill: #1e293b;
  stroke: #475569;
}

[data-theme="dark"] .mermaid-svg .basic {
  fill: #1e293b;
  stroke: #475569;
}

[data-theme="dark"] .mermaid-svg .labelBkg {
  background-color: transparent;
}

[data-theme="dark"] .mermaid-svg .cluster rect {
  fill: #0f172a;
  stroke: #334155;
}

[data-theme="dark"] .mermaid-svg .edgeLabel rect {
  fill: transparent;
  background-color: transparent;
}

[data-theme="dark"] .mermaid-svg text {
  fill: #e2e8f0;
}

[data-theme="dark"] .mermaid-svg .label {
  color: #e2e8f0;
  background-color: transparent;
}

[data-theme="dark"] .mermaid-svg .nodeLabel {
  color: #e2e8f0;
  background-color: transparent;
}

[data-theme="dark"] .mermaid-svg .cluster text {
  fill: #cbd5e1;
}

[data-theme="dark"] .mermaid-svg .edgePath .path {
  stroke: #64748b;
}

[data-theme="dark"] .mermaid-svg .flowchart-link {
  stroke: #64748b;
}

[data-theme="dark"] .mermaid-svg marker {
  fill: #64748b;
}

[data-theme="dark"] .mermaid-svg .arrowMarkerPath {
  fill: #64748b;
  stroke: #64748b;
}

/* 序列图特殊样式 */
[data-theme="dark"] .mermaid-svg .actor {
  fill: #334155 !important;
}

[data-theme="dark"] .mermaid-svg .messageLine0 {
  stroke: #94a3b8 !important;
}

[data-theme="dark"] .mermaid-svg .messageLine1 {
  stroke: #94a3b8 !important;
}

[data-theme="dark"] .mermaid-svg #arrowhead path {
  fill: #94a3b8 !important;
}

/* 甘特图特殊样式 */
[data-theme="dark"] .mermaid-svg .section0 {
  fill: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .mermaid-svg .section1,
[data-theme="dark"] .mermaid-svg .section2 {
  fill: rgba(255, 255, 255, 0.07) !important;
}

[data-theme="dark"] .mermaid-svg .task0,
[data-theme="dark"] .mermaid-svg .task1,
[data-theme="dark"] .mermaid-svg .task2,
[data-theme="dark"] .mermaid-svg .task3 {
  fill: #1e3a8a !important;
}
