/* 时空能量·易经本义 - 思维导图样式 */

/* === CSS变量 === */
:root {
  --bg: #0a0f14;
  --bg2: #0e1419;
  --card: #111920;
  --card2: #162028;
  --border: #1a2533;
  --text: #e8dcc8;
  --text2: #8a9fb0;
  --text3: #5a6a7a;
  --gold: #c9a84c;
  --gold-dim: #8a7030;
  --wood: #4a9e5c;
  --wood-dim: #2a6e3c;
  --fire: #c94a4a;
  --fire-dim: #8a2a2a;
  --earth: #a08040;
  --metal: #7a9ab8;
  --water: #4a7a9a;
  --shadow: rgba(0,0,0,0.5);
  --glow-gold: rgba(201,168,76,0.3);
  --glow-wood: rgba(74,158,92,0.3);
  --glow-fire: rgba(201,74,74,0.3);
  --radius: 12px;
  --transition: 0.3s ease;
}

/* === 全局 === */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { 
  height: 100%; 
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* === 布局 === */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* === 侧边栏 === */
#sidebar {
  width: 320px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
}

#sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

#book-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 4px;
}

#book-subtitle {
  font-size: 12px;
  color: var(--text2);
}

/* === 搜索 === */
#search-box {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

#search-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

#search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--glow-gold);
}

#search-input::placeholder {
  color: var(--text3);
}

/* === 导航 === */
#nav-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  margin-bottom: 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--card);
}

.nav-item.active {
  background: var(--card2);
  border-color: var(--border);
}

.nav-item.gold { border-left: 3px solid var(--gold); }
.nav-item.wood { border-left: 3px solid var(--wood); }
.nav-item.fire { border-left: 3px solid var(--fire); }
.nav-item.gray { border-left: 3px solid var(--text3); }

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 10px;
  flex-shrink: 0;
}

.nav-dot.gold { background: var(--gold); }
.nav-dot.wood { background: var(--wood); }
.nav-dot.fire { background: var(--fire); }
.nav-dot.gray { background: var(--text3); }

.nav-label {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item.active .nav-label {
  color: var(--gold);
}

/* === 主视图 === */
#main {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  background-image: 
    radial-gradient(circle at 20% 20%, rgba(201,168,76,0.03) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(201,74,74,0.03) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(74,158,92,0.02) 0%, transparent 50%);
}

#canvas-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#mindmap-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#mindmap-svg:active {
  cursor: grabbing;
}

/* === 控制栏 === */
#controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
  z-index: 50;
}

.ctrl-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.ctrl-btn:hover {
  background: var(--card2);
  color: var(--text);
  border-color: var(--gold);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

/* === 详情面板 === */
#detail-panel {
  position: absolute;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100%;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 200;
  transition: right 0.4s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px var(--shadow);
}

#detail-panel.open {
  right: 0;
}

#detail-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#detail-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gold);
}

#detail-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

#detail-close:hover {
  background: var(--card);
  color: var(--text);
}

#detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

#detail-content::-webkit-scrollbar {
  width: 6px;
}

#detail-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#detail-content::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

/* === 详情内容样式 === */
.detail-content h3 {
  font-size: 15px;
  color: var(--gold);
  margin: 16px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.detail-content h3:first-child {
  margin-top: 0;
}

.detail-content h4 {
  font-size: 13px;
  color: var(--text);
  margin: 12px 0 6px;
}

.detail-content p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text2);
  margin-bottom: 8px;
}

.detail-content ul, .detail-content ol {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text2);
  padding-left: 18px;
  margin-bottom: 8px;
}

.detail-content li {
  margin-bottom: 4px;
}

.detail-content strong {
  color: var(--text);
  font-weight: 500;
}

/* 可点击链接样式 - 用于天干等可跳转项目 */
.detail-content a {
  color: var(--gold);
  text-decoration: none;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(201, 168, 76, 0.1);
  transition: all 0.2s ease;
  cursor: pointer;
  font-weight: 500;
}

.detail-content a:hover {
  background: rgba(201, 168, 76, 0.25);
  color: #e8c860;
  text-decoration: underline;
}

.detail-content pre {
  background: var(--card);
  padding: 12px;
  border-radius: 8px;
  font-family: "Consolas", monospace;
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  margin: 8px 0;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0;
}

.detail-table th {
  background: var(--card);
  color: var(--gold);
  padding: 8px 6px;
  text-align: left;
  border: 1px solid var(--border);
  font-weight: 500;
}

.detail-table td {
  padding: 6px;
  border: 1px solid var(--border);
  color: var(--text2);
}

.detail-table tr:hover td {
  background: var(--card);
}

/* === SVG节点样式 === */
.node-group {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.node-group:hover {
  transform: scale(1.05);
}

.node-circle {
  transition: all 0.3s ease;
}

.node-group:hover .node-circle {
  filter: brightness(1.2);
}

.node-label {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  fill: var(--text);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.node-label.title {
  font-size: 14px;
  font-weight: 600;
}

.node-label.subtitle {
  font-size: 10px;
  fill: var(--text2);
}

.node-label.small {
  font-size: 11px;
}

/* === 边缘发光 === */
.glow-gold { filter: drop-shadow(0 0 8px var(--glow-gold)); }
.glow-wood { filter: drop-shadow(0 0 8px var(--glow-wood)); }
.glow-fire { filter: drop-shadow(0 0 8px var(--glow-fire)); }

/* === 高亮状态 === */
.highlight .node-circle {
  stroke-width: 3;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* === 缩放指示器 === */
#zoom-indicator {
  position: absolute;
  bottom: 20px;
  left: 20px;
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text2);
  z-index: 50;
}

/* === 提示 === */
#tooltip {
  position: fixed;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
  max-width: 200px;
  box-shadow: 0 4px 12px var(--shadow);
}

