/* 明代文集数字人文专题网站 —— 全局样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
[v-cloak] { display: none; }

:root {
  --crimson: #8c3b3b;
  --crimson-dark: #5f2424;
  --gold: #b98a2f;
  --paper: #f6f1e6;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #7a7265;
  --line: #e3dbc9;
}

html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--paper);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}
#app { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(135deg, var(--crimson-dark), var(--crimson));
  color: #fdf6e3;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  flex-shrink: 0;
}
.brand h1 { font-size: 22px; letter-spacing: 1px; }
.brand-en { font-size: 12px; font-weight: normal; opacity: .8; margin-left: 8px; letter-spacing: 1px; }
.subtitle { font-size: 12px; opacity: .85; margin-top: 2px; }
.tabs { display: flex; gap: 8px; }
.tabs button {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.25);
  color: #fdf6e3;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all .2s;
}
.tabs button:hover { background: rgba(255,255,255,.22); }
.tabs button.active { background: var(--gold); border-color: var(--gold); color: #3a2a08; font-weight: 600; }

/* ---------- 页面容器 ---------- */
.page { flex: 1; display: flex; min-height: 0; width: 100%; }

/* ---------- 数据页 ---------- */
.data-page { align-items: stretch; }
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: #fbf7ee;
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  overflow-y: auto;
}
.sidebar h3 { font-size: 15px; color: var(--crimson-dark); margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 12px; font-weight: normal; }

