/* ============================================================
   学海无涯 · 认知知识树样式
   遵循 COGNITION_TREE_FORMAT_SPEC 规范
   磨砂玻璃 · 数据驱动 · 响应式
   ============================================================ */

.tree-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  margin: 2rem 0;
}

/* ============ 工具栏 ============ */
.tree-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  box-shadow: 0 20px 55px rgba(30, 60, 70, 0.10);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
}

.tree-toolbar .search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.tree-toolbar input#tree-search {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid rgba(226, 220, 207, 0.6);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 13px;
  color: #2b2a26;
  outline: none;
}

.tree-toolbar input#tree-search:focus {
  border-color: #556b3d;
  background: #fff;
}

.tree-toolbar .btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tree-toolbar button {
  padding: 6px 12px;
  border: 1px solid rgba(226, 220, 207, 0.6);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 12px;
  color: #2b2a26;
  cursor: pointer;
  transition: all 0.15s;
}

.tree-toolbar button:hover {
  border-color: #556b3d;
  background: rgba(85, 107, 61, 0.1);
}

.tree-toolbar .btn-group-sep {
  width: 1px;
  height: 20px;
  background: rgba(226, 220, 207, 0.8);
  margin: 0 4px;
}

/* ============ 搜索结果浮层 ============ */
#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(226, 220, 207, 0.7);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(43, 42, 38, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 50;
  display: none;
}

#search-results.active {
  display: block;
}

.search-result {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid rgba(226, 220, 207, 0.4);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover {
  background: rgba(85, 107, 61, 0.08);
}

.search-result strong {
  display: block;
  font-family: 'Lora', 'Noto Serif SC', serif;
  font-size: 13px;
  color: #2b2a26;
  margin-bottom: 2px;
}

.search-result small {
  display: block;
  font-size: 11px;
  color: #8a8579;
  line-height: 1.3;
}

/* ============ 画布容器（磨砂玻璃） ============ */
.tree-map-panel {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  box-shadow: 0 20px 55px rgba(30, 60, 70, 0.10);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  overflow: hidden;
}

.tree-canvas {
  width: 100%;
  height: 640px;
  overflow: hidden;
  position: relative;
  cursor: grab;
  user-select: none;
}

.tree-canvas svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============ 节点样式 ============ */
.node {
  cursor: pointer;
  outline: none;
  transition: opacity 0.15s;
}

.node .node-bg {
  fill: rgba(255, 255, 255, 0.92);
  stroke: rgba(226, 220, 207, 0.9);
  stroke-width: 1.5;
  transition: all 0.18s;
}

.node .node-title {
  font-family: 'Lora', 'Noto Serif SC', serif;
  font-size: 13px;
  font-weight: 700;
  fill: #2b2a26;
  pointer-events: none;
}

.node .node-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  fill: #8a8579;
  pointer-events: none;
}

.node .branch-dot {
  stroke-width: 1.5;
  transition: all 0.15s;
}

/* 深绿色 · 可跳转（有 href） */
.node .branch-dot.has-link {
  fill: #556b3d;
  stroke: #3f5030;
}

/* 浅绿色 · 可展开（无 href 但有子节点） */
.node .branch-dot.expandable {
  fill: #d4e2c8;
  stroke: #a5b98d;
}

/* 浅灰色 · 叶子节点 */
.node .branch-dot.leaf {
  fill: #d8d4cb;
  stroke: #a8a49b;
}

.node:hover .branch-dot.has-link {
  fill: #a05a2c;
  stroke: #7a4520;
}

.node:hover .branch-dot.expandable {
  fill: #b5cba2;
  stroke: #556b3d;
}

.node .status-dot {
  stroke-width: 1.5;
  transition: all 0.15s;
}

/* 深绿色 · 可跳转（有 href） */
.node .status-dot.has-link {
  fill: #556b3d;
  stroke: #3f5030;
}

/* 浅绿色 · 可展开（无 href 但有子节点） */
.node .status-dot.expandable {
  fill: #d4e2c8;
  stroke: #a5b98d;
}

.node:hover .status-dot.has-link {
  fill: #a05a2c;
  stroke: #7a4520;
}

