/* 全局重置，优化移动端体验 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  display: flex; /* 保留flex布局 */
  padding: min(1.6vw, 1vh, 16px);
  height: 100vh;
  overflow: hidden;
  position: relative; /* 新增：为固定定位元素提供参考 */
}

/* 左侧悬浮图层控制面板（仿天地图样式） */
.layer-panel {
  position: fixed;
  top: 0;
  left: 0;
  transform: translateX(-240px);
  width: 240px;
  height: 100%;
  background: #fff;
  border-right: 1px solid #99cc99;
  padding: 15px 10px;
  overflow-y: auto;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
  z-index: 1666;
  transition: transform 0.3s ease;
  padding-top: 1vh;
  box-sizing: border-box;
}

/* 【修复】提升active类优先级，明确覆盖默认transform */
.layer-panel.active {
  transform: translateX(0) !important;
}

/* 悬浮触发按钮（logo/手柄） */
.layer-trigger {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 40px;
  height: 80px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-left: none;
  border-radius: 0 8px 8px 0;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  color: #666;
  font-size: 14px;
  transition: background 0.2s;
}

.layer-trigger:active {
  background: #f5f5f5;
  color: #333;
}

.layer-panel h3 {
  font-size: 16px;
  color: #333;
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}
.layer-item {
  display: flex;
  align-items: center;
  padding: 8px 5px;
  margin-bottom: 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.layer-item:hover {
  background: #f5f5f5;
}
.layer-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  cursor: pointer;
}
.layer-item label {
  flex: 1;
  font-size: 14px;
  color: #666;
  cursor: pointer;
}

#map {
  flex: 1; /* 保留flex布局的自适应 */
  height: 100%;
  width: min(96%, 100vw - 6px);
  margin: 0 auto;
  position: relative;
  border: min(1.6px, 1vh) dashed #99cc99;
  border-radius: max(6px, 0.6vw);
  overflow: hidden;
  touch-action: pan-x pan-y;
  transition: box-shadow 0.3s ease;
}

#map:active {
  box-shadow: 0 0 16px rgba(153, 204, 153, 0.6);
}

/* ========== 【方案A】Tooltip 样式（替代旧 Popup 样式）========== */

/* 悬停提示 Tooltip */
.leaflet-tooltip.hover-tooltip {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #4a8c4a;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  color: #333;
  padding: 0;
  max-width: 300px;
}

.leaflet-tooltip.hover-tooltip::before {
  display: none; /* 隐藏箭头 */
}

.leaflet-tooltip.hover-tooltip .feature-popup table {
  width: 100%;
  border-collapse: collapse;
}

.leaflet-tooltip.hover-tooltip .feature-popup table td {
  padding: 3px 5px;
  border-bottom: 1px solid #eee;
}

.leaflet-tooltip.hover-tooltip .feature-popup table tr:last-child td {
  border-bottom: none;
}

.leaflet-tooltip.hover-tooltip .feature-popup {
  margin: 8px 10px;
}

/* 站点标签 Tooltip */
.leaflet-tooltip.station-label-tooltip {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #8b7355;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  font-size: 11px;
  color: #5a4a3a;
  padding: 2px 6px;
  white-space: nowrap;
}

.leaflet-tooltip.station-label-tooltip::before {
  border-right-color: #8b7355;
}

.leaflet-tooltip.station-label-tooltip.top::before {
  border-top-color: #8b7355;
}

/* ========== 搜索框（侧边栏内） ========== */
.search-bar {
  padding: 0 5px 8px;
}

.search-bar input[type="text"] {
  width: 100%;
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid #99cc99;
  border-radius: 16px;
  background: #f8fcf8;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
  outline: none;
  color: #333;
  transition:
    border-color 0.2s,
    background 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.search-bar input[type="text"]:focus {
  border-color: #4a8c4a;
  background: #fff;
  border-radius: 16px 16px 0 0;
}

.search-results {
  display: none;
  background: #fff;
  border: 1px solid #c8e0c8;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 260px;
  overflow-y: auto;
  position: absolute;
  left: 5px;
  right: 5px;
  z-index: 2000;
}

.search-results.open {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

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

.search-result-item:hover {
  background: #f0f7f0;
}

.search-result-tag {
  flex-shrink: 0;
  font-size: 10px;
  color: #fff;
  background: #6aaa6a;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
}

.search-result-text {
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.search-result-text mark {
  background: #ffe066;
  color: #333;
  border-radius: 2px;
  padding: 0 1px;
}

.search-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: #999;
  text-align: center;
}

.leaflet-popup.hover-popup {
  pointer-events: none;
}

.leaflet-popup.hover-popup .leaflet-popup-content-wrapper {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #4a8c4a;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.leaflet-popup.hover-popup .leaflet-popup-content {
  font-size: 12px;
  color: #333;
  margin: 8px 10px;
}

.leaflet-popup.hover-popup .leaflet-popup-tip-container {
  display: none;
}

.leaflet-popup.hover-popup .feature-popup table {
  width: 100%;
  border-collapse: collapse;
}

.leaflet-popup.hover-popup .feature-popup table td {
  padding: 3px 5px;
  border-bottom: 1px solid #eee;
}

.leaflet-popup.hover-popup .feature-popup table tr:last-child td {
  border-bottom: none;
}