#tooltip.show {
  opacity: 1;
}

/* === 移动端适配 === */
@media (max-width: 768px) {
  #sidebar {
    position: absolute;
    left: -320px;
    width: 280px;
    transition: left 0.3s ease;
  }
  
  #sidebar.open {
    left: 0;
    z-index: 300;
  }
  
  #menu-toggle {
    display: flex;
  }
  
  #detail-panel {
    width: 100%;
    right: -100%;
  }
  
  #controls {
    bottom: 80px;
  }
}

/* === 移动端菜单按钮 === */
#menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 400;
}

/* === 加载动画 === */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text2);
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 10px;
}

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

/* === 空状态 === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text3);
  text-align: center;
  padding: 20px;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
}

/* === 章节列表样式 === */
.chapter-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.chapter-list li {
  margin-bottom: 8px;
  padding: 0;
}

.chapter-link {
  display: block;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
  position: relative;
}

.chapter-link::before {
  content: "▸";
  margin-right: 8px;
  color: var(--gold-dim);
  transition: transform 0.2s ease;
}

.chapter-link:hover {
  background: var(--card2);
  border-color: var(--gold-dim);
  color: var(--text);
  transform: translateX(4px);
}

.chapter-link:hover::before {
  color: var(--gold);
  transform: translateX(2px);
}

/* === 章节导航样式 === */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.chapter-nav-chapter {
  margin-top: 12px;
  padding-top: 12px;
}

.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.25s ease;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--card2);
  border-color: var(--gold-dim);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-prev {
  justify-content: flex-start;
}

.nav-next {
  justify-content: flex-end;
  text-align: right;
}

.nav-icon {
  font-size: 16px;
  color: var(--gold-dim);
  transition: transform 0.2s ease;
}

.nav-btn:hover .nav-icon {
  color: var(--gold);
}

.nav-prev:hover .nav-icon {
  transform: translateX(-3px);
}

.nav-next:hover .nav-icon {
  transform: translateX(3px);
}

.nav-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

/* 响应式：小屏幕时导航按钮堆叠 */
@media (max-width: 500px) {
  .chapter-nav {
    flex-direction: column;
  }

  .nav-title {
    max-width: 100%;
  }
}

/* === 内容阅读区样式 === */
#content-display {
  color: var(--text);
  line-height: 1.9;
  font-size: 15px;
}

#content-display h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

#content-display h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 32px 0 16px;
}

.content-section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 28px 0 14px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.15), transparent);
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0;
}

.content-text {
  margin-bottom: 16px;
  text-align: justify;
}

.content-quote {
  padding: 16px 20px;
  margin: 20px 0;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(180, 140, 40, 0.05));
  border-left: 4px solid var(--gold);
  border-radius: 0 10px 10px 0;
  font-style: italic;
  color: var(--text2);
}

.content-list {
  margin: 16px 0;
  padding-left: 24px;
}

.content-list li {
  margin-bottom: 10px;
  position: relative;
}

.content-list li::marker {
  color: var(--gold);
}

/* 对比框 */
.content-comparison {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin: 20px 0;
}

.comparison-item {
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.comparison-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.comparison-content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text2);
}

/* 阴阳对比 */
.content-yinyang {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin: 20px 0;
}

.yin-box, .yang-box {
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.yin-box {
  border-top: 3px solid #6b8cce;
}

.yang-box {
  border-top: 3px solid #d4af37;
}

.yin-title, .yang-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
}

.yin-content, .yang-content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text2);
}

/* 图片容器 */
.content-img-container {
  margin: 24px 0;
  text-align: center;
}

.content-img {
  display: inline-block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.content-img svg {
  max-width: 100%;
  height: auto;
}

.content-img-caption {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text3);
  text-align: center;
}

/* 八卦网格 */
.bagua-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.bagua-item {
  padding: 20px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all 0.25s ease;
}

.bagua-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.bagua-symbol {
  font-size: 36px;
  margin-bottom: 8px;
}

.bagua-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.bagua-attr {
  font-size: 13px;
  color: var(--text3);
}

/* 天干流程 */
.tiangan-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0;
  justify-content: center;
}

.tiangan-item {
  width: 80px;
  padding: 16px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all 0.25s ease;
}

.tiangan-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.tiangan-symbol {
  font-size: 32px;
  margin-bottom: 6px;
}

.tiangan-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.tiangan-yin {
  font-size: 11px;
  color: var(--text3);
}

/* 表格 */
.content-table {
  margin: 20px 0;
  overflow-x: auto;
}

.content-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.content-table th,
.content-table td {
  padding: 12px 14px;
  text-align: left;
  border: 1px solid var(--border);
}

.content-table th {
  background: var(--card);
  font-weight: 600;
  color: var(--gold);
}

.content-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* 能量流动 */
.energy-flow {
  margin: 20px 0;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.energy-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}

.energy-step:last-child {
  border-bottom: none;
}

.energy-num {
  width: 28px;
  height: 28px;
  background: var(--gold);
  color: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.energy-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text2);
  padding-top: 4px;
}

/* 响应式 */
@media (max-width: 768px) {
  .content-comparison,
  .content-yinyang {
    grid-template-columns: 1fr;
  }

  .bagua-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tiangan-flow {
    gap: 8px;
  }

  .tiangan-item {
    width: 70px;
    padding: 12px 8px;
  }
}

@media (max-width: 480px) {
  #content-display {
    font-size: 14px;
  }

  .bagua-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .bagua-symbol {
    font-size: 28px;
  }
}
