/* ==================== 股权大屏科技感样式（纯 Alpine.js + CSS 实现） ==================== */

/* ============ 1. 树形容器 ============ */

.tree-container {
  width: 100%;
  min-height: calc(100vh - 120px);
  background: transparent;
  overflow-x: auto;
  overflow-y: visible;
  padding: 40px 20px;
}

/* ============ 2. 节点卡片基础样式 ============ */

.tree-node {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  border: 2px solid #3b82f6;
  box-shadow:
    0 0 20px rgba(59, 130, 246, 0.5),
    inset 0 0 30px rgba(59, 130, 246, 0.1);
  border-radius: 8px;
  padding: 0;
  min-width: 180px;
  min-height: 80px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.tree-node:hover {
  box-shadow:
    0 0 30px rgba(59, 130, 246, 0.8),
    0 0 50px rgba(59, 130, 246, 0.4),
    inset 0 0 30px rgba(59, 130, 246, 0.15);
  transform: translateY(-3px) scale(1.02);
  border-color: #60a5fa;
}

/* 卡片内容 */
.equity-card {
  padding: 16px 12px;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 紧凑模式（子公司） */
.equity-card.compact {
  padding: 12px 8px;
  min-height: 60px;
}

/* 卡片标题 */
.card-title {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
  line-height: 1.4;
  word-break: break-all;
}

/* 控股比例显示 */
.card-holding {
  color: #fbbf24;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin: 4px 0;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
}

/* 卡片类型标签 */
.card-type {
  color: #93c5fd;
  font-size: 11px;
  text-align: center;
  padding: 2px 8px;
  background: rgba(147, 197, 253, 0.15);
  border-radius: 4px;
  border: 1px solid rgba(147, 197, 253, 0.3);
}

/* ============ 3. 徽章样式 ============ */

.node-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: #ffffff;
  z-index: 10;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

/* 蓝色徽章 */
.badge-blue {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: 2px solid #60a5fa;
  box-shadow:
    0 0 15px rgba(59, 130, 246, 0.6),
    0 0 30px rgba(59, 130, 246, 0.3);
}

/* 黄色徽章（高亮企业，如安琪酵母） */
.badge-yellow {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border: 2px solid #fbbf24;
  box-shadow:
    0 0 15px rgba(245, 158, 11, 0.6),
    0 0 30px rgba(245, 158, 11, 0.3);
  animation: pulse-yellow 2s ease-in-out infinite;
}

/* 黄色徽章脉冲动画 */
@keyframes pulse-yellow {
  0%, 100% {
    box-shadow:
      0 0 15px rgba(245, 158, 11, 0.6),
      0 0 30px rgba(245, 158, 11, 0.3);
  }
  50% {
    box-shadow:
      0 0 25px rgba(245, 158, 11, 0.8),
      0 0 40px rgba(245, 158, 11, 0.5);
  }
}

/* ============ 4. 高亮节点 ============ */

.highlight-node {
  border-color: #fbbf24 !important;
  box-shadow:
    0 0 25px rgba(251, 191, 36, 0.6),
    inset 0 0 30px rgba(251, 191, 36, 0.1) !important;
}

.highlight-node:hover {
  box-shadow:
    0 0 35px rgba(251, 191, 36, 0.8),
    0 0 60px rgba(251, 191, 36, 0.5),
    inset 0 0 30px rgba(251, 191, 36, 0.15) !important;
}

/* ============ 5. 根节点特殊样式（国资委） ============ */

.root-node {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
  border-color: #a78bfa !important;
  box-shadow:
    0 0 30px rgba(167, 139, 250, 0.6),
    inset 0 0 30px rgba(167, 139, 250, 0.1) !important;
  min-height: 100px !important;
  min-width: 220px !important;
}

.root-node:hover {
  box-shadow:
    0 0 40px rgba(167, 139, 250, 0.8),
    0 0 60px rgba(167, 139, 250, 0.5),
    inset 0 0 30px rgba(167, 139, 250, 0.15) !important;
}

.root-node .card-title {
  font-size: 16px;
  font-weight: 700;
}

/* ============ 6. 连接线样式（纯 CSS） ============ */

/* 根节点向下的垂直线 */
.connection-line-vertical {
  width: 2px;
  height: 60px;
  background: linear-gradient(180deg, #a78bfa 0%, rgba(167, 139, 250, 0.5) 100%);
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.8);
  margin: 0 auto;
}

/* 集团向上的连接线 */
.connection-line-up {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 60px;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.3) 0%, #3b82f6 100%);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
}

/* 水平连接线（第1层5个集团之间） */
.tree-level-1::before {
  content: '';
  position: absolute;
  top: -60px;
  left: 15%;
  right: 15%;
  height: 2px;
  background: linear-gradient(90deg,
    rgba(59, 130, 246, 0.3) 0%,
    #3b82f6 20%,
    #3b82f6 80%,
    rgba(59, 130, 246, 0.3) 100%
  );
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
}

/* 节点向下的连接线 */
.connection-line-down {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 48px;
  background: linear-gradient(180deg, #3b82f6 0%, rgba(59, 130, 246, 0.5) 100%);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
  z-index: -1;
}

/* ============ 7. 展开/折叠按钮 ============ */

.toggle-btn {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
  border: 2px solid #3b82f6;
  color: #ffffff;
  font-size: 18px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
  z-index: 10;
}

.toggle-btn:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  border-color: #60a5fa;
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.9);
  transform: translateX(-50%) scale(1.15);
}

.toggle-btn:active {
  transform: translateX(-50%) scale(0.95);
}

/* 展开状态的按钮 */
.toggle-btn.expanded {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  border-color: #a78bfa;
  box-shadow: 0 0 15px rgba(167, 139, 250, 0.6);
}

