/* ============================================
   时空数据可视化 - 样式表
   ============================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: #0a0e1a;
}

/* ---- 地图容器 ---- */
#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* ---- 控制面板 ---- */
#control-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 340px;
  max-height: calc(100vh - 120px);
  background: rgba(15, 20, 32, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  color: #e8eaf0;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
}

#control-panel::-webkit-scrollbar {
  width: 6px;
}
#control-panel::-webkit-scrollbar-track {
  background: transparent;
}
#control-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* ---- 面板头部 ---- */
.panel-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.15), rgba(156, 39, 176, 0.1));
  border-radius: 16px 16px 0 0;
}

.panel-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #64b5f6, #ce93d8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.panel-header .subtitle {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
  letter-spacing: 0.3px;
}

.panel-header .badges {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.panel-header .badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

/* ---- 采样信息 ---- */
.sampling-info {
  padding: 14px 22px;
  background: linear-gradient(135deg, rgba(37,99,235,0.12), rgba(0,184,212,0.08));
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sampling-date, .sampling-time {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.si-label {
  font-size: 9px; font-weight: 600; color: rgba(255,255,255,0.35);
  text-transform: uppercase; letter-spacing: 0.5px;
  min-width: 48px;
}
.si-value {
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.9);
}
.si-duration {
  font-size: 10px; color: #60a5fa; font-weight: 700;
  background: rgba(96,165,250,0.15); padding: 1px 6px; border-radius: 8px;
}
.sampling-meta {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.si-chip {
  font-size: 9px; color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.06); padding: 2px 7px; border-radius: 10px;
}
.sampling-ref {
  font-size: 8.5px; color: rgba(255,255,255,0.25); margin-top: 8px; line-height: 1.5;
}

/* ---- 通用 section ---- */
.section {
  padding: 16px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.section h3 {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

/* ---- 图层控制 ---- */
.layer-toggles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layer-toggles label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  padding: 6px 0;
  transition: color 0.2s;
}

.layer-toggles label:hover {
  color: #fff;
}

.layer-toggles input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
  flex-shrink: 0;
}

.layer-toggles input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.3s;
}

.layer-toggles input[type="checkbox"]:checked {
  background: #2196F3;
}

.layer-toggles input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

.layer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- 统计卡片 ---- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
  transition: background 0.2s;
}

.stat-card:hover {
  background: rgba(255, 255, 255, 0.07);
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: #64b5f6;
  line-height: 1.2;
}

.stat-card:nth-child(2) .stat-value { color: #ef5350; }
.stat-card:nth-child(3) .stat-value { color: #66bb6a; }
.stat-card:nth-child(4) .stat-value { color: #ffa726; }
.stat-card:nth-child(5) .stat-value { color: #ab47bc; }

.stat-label {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 4px;
  letter-spacing: 0.3px;
}

/* ---- 时间分布图表 ---- */
#time-chart {
  width: 100%;
  height: 80px;
  display: block;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.chart-hint {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 6px;
}

/* ---- 数据来源 ---- */
.data-source-item {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.data-source-item:last-child {
  border-bottom: none;
}

.data-source-item .ds-icon {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.data-source-item .ds-content {
  flex: 1;
  min-width: 0;
}

.data-source-item .ds-name {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

.data-source-item .ds-source {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
}

/* ---- 时间控制器 ---- */
#time-controller {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 380px));
  background: rgba(15, 20, 32, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 1000;
}

#play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2196F3, #1976D2);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

#play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(33, 150, 243, 0.5);
}

#play-btn:active {
  transform: scale(0.95);
}

.time-slider-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#time-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(33, 150, 243, 0.3), rgba(156, 39, 176, 0.3));
  outline: none;
  cursor: pointer;
}

#time-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #2196F3;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#time-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #2196F3;
  cursor: pointer;
}

.time-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#current-time {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.time-range {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.speed-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.speed-control label {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#speed-select {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

#speed-select option {
  background: #1a1f2e;
}

/* ---- 图例 ---- */
#legend {
  position: absolute;
  bottom: 20px;
  right: 16px;
  background: rgba(15, 20, 32, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  padding: 14px 16px;
  z-index: 1000;
  max-width: 200px;
}

#legend h4 {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 6px 0;
}

/* ---- 出租车标记 ---- */
.taxi-marker {
  background: transparent !important;
  border: none !important;
}

.taxi-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 4px var(--glow), 0 1px 3px rgba(0, 0, 0, 0.4);
  position: relative;
  transition: transform 0.1s;
}

.taxi-dot.occupied {
  animation: taxiPulse 1.5s ease-in-out infinite;
}

@keyframes taxiPulse {
  0%, 100% {
    box-shadow: 0 0 4px var(--glow), 0 0 0 0 var(--glow);
  }
  50% {
    box-shadow: 0 0 8px var(--glow), 0 0 0 6px transparent;
  }
}

/* ---- POI 标记 ---- */
.poi-marker {
  background: transparent !important;
  border: none !important;
}

.poi-pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--poi-color);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.poi-pin:hover {
  transform: scale(1.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 10000;
}

.poi-icon {
  font-size: 13px;
  line-height: 1;
}

.poi-label {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 500;
  color: #1a1a2e;
  background: rgba(255, 255, 255, 0.92);
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.poi-pin:hover .poi-label {
  opacity: 1;
}

/* ---- Popup 样式 ---- */
.leaflet-popup-content-wrapper {
  background: rgba(15, 20, 32, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  color: #e8eaf0;
}

.leaflet-popup-content {
  margin: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  min-width: 180px;
}

.leaflet-popup-tip {
  background: rgba(15, 20, 32, 0.95);
}

.leaflet-popup-close-button {
  color: rgba(255, 255, 255, 0.5) !important;
}

.popup-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.popup-cat {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.popup-desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 8px;
}

.popup-meta {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  font-family: monospace;
}

.popup-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.popup-status.occupied { color: #ef5350; }
.popup-status.cruising { color: #64b5f6; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.popup-route {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 4px;
}

.popup-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  margin: 8px 0;
  overflow: hidden;
}

.popup-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #FF9800, #F44336);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

/* ---- Leaflet 控件美化 ---- */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom a {
  background: rgba(15, 20, 32, 0.88) !important;
  backdrop-filter: blur(20px);
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 8px !important;
  margin-bottom: 4px !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(33, 150, 243, 0.3) !important;
}

.leaflet-bar {
  border: none !important;
}

/* ---- 响应式 ---- */
@media (max-width: 768px) {
  #control-panel {
    width: 280px;
    max-height: calc(100vh - 180px);
  }

  #time-controller {
    width: calc(100vw - 32px);
    left: 16px;
    transform: none;
  }

  #legend {
    display: none;
  }
}
