/* =========================================================================
 * onticards · 制造业智能化全景图谱 — 图谱视图样式
 * 米色主题 #f7f3e9，暖色系
 * ========================================================================= */

:root {
  --bg: #f7f3e9;
  --bg-elevated: #fffdf7;
  --surface: #f1ead9;
  --surface-hover: #e9e0ca;
  --text: #2d2a26;
  --text-secondary: #6b655c;
  --text-tertiary: #a39a8b;
  --border: #e5ddc9;
  --border-strong: #d4c9ae;
  --primary: #ff6b2c;
  --primary-soft: rgba(255, 107, 44, 0.10);

  --c-data: #2563eb;
  --c-knowledge: #059669;
  --c-skill: #9333ea;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 8px rgba(87, 72, 50, 0.08);
  --shadow-md: 0 8px 24px rgba(87, 72, 50, 0.12);
  --shadow-lg: 0 24px 60px rgba(87, 72, 50, 0.18);

  --header-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== 顶栏 ===================== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(247, 243, 233, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.brand {
  display: flex; align-items: center;
  text-decoration: none; color: inherit;
}
.brand-title {
  font-family: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", "Songti SC", serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  line-height: 1.2;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.view-switch, .view-current {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
}
.view-switch {
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.view-switch:hover { border-color: var(--border-strong); color: var(--text); }
.view-switch svg { width: 15px; height: 15px; }
.view-current {
  color: #fff;
  background: var(--primary);
  cursor: default;
}
.view-current svg { width: 15px; height: 15px; }

/* ===================== 语言切换器 ===================== */
.lang-switch { position: relative; margin-left: 6px; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  font-family: inherit;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.lang-btn:hover { border-color: var(--border-strong); color: var(--text); }
.lang-btn > svg:first-child { width: 15px; height: 15px; }
.lang-btn .lang-caret { width: 12px; height: 12px; opacity: 0.7; transition: transform 0.2s ease; }
.lang-switch:hover .lang-caret,
.lang-switch.open .lang-caret { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 138px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 200;
}
.lang-switch:hover .lang-menu,
.lang-switch.open .lang-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.lang-switch:hover .lang-menu::before,
.lang-switch.open .lang-menu::before {
  content: '';
  position: absolute;
  top: -14px; left: 0; right: 0;
  height: 14px;
}
.lang-item {
  display: flex; align-items: center;
  width: 100%;
  font-family: inherit;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.lang-item:hover { background: var(--surface); color: var(--text); }
.lang-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
.lang-item.active::after {
  content: '✓';
  margin-left: auto;
  font-size: 12px;
}

/* ===================== 图谱舞台 ===================== */
.graph-stage {
  position: fixed;
  top: var(--header-h); left: 0; right: 0; bottom: 0;
  background: var(--bg);
}

#graphContainer,
#networkContainer {
  width: 100%;
  height: 100%;
}
#graphContainer canvas,
#networkContainer canvas { outline: none; }

/* ===================== 工具栏 ===================== */
.graph-toolbar {
  position: absolute;
  top: 20px; right: 24px;
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px;
  box-shadow: var(--shadow-sm);
  z-index: 50;
}

.tb-btn {
  display: flex; align-items: center; gap: 6px;
  border: none; background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px; font-weight: 600;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  white-space: nowrap;
}
.tb-btn:hover { background: var(--surface); color: var(--text); }
.tb-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.tb-btn.icon-only { padding: 7px; }
.tb-btn:active { transform: scale(0.95); }

.tb-divider {
  width: 1px; height: 20px;
  background: var(--border);
  margin: 0 2px;
}

.tb-zoom-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ===================== 图例 ===================== */
.graph-legend {
  position: absolute;
  left: 24px; bottom: 24px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  z-index: 50;
}
.legend-item {
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; color: var(--text-secondary); font-weight: 500;
}
.legend-dot {
  width: 12px; height: 12px; border-radius: 4px;
  flex-shrink: 0;
}
.legend-dot.outline {
  background: transparent;
  border: 2px solid;
  border-radius: 4px;
}

/* ===================== 加载与提示 ===================== */
.graph-loading {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  background: var(--bg);
  z-index: 60;
  color: var(--text-secondary);
  font-size: 14px;
  transition: opacity 0.4s ease;
}
.graph-loading.hide { opacity: 0; pointer-events: none; }
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.graph-toast {
  position: absolute;
  top: 76px; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--text);
  color: #fdf9f0;
  font-size: 13px; font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 80;
}
.graph-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================== 节点详情模态窗 ===================== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 38, 0.32);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.22s ease;
}
.modal-mask.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  width: 92vw;
  max-width: 640px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal.modal-skill { max-width: 900px; height: 84vh; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head-main { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.modal-badge {
  align-self: flex-start;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}
.modal-badge.badge-data { background: rgba(37,99,235,0.10); color: var(--c-data); }
.modal-badge.badge-knowledge { background: rgba(5,150,105,0.10); color: var(--c-knowledge); }
.modal-badge.badge-skill { background: rgba(147,51,234,0.10); color: var(--c-skill); }
.modal-title { font-size: 19px; font-weight: 800; line-height: 1.35; }

.modal-close {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 9px;
  color: var(--text-tertiary);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.modal-close:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body {
  padding: 22px 26px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* 数据/知识节点弹窗内容 */
.detail-para {
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--text-secondary);
}
.detail-para strong { color: var(--text); }

.kv-block { margin-bottom: 20px; }
.kv-block:last-child { margin-bottom: 0; }
.kv-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 800;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 9px;
}
.kv-label::before {
  content: "";
  width: 4px; height: 14px;
  border-radius: 2px;
  background: var(--kv-color, var(--c-knowledge));
}
.kv-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  padding-left: 11px;
}

/* ===================== 技能节点：代码仓库 ===================== */
.skill-desc {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.repo-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.repo-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 800;
}
.repo-title svg { width: 16px; height: 16px; color: var(--text-secondary); }
.repo-count { font-size: 12px; color: var(--text-tertiary); font-weight: 500; margin-left: 6px; }
.repo-actions { display: flex; gap: 8px; align-items: center; }
.repo-toggle-all {
  border: none; background: transparent;
  color: var(--c-skill); font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  padding: 4px 6px;
}
.repo-toggle-all:hover { text-decoration: underline; }

.repo-panel {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fbf8f1;
  min-height: 320px;
  flex: 1;
}

.repo-tree {
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
  background: var(--bg-elevated);
}
.repo-tree-item {
  display: flex; align-items: center; gap: 7px;
  width: 100%;
  border: none; background: transparent;
  font-size: 13px; color: var(--text-secondary);
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
  transition: background 0.15s ease;
}
.repo-tree-item:hover { background: var(--surface); }
.repo-tree-item.active { background: rgba(147,51,234,0.10); color: var(--c-skill); font-weight: 600; }
.repo-tree-item .tree-caret {
  width: 12px; height: 12px; flex-shrink: 0;
  transition: transform 0.15s ease;
  color: var(--text-tertiary);
}
.repo-tree-item.open > .tree-caret { transform: rotate(90deg); }
.repo-tree-item .tree-icon { width: 14px; height: 14px; flex-shrink: 0; }
.repo-tree-item .tree-tag {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(37,99,235,0.10);
  color: var(--c-data);
  font-weight: 600;
  flex-shrink: 0;
}
.repo-tree-children { padding-left: 16px; }
.repo-tree-children.collapsed { display: none; }

.repo-code {
  flex: 1;
  overflow: auto;
  min-width: 0;
  display: flex; flex-direction: column;
}
.repo-code-path {
  font-size: 12px;
  font-family: "SF Mono", Consolas, monospace;
  color: var(--text-tertiary);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.repo-code pre {
  flex: 1;
  margin: 0;
  padding: 16px 18px;
  font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: #3f3a33;
  white-space: pre;
  overflow: auto;
}
.repo-code-empty {
  flex: 1;
  display: grid; place-items: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* 一键打包下载 */
.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.foot-hint { font-size: 12px; color: var(--text-tertiary); }
.btn-download {
  display: flex; align-items: center; gap: 7px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 13.5px; font-weight: 700;
  padding: 9px 18px;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(255, 107, 44, 0.3);
}
.btn-download:hover { background: #ff5a14; transform: translateY(-1px); }
.btn-download:active { transform: translateY(0); }
.btn-download svg { width: 15px; height: 15px; }

/* ===================== 响应式 ===================== */
@media (max-width: 900px) {
  .graph-toolbar { right: 12px; top: 12px; }
  .tb-btn span { display: none; }
  .graph-legend { left: 12px; bottom: 12px; padding: 10px 12px; gap: 6px; }
  .brand-site, .brand-sep { display: none; }
  .repo-panel { flex-direction: column; }
  .repo-tree { width: 100%; max-height: 160px; border-right: none; border-bottom: 1px solid var(--border); }
}