.toggle-btn.expanded:hover {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  box-shadow: 0 0 25px rgba(167, 139, 250, 0.9);
}

/* ============ 8. 节点尺寸变体 ============ */

.group-node {
  min-width: 180px;
  min-height: 80px;
}

.mid-node {
  min-width: 180px;
  min-height: 80px;
}

.sub-node {
  min-width: 140px;
  min-height: 60px;
}

/* ============ 9. 弹窗样式 ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid #3b82f6;
  box-shadow:
    0 0 40px rgba(59, 130, 246, 0.6),
    inset 0 0 60px rgba(59, 130, 246, 0.05);
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  padding: 32px;
}

.modal-title {
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #3b82f6;
  display: flex;
  align-items: center;
}

.modal-title::before {
  content: '';
  width: 4px;
  height: 24px;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  margin-right: 12px;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
}

.close-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #1e40af;
  border: 2px solid #3b82f6;
  color: #ffffff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.close-btn:hover {
  background-color: #2563eb;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
  transform: rotate(90deg) scale(1.1);
}

/* 信息区块 */
.info-section {
  margin-bottom: 24px;
}

.info-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: #60a5fa;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.info-grid > div {
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.6;
}

.info-grid > div > span {
  color: #ffffff;
  font-weight: 500;
}

/* ============ 10. 滚动条样式 ============ */

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: rgba(59, 130, 246, 0.1);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
}

/* ============ 11. 响应式适配 ============ */

@media (max-width: 1280px) {
  .tree-node {
    min-width: 160px;
  }

  .card-title {
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .tree-node {
    min-width: 140px;
    min-height: 70px;
  }

  .card-title {
    font-size: 12px;
  }

  .card-type {
    font-size: 10px;
  }

  .modal-content {
    padding: 24px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .tree-level-1 {
    flex-wrap: wrap;
  }
}

/* ============ 12. 长文本换行 ============ */

.text-wrap {
  word-wrap: break-word;
  word-break: break-all;
  white-space: normal;
}

/* ============ 13. 过渡动画 ============ */

/* Alpine.js x-transition 会自动处理大部分动画 */
/* 这里只需要定义一些补充的过渡效果 */

.tree-level-2,
.tree-level-3 {
  animation: fadeInDown 0.3s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============ 14. Mermaid.js 节点样式覆盖 ============ */

/* Mermaid SVG 容器 */
.mermaid-container svg {
  filter: drop-shadow(0 0 30px rgba(59, 130, 246, 0.3));
}

/* Mermaid 节点（默认） */
.mermaid-container .node rect,
.mermaid-container .node polygon,
.mermaid-container .node circle {
  fill: #1e40af !important;
  stroke: #3b82f6 !important;
  stroke-width: 2px !important;
  filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.6));
  transition: all 0.3s ease;
}

/* 节点悬停效果 */
.mermaid-container .node:hover rect,
.mermaid-container .node:hover polygon,
.mermaid-container .node:hover circle {
  fill: #2563eb !important;
  stroke: #60a5fa !important;
  filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.9));
  transform: scale(1.05);
}

/* 根节点样式 */
.mermaid-container .rootNode rect,
.mermaid-container .rootNode polygon {
  fill: #7c3aed !important;
  stroke: #a78bfa !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.8));
}

.mermaid-container .rootNode:hover rect,
.mermaid-container .rootNode:hover polygon {
  fill: #8b5cf6 !important;
  stroke: #c4b5fd !important;
  filter: drop-shadow(0 0 30px rgba(167, 139, 250, 1));
}

/* 高亮节点（黄色，如安琪酵母） */
.mermaid-container .highlightNode rect,
.mermaid-container .highlightNode polygon {
  fill: #d97706 !important;
  stroke: #fbbf24 !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.8));
  animation: pulse-highlight 2s ease-in-out infinite;
}

@keyframes pulse-highlight {
  0%, 100% {
    filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.8));
  }
  50% {
    filter: drop-shadow(0 0 30px rgba(251, 191, 36, 1));
  }
}

/* 节点文本 */
.mermaid-container .nodeLabel {
  color: #ffffff !important;
  font-weight: 600 !important;
  font-size: 14px !important;
}

.mermaid-container .nodeLabel b {
  font-weight: 700 !important;
  color: #ffffff !important;
}

/* 连接线 */
.mermaid-container .flowchart-link {
  stroke: #3b82f6 !important;
  stroke-width: 2px !important;
  stroke-dasharray: 5, 5 !important;
  filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.6));
}

/* 箭头 */
.mermaid-container .arrowheadPath {
  fill: #3b82f6 !important;
  stroke: #3b82f6 !important;
}

/* 连接线标签（控股比例） */
.mermaid-container .edgeLabel {
  background-color: rgba(30, 41, 59, 0.95) !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  border: 1px solid #fbbf24 !important;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.5) !important;
}

.mermaid-container .edgeLabel span {
  color: #fbbf24 !important;
  font-weight: 600 !important;
  font-size: 12px !important;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.8) !important;
}

/* 集群/分组背景 */
.mermaid-container .cluster rect {
  fill: rgba(30, 64, 175, 0.1) !important;
  stroke: #3b82f6 !important;
  stroke-width: 1px !important;
  stroke-dasharray: 5 5 !important;
}

/* 标签背景 */
.mermaid-container .label-container {
  background: transparent !important;
}

/* 节点内边距调整 */
.mermaid-container .node > rect {
  rx: 8px !important;
  ry: 8px !important;
}

/* 外部展开/折叠按钮 */
.external-toggle-btn {
  z-index: 100;
}

.toggle-btn-external:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.9) !important;
  transform: scale(1.15);
}
