/* ============================================================
   ArlingtonBlack Interactive Community Map — Styles
   Dark theme, green accent, semi-transparent toggle panel
   ============================================================ */

/* --- Map Container --- */
#map {
  width: 100%;
  height: calc(100vh - var(--nav-height, 68px));
  min-height: 500px;
  position: relative;
}

/* MapLibre popup overrides — high specificity to beat CDN defaults */
.maplibregl-popup-content,
.maplibregl-popup-content-wrapper {
  background: var(--color-surface, #0D2918) !important;
  color: var(--color-text, #E8F5EE) !important;
  border: 1px solid var(--color-border, #0F3D22) !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  font-family: 'Inter', system-ui, sans-serif !important;
  font-size: 0.875rem;
  max-width: 300px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
}

.maplibregl-popup-content a {
  color: var(--color-accent, #18DB67) !important;
  text-decoration: none;
}

.maplibregl-popup-content a:hover {
  text-decoration: underline;
}

.maplibregl-popup-content h3 {
  font-family: 'Playfair Display', Georgia, serif !important;
  font-size: 1.05rem !important;
  color: var(--color-accent, #18DB67) !important;
  margin: 0 0 4px !important;
  line-height: 1.2 !important;
}

.maplibregl-popup-content .popup-subtitle {
  font-size: 0.8rem !important;
  color: var(--color-text-muted, #7CB899) !important;
  margin-bottom: 8px !important;
}

.maplibregl-popup-content .popup-detail {
  margin: 2px 0 !important;
  font-size: 0.8rem !important;
  color: var(--color-text, #E8F5EE) !important;
}

.maplibregl-popup-close-button {
  color: var(--color-text-muted, #7CB899) !important;
  font-size: 1rem !important;
  padding: 4px 8px !important;
}

.maplibregl-popup-tip {
  border-top-color: var(--color-surface, #0D2918) !important;
  border-bottom-color: var(--color-surface, #0D2918) !important;
}

/* --- Layer Toggle Panel --- */
.map-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  background: rgba(3, 3, 3, 0.92);
  border: 1px solid var(--color-border, #0F3D22);
  border-radius: 12px;
  padding: 16px;
  min-width: 200px;
  max-width: 260px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.map-panel h4 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 0.95rem;
  color: var(--color-text, #E8F5EE);
  margin: 0 0 4px;
}

.map-panel .panel-section {
  margin-bottom: 12px;
}

.map-panel .panel-section:last-child {
  margin-bottom: 0;
}

.map-panel .city-filter {
  margin-bottom: 12px;
}

.map-panel .city-filter select {
  width: 100%;
  background: var(--color-surface, #0D2918);
  color: var(--color-text, #E8F5EE);
  border: 1px solid var(--color-border, #0F3D22);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-family: 'Inter', system-ui, sans-serif;
}

.map-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--color-text, #E8F5EE);
  cursor: pointer;
  padding: 3px 0;
}

.map-panel label:hover {
  color: var(--color-accent, #18DB67);
}

.map-panel .layer-count {
  color: var(--color-text-muted, #7CB899);
  font-size: 0.75rem;
  margin-left: auto;
}

.map-panel .sub-labels {
  margin-left: 20px;
  border-left: 1px solid var(--color-border, #0F3D22);
  padding-left: 8px;
}

.map-panel .legend {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border, #0F3D22);
}

.map-panel .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--color-text-muted, #7CB899);
}

.legend-item strong {
  color: var(--color-text, #E8F5EE);
}

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

/* Color swatches for map circle layers */
.swatch-business { border-radius: 2px; }
.swatch-official-dem { background: #3B82F6; }
.swatch-official-rep { background: #EF4444; }
.swatch-official-other { background: #6B7280; }

/* --- Loading / Error States --- */
.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--color-text-muted, #7CB899);
  font-size: 0.9rem;
  z-index: 5;
  text-align: center;
}

.map-loading .spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border, #0F3D22);
  border-top-color: var(--color-accent, #18DB67);
  border-radius: 50%;
  animation: map-spin 0.8s linear infinite;
  margin-bottom: 8px;
}

@keyframes map-spin {
  to { transform: rotate(360deg); }
}

.map-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #EF4444;
  font-size: 0.9rem;
  z-index: 5;
  text-align: center;
  padding: 20px;
  background: rgba(3,3,3,0.85);
  border-radius: 12px;
  border: 1px solid #EF4444;
}

/* MapLibre navigation controls */
.maplibregl-ctrl-top-right {
  top: 12px;
  right: 12px;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  #map {
    height: calc(100vh - var(--nav-height, 68px) - 50px);
  }

  .map-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    max-height: 45vh;
    border-radius: 12px 12px 0 0;
    padding: 12px;
    background: rgba(3, 3, 3, 0.96);
  }

  .map-panel .sub-labels {
    margin-left: 12px;
  }

  .map-panel .panel-section {
    margin-bottom: 8px;
  }

  /* Mobile toggle bar */
  .map-panel-collapsed {
    height: auto;
    max-height: 48px;
    overflow: hidden;
  }

  .map-panel .panel-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 8px;
  }

  .map-panel .panel-toggle::after {
    content: '▲';
    font-size: 0.75rem;
    color: var(--color-accent, #18DB67);
  }

  .map-panel-collapsed .panel-toggle::after {
    content: '▼';
  }
}

@media (min-width: 769px) {
  .map-panel .panel-toggle {
    display: none;
  }
}