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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

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

/* --- Sidebar --- */

#sidebar {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 340px;
  max-height: calc(100vh - 24px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  font-size: 13px;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #111;
  margin-bottom: 8px;
}

/* --- Status indicator --- */

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}

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

.status.connected .status-dot {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status.connected {
  color: #16a34a;
}

.status.disconnected .status-dot {
  background: #ef4444;
}

.status.disconnected {
  color: #dc2626;
}

.status.reconnecting .status-dot {
  background: #f59e0b;
  animation: pulse 1s infinite;
}

.status.reconnecting {
  color: #d97706;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Legend --- */

.legend {
  padding: 10px 16px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid #e5e7eb;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555;
}

.legend-swatch {
  width: 20px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid;
}

.legend-swatch.nominatim {
  background: rgba(59, 130, 246, 0.2);
  border-color: #2563eb;
}

.legend-swatch.maptiler {
  background: rgba(249, 115, 22, 0.2);
  border-color: #ea580c;
  border-style: dashed;
}

.legend-swatch.google {
  background: rgba(34, 197, 94, 0.2);
  border-color: #16a34a;
}

.legend-swatch.mapbox {
  background: rgba(168, 85, 247, 0.2);
  border-color: #7c3aed;
}

/* --- Actions --- */

.sidebar-actions {
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.btn {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: #374151;
}

.btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.btn-danger {
  color: #dc2626;
  border-color: #fca5a5;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: #dc2626;
}

/* --- Location list --- */

.location-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.empty-msg {
  text-align: center;
  color: #9ca3af;
  padding: 24px 16px;
  font-size: 12px;
}

.location-card {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.location-card:hover {
  background: #f3f4f6;
}

.location-card.nominatim {
  border-left: 3px solid #2563eb;
}

.location-card.maptiler {
  border-left: 3px solid #ea580c;
}

.location-card.google {
  border-left: 3px solid #16a34a;
}

.location-card.mapbox {
  border-left: 3px solid #7c3aed;
}

.location-card .loc-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.location-card .loc-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.location-card.nominatim .loc-badge {
  background: #dbeafe;
  color: #1e40af;
}

.location-card.maptiler .loc-badge {
  background: #ffedd5;
  color: #c2410c;
}

.location-card.google .loc-badge {
  background: #dcfce7;
  color: #166534;
}

.location-card.mapbox .loc-badge {
  background: #f3e8ff;
  color: #6b21a8;
}

.location-card .loc-query {
  font-weight: 600;
  font-size: 12px;
  color: #111;
}

.location-card .loc-name {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-card .loc-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 14px;
  line-height: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s;
}

.location-card:hover .loc-delete {
  opacity: 1;
}

.location-card .loc-delete:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* --- Scrollbar --- */

.location-list::-webkit-scrollbar {
  width: 4px;
}

.location-list::-webkit-scrollbar-track {
  background: transparent;
}

.location-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}
