/* ===================================================
   台风实时追踪系统 - 暗色主题样式
   =================================================== */

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

:root {
  --bg-dark:      #0d1117;
  --bg-panel:     #161b22;
  --bg-card:      #21262d;
  --bg-hover:     #30363d;
  --border:       #30363d;
  --text-primary: #e6edf3;
  --text-secondary:#8b949e;
  --accent:       #1f6feb;
  --accent-light: #4fc3f7;
  --success:      #3fb950;
  --warning:      #d29922;
  --danger:       #f85149;
  --topbar-h:     52px;
  --sidebar-w:    320px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
}

/* ===== 顶部导航栏 ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(13,17,23,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 2000;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-icon {
  font-size: 22px;
  color: var(--accent-light);
  animation: spin-slow 8s linear infinite;
}

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

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-primary);
}

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 20px;
}

.update-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 8px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* 风场按钮激活态 */
.btn-icon.active {
  background: rgba(79,195,247,0.18);
  border-color: var(--accent-light);
  color: var(--accent-light);
  box-shadow: 0 0 8px rgba(79,195,247,0.35);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 主体布局 ===== */
.main-layout {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  display: flex;
}

/* ===== 侧栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .3s ease, min-width .3s ease;
  z-index: 1000;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== 面板卡片 ===== */
.panel {
  margin: 10px 10px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.panel:last-child { margin-bottom: 10px; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
}

/* ===== 台风列表 ===== */
.typhoon-list {
  padding: 6px;
}

.typhoon-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .2s;
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.typhoon-item:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.typhoon-item.active {
  background: rgba(31,111,235,0.15);
  border-color: var(--accent);
}

.typhoon-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.typhoon-info { flex: 1; min-width: 0; }

.typhoon-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.typhoon-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.typhoon-grade {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ===== 台风详情 ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  margin: 0;
}

.detail-item {
  background: var(--bg-card);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.detail-unit {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ===== 图例 ===== */
.legend {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-line {
  width: 20px; height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.legend-line.dashed {
  background: repeating-linear-gradient(
    to right,
    #ff8a65 0, #ff8a65 4px,
    transparent 4px, transparent 7px
  ) !important;
  height: 3px;
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  opacity: 0.8;
}

/* ===== 气象数据 ===== */
.weather-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.weather-item {
  background: var(--bg-card);
  padding: 10px 12px;
  text-align: center;
}

.weather-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.weather-label {
  font-size: 10px;
  color: var(--text-secondary);
}

.weather-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== 强度图例 ===== */
.intensity-legend {
  padding: 8px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.intensity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 5px currentColor;
}

/* ===== 折叠按钮 ===== */
.btn-toggle {
  position: absolute;
  left: var(--sidebar-w);
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 48px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  z-index: 1100;
  border-radius: 0 4px 4px 0;
  transition: left .3s ease;
}

.btn-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.sidebar.collapsed ~ .btn-toggle {
  left: 0;
}

/* ===== 地图 ===== */
#map {
  flex: 1;
  height: 100%;
}

/* Leaflet 暗色覆盖 */
.leaflet-container {
  background: #0e1520 !important;
}

/* ===== 加载遮罩 ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,17,23,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.loading-box {
  text-align: center;
  color: var(--text-primary);
}

.loading-logo {
  font-size: 48px;
  color: var(--accent-light);
  display: block;
  margin-bottom: 16px;
}

.loading-box p {
  font-size: 15px;
  color: var(--text-secondary);
}

.loading-placeholder {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== 无台风提示 ===== */
.no-typhoon-msg {
  position: fixed;
  top: 50%;
  left: calc(50% + var(--sidebar-w) / 2);
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-secondary);
  z-index: 500;
  pointer-events: none;
}

.no-typhoon-msg i {
  font-size: 48px;
  color: var(--warning);
  display: block;
  margin-bottom: 12px;
}

.no-typhoon-msg p {
  font-size: 16px;
  color: var(--text-primary);
}

.no-typhoon-msg small {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: block;
}

/* ===== 台风路径弹窗 ===== */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  color: var(--text-primary) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  min-width: 200px;
}

.popup-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  color: var(--text-secondary);
}

.popup-row span:last-child {
  color: var(--text-primary);
  font-weight: 600;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .topbar-title { font-size: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
}