.tree { list-style: none; }
.tree-item { margin-bottom: 4px; }
.tree-node {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: 6px; cursor: pointer;
  background: #f3ecdd; border: 1px solid transparent;
}
.tree-node:hover { background: #eee5cf; }
.caret { font-size: 10px; color: var(--gold); transition: transform .15s; display: inline-block; }
.caret.open { transform: rotate(90deg); }
.node-name { font-weight: 600; flex: 1; }
.count { color: var(--muted); font-size: 12px; }
.tree-children { list-style: none; margin: 2px 0 6px 18px; border-left: 1px dashed var(--line); padding-left: 8px; }
.tree-leaf {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.tree-leaf:hover { background: #eee5cf; }
.tree-leaf.selected { background: var(--crimson); color: #fff; }
.tree-leaf.selected .count { color: #f3d9a0; }
.leaf-name { flex: 1; }

/* ---------- 内容区 ---------- */
.content { flex: 1; padding: 18px 22px; overflow-y: auto; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.card h3 { font-size: 15px; color: var(--crimson-dark); margin-bottom: 10px; }

.filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 10px; }
.filter-row:last-child { margin-bottom: 0; }
.filter-row label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.filter-row select, .filter-row input {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: #fff;
  min-width: 130px; color: var(--ink);
}
.filter-row input { min-width: 160px; }

.btn {
  padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 13px; color: var(--ink);
}
.btn.primary { background: var(--crimson); color: #fff; border-color: var(--crimson); }
.btn.primary:hover { background: var(--crimson-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 视图切换 */
.mode-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.mode-btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 13px; color: var(--ink); transition: all .15s;
}
.mode-btn:hover { border-color: var(--gold); }
.mode-btn.active { background: var(--crimson); color: #fff; border-color: var(--crimson); font-weight: 600; }

/* 图表 */
.chart { width: 100%; height: 320px; }

/* 分类统计：树状图 + 饼状图 */
.class-charts { display: flex; gap: 16px; flex-wrap: wrap; }
.chart-box { flex: 1 1 340px; min-width: 300px; }
.chart-box h4 { font-size: 13px; color: var(--muted); margin-bottom: 6px; text-align: center; }
.tm-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; justify-content: center; }
.tm-level { font-size: 13px; color: var(--muted); }
.tm-level b { color: var(--crimson-dark); }
.tm-back { padding: 4px 12px; font-size: 12px; }

/* 表格 */
.table-head { display: flex; justify-content: space-between; align-items: center; }
.table-head h3 { margin-bottom: 4px; }
.total { color: var(--crimson); font-size: 13px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 9px 10px; background: #f7f1e2; color: var(--crimson-dark);
  border-bottom: 2px solid var(--gold); white-space: nowrap;
}
tbody td { padding: 8px 10px; border-bottom: 1px solid #efe8d7; vertical-align: top; }
tbody tr:hover { background: #fdf9ef; }
td.title { font-weight: 600; }
td.cat { color: var(--muted); font-size: 12px; }
td a { color: #1f5c8d; text-decoration: none; }
td a:hover { text-decoration: underline; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.page-info { font-size: 13px; color: var(--muted); }

/* ---------- 地图页 ---------- */
.map-page { position: relative; flex-direction: column; }
.map-row { flex: 1; display: flex; min-height: 0; }
.map-wrap { flex: 1; position: relative; min-width: 0; }
.map { width: 100%; height: 100%; z-index: 1; }

/* 地图筛选栏（悬浮于地图左上） */
.map-filter {
  position: absolute; top: 12px; left: 12px; z-index: 1100;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  padding: 10px 12px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  max-width: calc(100% - 24px);
}
.map-filter-title { font-weight: 700; color: var(--crimson-dark); font-size: 13px; align-self: center; }
.map-filter label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 3px; }
.map-filter select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; background: #fff; color: var(--ink); }
.map-filter .btn { padding: 5px 12px; font-size: 12px; }

.map-sidebar {
  width: 340px; flex-shrink: 0; background: #fff; border-left: 1px solid var(--line);
  padding: 16px; overflow-y: auto; height: 100%;
  box-shadow: -2px 0 8px rgba(0, 0, 0, .06); z-index: 2;
}

/* 省内地点列表（点击省 → 地点统计） */
.place-list { list-style: none; }
.place-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 7px; background: #fdfbf5; cursor: pointer; transition: all .15s;
}
.place-item:hover { border-color: var(--gold); background: #faf3e3; transform: translateX(2px); }
.place-name { font-weight: 600; font-size: 13px; }
.place-count { font-size: 12px; color: var(--crimson); background: #f6e9d2; padding: 2px 8px; border-radius: 999px; }
.place-hint { margin: 6px 0 10px; }
.map-sidebar h3 { font-size: 15px; color: var(--crimson-dark); margin-bottom: 12px; }
.province-title {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--crimson); color: #fff; padding: 9px 12px; border-radius: 8px; margin-bottom: 12px;
}
.province-name { font-size: 16px; font-weight: 700; }
.province-count { font-size: 12px; opacity: .9; }
.clear-btn {
  margin-left: auto; background: rgba(255, 255, 255, .22); color: #fff;
  border: 1px solid rgba(255, 255, 255, .5); border-radius: 6px;
  cursor: pointer; font-size: 12px; padding: 2px 9px;
}
.clear-btn:hover { background: rgba(255, 255, 255, .38); }
.province-works { list-style: none; }
.pw-item {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fdfbf5;
}
.pw-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.pw-meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.pw-link { font-size: 12px; color: #1f5c8d; text-decoration: none; }
.pw-link:hover { text-decoration: underline; }

/* 地图弹窗 */
.popup-title { font-weight: 700; color: var(--crimson-dark); margin-bottom: 4px; }
.pop-t { font-size: 12px; line-height: 1.5; }
.pop-more { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Leaflet 图例 */
.legend { background: #fff; padding: 8px 10px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: 12px; line-height: 1.9; }

/* ---------- 第三层 ---------- */
.delta-page { justify-content: center; padding: 30px 20px; }
.delta-card { max-width: 760px; width: 100%; }
.delta-card .desc { line-height: 1.9; color: #4a4437; margin-bottom: 14px; }
.delta-status { margin: 14px 0; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.badge { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ready { background: #e3f2e5; color: #1e6b2e; }
.badge.pending { background: #fdeee0; color: #a35a16; }
.texts-box { background: #fbf7ee; border: 1px dashed var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0 16px; }
.texts-box h4 { font-size: 13px; margin-bottom: 8px; color: var(--crimson-dark); }
.texts-box ul { list-style: none; }
.texts-box li { font-size: 13px; padding: 3px 0; }
code { background: #efe8d7; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- 页脚 ---------- */
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 12px; background: #fbf7ee; border-top: 1px solid var(--line); flex-shrink: 0; }

/* 去除 Leaflet 交互要素点击后的浏览器蓝色焦点框 */
.leaflet-container .leaflet-interactive,
.leaflet-container .leaflet-interactive:focus,
.leaflet-container path,
.leaflet-container svg a:focus {
  outline: none !important;
}
.leaflet-container { font-family: inherit; background: #f4efe3; }

/* 省份名称标注（常驻标签，胶囊样式，字号随缩放变化） */
.province-label {
  background: rgba(255, 251, 240, .92);
  color: #7a2e2e;
  border: 1px solid rgba(140, 59, 59, .4);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: var(--province-label-fs, 12px);
  font-weight: 600;
  letter-spacing: 1px;
  box-shadow: 0 1px 5px rgba(90, 50, 30, .25);
  white-space: nowrap;
  transition: font-size .2s;
}
.province-label::before { display: none; }

/* 省份名称显示开关 */
.province-label-ctrl {
  background: #fff;
  border-radius: 6px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
  margin: 0;
}