.node:hover .status-dot.expandable {
  fill: #b5cba2;
  stroke: #556b3d;
}

.node:hover .node-bg {
  stroke: #556b3d;
  stroke-width: 2;
  fill: #fff;
}

.node.selected .node-bg {
  stroke: #556b3d;
  stroke-width: 2.5;
  fill: rgba(212, 226, 200, 0.5);
  filter: drop-shadow(0 4px 12px rgba(85, 107, 61, 0.25));
}

.node.selected .node-title {
  fill: #556b3d;
}

/* 路线高亮 */
.node.route-node .node-bg {
  stroke: #a05a2c;
  stroke-width: 2;
}

.node.selected.route-node .node-bg {
  stroke: #a05a2c;
  stroke-width: 2.5;
}

/* ============ 连接线 ============ */
.edge {
  fill: none;
  stroke: rgba(138, 133, 121, 0.4);
  stroke-width: 1.5;
  transition: stroke 0.15s;
}

.edge.route-edge {
  stroke: #a05a2c;
  stroke-width: 3;
}

/* ============ 详情面板（磨砂玻璃） ============ */
.tree-detail-panel {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  box-shadow: 0 20px 55px rgba(30, 60, 70, 0.10);
  backdrop-filter: blur(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  padding: 24px;
  height: fit-content;
  max-height: 640px;
  overflow-y: auto;
}

.detail-empty {
  color: #8a8579;
  font-style: italic;
  text-align: center;
  padding: 40px 0;
}

.detail-header {
  padding-left: 14px;
  border-left: 4px solid #556b3d;
  margin-bottom: 18px;
}

.detail-depth {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #8a8579;
  margin-bottom: 4px;
}

.detail-title {
  font-family: 'Lora', 'Noto Serif SC', serif;
  font-size: 20px;
  font-weight: 700;
  color: #2b2a26;
  line-height: 1.3;
}

.detail-desc {
  font-family: 'Lora', 'Noto Serif SC', serif;
  font-size: 14px;
  line-height: 1.7;
  color: #2b2a26;
  margin-bottom: 18px;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.meta-item {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  border: 1px solid rgba(226, 220, 207, 0.5);
}

.meta-label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8a8579;
  margin-bottom: 4px;
}

.meta-value {
  display: block;
  font-family: 'Lora', 'Noto Serif SC', serif;
  font-size: 13px;
  font-weight: 700;
  color: #2b2a26;
}

.detail-path {
  padding: 12px 14px;
  background: rgba(85, 107, 61, 0.06);
  border-radius: 12px;
  border-left: 3px solid #556b3d;
  margin-bottom: 18px;
}

.path-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #556b3d;
  margin-bottom: 4px;
}

.path-value {
  font-family: 'Lora', 'Noto Serif SC', serif;
  font-size: 12px;
  line-height: 1.5;
  color: #2b2a26;
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-btn {
  padding: 10px 16px;
  border: 1px solid rgba(226, 220, 207, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-family: 'Lora', 'Noto Serif SC', serif;
  font-size: 13px;
  font-weight: 700;
  color: #2b2a26;
  cursor: pointer;
  transition: all 0.15s;
}

.detail-btn:hover {
  border-color: #556b3d;
  background: rgba(85, 107, 61, 0.1);
}

.detail-btn.primary {
  background: rgba(85, 107, 61, 0.15);
  border-color: #556b3d;
  color: #556b3d;
}

.detail-btn.primary:hover {
  background: #556b3d;
  color: #fff;
}

.detail-btn.accent {
  background: #556b3d;
  border-color: #556b3d;
  color: #fff;
}

.detail-btn.accent:hover {
  background: #a05a2c;
  border-color: #a05a2c;
}

/* ============ 响应式：手机端单栏 ============ */
@media (max-width: 720px) {
  .tree-workspace {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .tree-canvas {
    height: 500px;
  }
  .tree-detail-panel {
    max-height: none;
    padding: 18px;
  }
  .tree-toolbar {
    padding: 10px 12px;
    gap: 6px;
  }
  .tree-toolbar button {
    padding: 5px 10px;
    font-size: 11px;
  }
  .detail-meta {
    grid-template-columns: 1fr;
  }
}
