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

:root {
  --bg-primary: #0a0a14;
  --bg-secondary: #12122a;
  --bg-panel: #16163a;
  --bg-hover: #1e1e4a;
  --text-primary: #e0e0f0;
  --text-secondary: #8888aa;
  --accent: #00ccff;
  --accent-glow: rgba(0, 204, 255, 0.15);
  --danger: #ff4455;
  --warning: #ffaa22;
  --success: #22dd66;
  --border: #2a2a4a;
  --radius: 8px;
  --radius-sm: 4px;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-sans: 'Inter', 'Segoe UI', 'Helvetica Neue', sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
}

#app {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* ===== LEFT SIDEBAR ===== */
#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(18, 18, 42, 0.95) 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  backdrop-filter: blur(12px);
  overflow-y: auto;
  transition: transform 0.3s ease;
}

#sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

#sidebar-header .logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--bg-primary);
  box-shadow: 0 0 20px var(--accent-glow);
}

#sidebar-header h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

#sidebar-header .badge {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 10px;
  letter-spacing: 1px;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 2px;
}

/* Source Toggle Items */
#source-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

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

.source-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.source-item .toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.source-item.active .toggle {
  background: var(--accent);
}

.source-item .toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  transition: left 0.2s ease;
}

.source-item.active .toggle::after {
  left: 19px;
}

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

.source-item .source-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.source-item .source-desc {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-item .source-count {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}

/* Refresh Button */
#refresh-btn {
  padding: 10px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  margin-top: auto;
}

#refresh-btn:hover {
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}

#refresh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== GLOBE CONTAINER ===== */
#globe-container {
  flex: 1;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

#globe-container canvas {
  display: block;
}

/* ===== HOTSPOTS PANEL ===== */
#hotspots-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 320px;
  max-height: calc(100% - 32px);
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(18, 18, 42, 0.95) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  overflow: hidden;
}

#hotspots-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

#hotspots-header h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#hotspots-header .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 68, 85, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255, 68, 85, 0); }
}

#hotspots-count {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

#hotspots-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.hotspot-item {
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.hotspot-item .hotspot-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.hotspot-item .hotspot-loc {
  font-size: 10px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.hotspot-item .hotspot-tag {
  display: inline-block;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 4px;
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-quake { background: rgba(255, 68, 85, 0.2); color: var(--danger); }
.tag-disaster { background: rgba(255, 170, 34, 0.2); color: var(--warning); }
.tag-conflict { background: rgba(255, 68, 85, 0.15); color: #ff6680; }
.tag-weather { background: rgba(0, 204, 255, 0.2); color: var(--accent); }
.tag-news { background: rgba(34, 221, 102, 0.2); color: var(--success); }

/* ===== BOTTOM STATUS BAR ===== */
#status-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 6px 16px;
  background: rgba(18, 18, 42, 0.85);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
  display: flex;
  gap: 16px;
  align-items: center;
  backdrop-filter: blur(8px);
}

#status-bar .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 3s infinite;
}

/* ===== ZOOM CONTROLS ===== */
#zoom-controls {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 8px;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(18, 18, 42, 0.85);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.zoom-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* ===== MUSIC TOGGLE ===== */
#music-toggle {
  position: absolute;
  top: 16px;
  left: 296px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(18, 18, 42, 0.85);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

#music-toggle:hover {
  border-color: var(--accent);
}

#music-toggle.muted {
  opacity: 0.5;
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ===== TOOLTIP ===== */
.globe-tooltip {
  position: absolute;
  padding: 8px 12px;
  background: rgba(10, 10, 20, 0.95);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  max-width: 220px;
}

.globe-tooltip .tt-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.globe-tooltip .tt-detail {
  font-size: 10px;
  color: var(--text-secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    width: 260px;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #hotspots-panel {
    width: 260px;
    right: 4px;
    top: 8px;
    max-height: calc(100% - 16px);
  }

  #chat-panel {
    width: 260px;
    right: 4px;
    bottom: 8px;
  }

  #music-toggle {
    left: 8px;
  }

  #hamburger {
    display: flex !important;
  }
}

#hamburger {
  display: none;
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 20;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(18, 18, 42, 0.85);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

/* ===== CHAT PANEL ===== */
#chat-panel {
  position: absolute;
  bottom: 56px;
  right: 16px;
  width: 320px;
  max-height: 260px;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(18, 18, 42, 0.95) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  overflow: hidden;
}

#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-header h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

#chat-count {
  font-size: 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  min-height: 50px;
}

.chat-msg {
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg .chat-author {
  font-weight: 600;
  color: var(--accent);
  margin-right: 4px;
}

.chat-msg .chat-text {
  color: var(--text-primary);
}

.chat-msg.chat-system .chat-text {
  color: var(--text-secondary);
  font-style: italic;
}

#chat-input-row {
  display: flex;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg-panel);
  border: none;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
}

#chat-input::placeholder {
  color: var(--text-secondary);
}

#chat-send {
  width: 40px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s ease;
}

#chat-send:hover {
  background: #33ddff;
}
