/* GMBA 山脉查看器样式 - 浅色主题 */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ====== 侧边栏 ====== */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 1px 0 3px rgba(0,0,0,0.04);
}

.brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f3f4f6;
  background: linear-gradient(135deg, #fafbfc 0%, #f0f4f8 100%);
}
.brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.01em;
}
.brand .ver {
  font-size: 11px;
  background: #1d4ed8;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 4px;
  font-weight: 600;
}
.brand-sub {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.panel {
  border-bottom: 1px solid #f3f4f6;
  padding: 12px 16px 14px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
  color: #1f2937;
}
.input:focus { border-color: #1d4ed8; box-shadow: 0 0 0 2px rgba(29,78,216,0.15); }

/* ====== 搜索结果下拉 ====== */
.search-panel { position: relative; }
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 1000;
  margin-top: 2px;
}
.search-hint {
  padding: 6px 12px;
  font-size: 11px;
  color: #6b7280;
  border-bottom: 1px solid #f3f4f6;
  background: #f9fafb;
}
.search-result-item {
  display: flex;
  align-items: center;
  padding: 7px 10px 7px 0;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  position: relative;
}
.search-result-item:hover { background: #eff6ff; }
.search-result-item:last-child { border-bottom: none; }
.sri-bar {
  display: inline-block;
  width: 3px;
  height: 28px;
  margin: 0 10px 0 0;
  border-radius: 2px;
  flex-shrink: 0;
}
.sri-main {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sri-sub {
  font-size: 11px;
  color: #6b7280;
  margin-left: 8px;
  flex-shrink: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-mini {
  font-size: 11px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 2px 8px;
  color: #6b7280;
  cursor: pointer;
}
.btn-mini:hover { background: #e5e7eb; }

/* ====== 统计 ====== */
.stats { display: flex; flex-direction: column; gap: 4px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #6b7280;
  padding: 3px 0;
}
.stat-row b {
  font-size: 13px;
  color: #111827;
  font-weight: 600;
}

/* ====== 层级网格 ====== */
.lvl-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 2px;
}
.lvl-chip {
  font-size: 11px;
  text-align: center;
  padding: 6px 0;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  cursor: pointer;
  background: #fff;
  color: #6b7280;
  transition: all 0.12s;
  position: relative;
}
.lvl-chip:hover { border-color: #1d4ed8; color: #1d4ed8; }
.lvl-chip.active {
  background: var(--lvl-color, #1d4ed8);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.lvl-chip .lvl-count {
  display: block;
  font-size: 9px;
  opacity: 0.7;
  margin-top: 2px;
}

.hint {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 6px;
  line-height: 1.4;
}

/* 填充浓度滑块 */
.alpha-val {
  font-size: 11px;
  color: #2563eb;
  font-variant-numeric: tabular-nums;
}
#fillAlpha {
  width: 100%;
  margin-top: 8px;
  accent-color: #2563eb;
  cursor: pointer;
}

/* ====== 切换开关 ====== */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1;
  transition: 0.2s;
  border-radius: 20px;
}
.slider:before {
  content: "";
  position: absolute;
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background: #fff;
  transition: 0.2s;
  border-radius: 50%;
}
.switch input:checked + .slider { background: #1d4ed8; }
.switch input:checked + .slider:before { transform: translateX(16px); }

/* ====== Tab 按钮 ====== */
.lang-tabs, .base-layers {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.lang-btn, .base-btn {
  flex: 1;
  font-size: 12px;
  padding: 5px 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6b7280;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s;
}
.lang-btn:hover, .base-btn:hover { border-color: #1d4ed8; color: #1d4ed8; }
.lang-btn.active, .base-btn.active {
  background: #1d4ed8;
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}

/* ====== 距离测量 ====== */
/* 侧栏没有测距面板样式 —— 整个控件只有一个开关 (.switch), 读数全部画在地图上。 */

/* 地图上的测距标注 (divIcon) —— 与 .mtn-label 同理, 用透明容器 + flex 居中 */
.measure-seg {
  background: transparent !important;
  border: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #6d28d9;
  white-space: nowrap;
  pointer-events: none;
  /* 白色光晕: 压在卫星影像 / 深色地形上依然可读 */
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}
/* 总里程: 实心紫色药丸, 和分段数字的"白底描边"区分开, 一眼能看出主次。
   外层是固定 150px 的居中容器 (Leaflet 靠固定尺寸算锚点), 底色画在内层自适应宽度上,
   否则药丸会被拉成一条 150px 的长条。 */
.leaflet-marker-icon.measure-total-tag {
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.measure-total-tag .mtt-inner {
  background: #7c3aed;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  padding: 1px 10px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  font-variant-numeric: tabular-nums;
}

/* 测距模式下光标变十字 (用 !important 压掉 JS 给容器设的 inline cursor) */
#map.measuring,
#map.measuring .leaflet-interactive { cursor: crosshair !important; }

/* ====== 图例 ====== */
.legend {
  padding: 14px 16px 14px;
  border-top: 1px solid #f3f4f6;
}
.legend-title {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.legend-bar {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right,
    #fef3c7 0%,
    #fde68a 11%,
    #fca5a5 22%,
    #f87171 33%,
    #ef4444 44%,
    #dc2626 55%,
    #b91c1c 66%,
    #991b1b 77%,
    #7f1d1d 88%,
    #450a0a 100%);
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #9ca3af;
  margin-top: 4px;
}

/* ====== 数据来源致谢 ====== */
.data-source {
  padding: 14px 16px 20px;
  margin-top: auto;
  border-top: 1px solid #f3f4f6;
  background: linear-gradient(180deg, #fafbfc 0%, #f5f7fa 100%);
}
.ds-title {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.ds-org {
  font-size: 12px;
  color: #1f2937;
  line-height: 1.5;
}
.ds-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 500;
}
.ds-link:hover { text-decoration: underline; }
.ds-thanks {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.5;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
}
.ds-thanks a {
  color: #1d4ed8;
  text-decoration: none;
  word-break: break-all;
}
.ds-thanks a:hover { text-decoration: underline; }

/* ====== 地图 ====== */
.map-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
#map {
  width: 100%;
  height: 100%;
  background: #eaf2f8;
}

/* ====== 加载遮罩 ====== */
.loading-mask {
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.96);
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  font-size: 13px;
  color: #374151;
}
.loading-mask[hidden] { display: none; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== 信息卡片 ====== */
.info-card {
  position: absolute;
  top: 16px; right: 16px;
  width: 320px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 14px 16px 16px;
  z-index: 1000;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.info-card[hidden] { display: none; }
.info-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none;
  border: none;
  font-size: 22px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
}
.info-close:hover { color: #374151; }
.info-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
  padding-right: 16px;
}
.info-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.chip {
  font-size: 11px;
  background: #f3f4f6;
  color: #4b5563;
  padding: 2px 7px;
  border-radius: 10px;
}
.chip.lvl { background: #1d4ed8; color: #fff; font-weight: 600; }
.chip.sel { background: #b91c1c; color: #fff; font-weight: 600; }
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12px;
}
.info-grid .info-field {
  display: flex;
  flex-direction: column;
}
.info-grid .info-label {
  color: #9ca3af;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.info-grid .info-value {
  color: #111827;
  font-weight: 500;
  word-break: break-word;
}
.info-grid .info-field.full { grid-column: span 2; }
.info-wiki {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: #1d4ed8;
  text-decoration: none;
}
.info-wiki:hover { text-decoration: underline; }

/* ====== 缩放提示 ====== */
.zoom-hint {
  position: absolute;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: rgba(17,24,39,0.9);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  z-index: 1000;
  pointer-events: none;
}
.zoom-hint[hidden] { display: none; }

/* ====== Leaflet 控件美化 ====== */
.leaflet-control-zoom { border: none !important; box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important; }
.leaflet-control-zoom a {
  background: #fff !important;
  color: #374151 !important;
  border-radius: 6px !important;
  margin-bottom: 4px;
}
/* 比例尺 (左下角) —— 与缩放按钮保持同一套白色圆角风格 */
.leaflet-control-scale {
  margin-left: 14px !important;
  margin-bottom: 14px !important;
}
.leaflet-control-scale-line {
  background: rgba(255,255,255,0.92) !important;
  border: 1px solid #9ca3af !important;
  border-top: none !important;
  border-radius: 0 0 6px 6px !important;
  color: #374151 !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  padding: 2px 8px !important;
  text-shadow: none !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12) !important;
}
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.leaflet-popup-content { margin: 8px 12px; font-size: 13px; }

/* ====== 山脉 hover tooltip ====== */
.mtn-tooltip.leaflet-tooltip {
  background: rgba(255,255,255,0.96);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 5px 9px;
  color: #111827;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.mtn-tooltip.leaflet-tooltip-top::before { border-top-color: rgba(255,255,255,0.96); }
.mtn-tooltip .mtn-tip-name { font-weight: 600; line-height: 1.3; }
.mtn-tooltip .mtn-tip-sub { font-size: 11px; color: #6b7280; margin-top: 1px; line-height: 1.3; }

/* ====== 常驻标签 (山脉名) ====== */
.mtn-label {
  background: transparent !important;
  border: none !important;
  /* 让标签中心对齐要素中心, 而不是默认的左上对齐 */
  display: flex;
  align-items: center;
  justify-content: center;
}
.mtn-label-text {
  display: inline-block;
  background: rgba(255,255,255,0.88);
  color: #1f2937;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid #d1d5db;
  border-left: 3px solid #888;   /* 用 inline style 覆盖成层级配色 */
  white-space: nowrap;
  pointer-events: none;           /* 不阻挡地图交互 */
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  transform: translate(-50%, -50%);   /* 让标签中心对齐要素中心 */
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====== 滚动条 ====== */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ====== 响应式 ====== */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: 40vh; border-right: none; border-bottom: 1px solid #e5e7eb; }
  #app { flex-direction: column; }
  .info-card { width: calc(100% - 32px); }
}
