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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: #f5f5f5;
}

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* 侧边栏 */
.sidebar {
  width: 320px;
  background: #fff;
  padding: 20px;
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  z-index: 1000;
}

.sidebar h1 {
  font-size: 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 刷新按钮 */
.refresh-btn {
  width: 100%;
  padding: 12px;
  background: #52c41a;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.refresh-btn:hover {
  background: #389e0d;
}

.refresh-btn:disabled {
  background: #d9d9d9;
  cursor: not-allowed;
}

.refresh-status {
  font-size: 12px;
  color: #666;
  margin-top: 8px;
  text-align: center;
}

.section {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0e0e0;
}

.section:last-child {
  border-bottom: none;
}

.section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
}

/* 搜索框 */
.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.search-box input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: #1890ff;
}

.search-box button {
  padding: 10px 16px;
  background: #1890ff;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.search-box button:hover {
  background: #096dd9;
}

.search-status {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

/* 地图类型切换按钮 */
.map-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.map-toggle button {
  flex: 1;
  padding: 10px;
  border: 2px solid #e0e0e0;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.map-toggle button:hover {
  border-color: #1890ff;
  color: #1890ff;
}

.map-toggle button.active {
  background: #1890ff;
  color: #fff;
  border-color: #1890ff;
}

/* 快捷筛选按钮 */
.quick-filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-filter {
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  text-align: left;
}

.quick-filter:hover {
  border-color: #1890ff;
  color: #1890ff;
  background: #f0f7ff;
}

.quick-filter.active {
  background: #1890ff;
  color: #fff;
  border-color: #1890ff;
  font-weight: 500;
}

/* 复选框样式 */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.checkbox-item:hover {
  background: #f0f0f0;
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-item label {
  cursor: pointer;
  font-size: 14px;
}

/* 统计信息 */
.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
}

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

.stat-value {
  font-weight: 600;
  color: #1890ff;
}

/* 用户位置卡片 */
.location-card {
  background: #f0f7ff;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
}

.location-card strong {
  display: block;
  margin-bottom: 6px;
  color: #333;
}

/* 定位按钮 */
.locate-btn {
  width: 100%;
  padding: 12px;
  background: #722ed1;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.locate-btn:hover {
  background: #531dab;
}

.location-status {
  font-size: 12px;
  color: #666;
  margin-top: 8px;
  text-align: center;
}

.location-actions {
  margin-top: 12px;
}

.sort-btn {
  width: 100%;
  padding: 10px;
  background: #fa8c16;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.sort-btn:hover {
  background: #d46b08;
}

.sort-btn:disabled {
  background: #d9d9d9;
  cursor: not-allowed;
}

/* 地图区域 */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  height: 100%;
  width: 100%;
}

/* 自定义 Popup 样式 */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  padding: 0;
}

.popup-content {
  padding: 16px;
  min-width: 280px;
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.popup-influence {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.popup-influence .score {
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 4px;
}

.popup-influence .level {
  font-size: 13px;
  color: #666;
}

.popup-type {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  margin-top: 8px;
  background: #e0e0e0;
  color: #333;
}

.popup-metadata {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e0e0e0;
  font-size: 12px;
  color: #666;
}

.popup-metadata div {
  margin-bottom: 4px;
}

.popup-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: #1890ff;
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 6px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.popup-btn:hover {
  background: #096dd9;
}

/* 扩散动画 */
@keyframes pulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.3;
  }
  100% {
    opacity: 0.6;
  }
}

.pulse-circle {
  animation: pulse 3s ease-in-out infinite;
}

/* 热点图例 */
.legend {
  background: white;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  font-size: 12px;
}

.legend-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
  }

  .map-container {
    height: 60vh;
  }
}

/* 距离筛选按钮 */
.distance-filter {
  margin-top: 15px;
}

.distance-filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.distance-filter-btn {
  flex: 1;
  min-width: 60px;
  padding: 8px 12px;
  background: #f0f0f0;
  color: #666;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.distance-filter-btn:hover {
  background: #e6f7ff;
  border-color: #1890ff;
  color: #1890ff;
}

.distance-filter-btn.active {
  background: #1890ff;
  color: white;
  border-color: #1890ff;
}

.distance-filter-btn:active {
  transform: scale(0.98);
}

/* ============ 定位按钮样式 ============ */

.location-control {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  padding: 6px;
  z-index: 1000;
}

.location-button {
  width: 40px;
  height: 40px;
  background: #fff;
  border: 2px solid #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: all 0.2s;
  font-size: 20px;
}

.location-button:hover {
  background: #f5f5f5;
  border-color: #1890ff;
  color: #1890ff;
}

.location-button:active {
  transform: scale(0.95);
}

.location-button.locating {
  color: #1890ff;
  border-color: #1890ff;
  background: #e6f7ff;
}

.location-button.located {
  color: #52c41a;
  border-color: #52c41a;
  background: #f6ffed;
}

.location-button.error {
  color: #ff4d4f;
  border-color: #ff4d4f;
}

/* 旋转动画 */
.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ============ 位置标记样式 ============ */

.user-marker {
  background: transparent !important;
  border: none !important;
}

.location-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.location-marker-inner {
  position: relative;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.location-dot {
  width: 14px;
  height: 14px;
  background: #1890ff;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
  z-index: 2;
}

.location-pulse {
  position: absolute;
  width: 30px;
  height: 30px;
  background: #1890ff;
  border-radius: 50%;
  opacity: 0.4;
  z-index: 1;
  animation: pulse-location 2s ease-out infinite;
}

@keyframes pulse-location {
  0% {
    transform: scale(0.8);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* 位置 popup 样式 */
.location-popup {
  font-size: 13px;
  min-width: 150px;
}

.location-popup h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.location-info {
  color: #666;
  line-height: 1.6;
}

.location-info div {
  margin-bottom: 4px;
}

/* ============ Toast 提示样式 ============ */

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10000;
  animation: slide-down 0.3s ease-out;
}

.toast.error {
  background: #ff4d4f;
}

.toast.success {
  background: #52c41a;
}

.toast.info {
  background: #1890ff;
}

.toast.fade-out {
  animation: fade-out 0.3s ease-in forwards;
}

@keyframes slide-down {
  from {
    transform: translate(-50%, -20px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ============ 距离统计样式 ============ */

.distance-stats {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
}

.distance-stats .stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}

.distance-stats .stat-item span:first-child {
  color: #666;
}

.distance-stats .stat-value {
  font-weight: 600;
  color: #1890ff;
  font-size: 14px;
}

/* 距离筛选按钮禁用状态 */
.distance-filter-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f5f5f5;
}

.distance-filter-btn.disabled:hover {
  background: #f5f5f5;
  border-color: #d9d9d9;
  color: #666;
}

/* ============ Popup 导航按钮样式 ============ */

.popup-nav {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e0e0e0;
}

.nav-btn {
  display: inline-block;
  padding: 6px 12px;
  background: #1890ff;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: #096dd9;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(24, 144, 255, 0.2);
}

/* ============ Popup 距离显示样式 ============ */

.popup-distance {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e0e0e0;
}

.popup-distance .distance-label {
  font-size: 14px;
  font-weight: 500;
  color: #1890ff;
}
