/* ==========================================================================
   AI SMART LOCAL AGENT — Interactive GIS Map Styles
   Midnight Navy · Electric Blue & Cyan · Glassmorphic Floating Controls
   ========================================================================== */

.map-page {
  overflow-x: hidden;
}

.map-workspace {
  position: relative;
  margin-top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  min-height: 540px;
  width: 100%;
  overflow: hidden;
  background: var(--bg-midnight);
}

.civic-map {
  width: 100%;
  height: 100%;
  z-index: 1;
  background: var(--bg-midnight);
  cursor: crosshair;
}

/* Dark-Mode OpenStreetMap Tile Styling (only applied to standard light OSM tiles) */
.civic-map.is-osm-inverted .leaflet-tile-pane {
  filter: invert(100%) hue-rotate(180deg) brightness(92%) contrast(94%) saturate(85%);
}

/* Leaflet Zoom & Attribution Controls */
.civic-map .leaflet-control-zoom {
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
  box-shadow: var(--shadow-card) !important;
  margin: 0 16px 24px 0 !important;
}

.civic-map .leaflet-control-zoom a {
  background: var(--glass-bg-strong) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--glass-border) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 1.05rem !important;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.civic-map .leaflet-control-zoom a:last-child {
  border-bottom: none !important;
}

.civic-map .leaflet-control-zoom a:hover {
  background: rgba(34, 211, 238, 0.16) !important;
  color: var(--accent-cyan-bright) !important;
}

.civic-map .leaflet-control-attribution {
  background: rgba(6, 11, 22, 0.82) !important;
  color: var(--text-muted) !important;
  border-top: 1px solid var(--glass-border);
  border-left: 1px solid var(--glass-border);
  border-top-left-radius: 8px;
  font-size: 0.72rem !important;
  padding: 3px 8px !important;
}

.civic-map .leaflet-control-attribution a {
  color: var(--accent-cyan-bright) !important;
}

/* ==========================================================================
   FLOATING FILTER & SEARCH PANEL
   ========================================================================== */

.map-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 500;
  width: 348px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 18px;
  background: rgba(8, 14, 28, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 54px -18px rgba(0, 0, 0, 0.85);
  transition: transform var(--transition-med), opacity var(--transition-med);
}

.map-panel.is-collapsed {
  transform: translateX(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}

.map-panel::-webkit-scrollbar {
  width: 6px;
}

.map-panel::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
}

.map-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.map-panel-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan-bright);
  margin-bottom: 4px;
}

.map-panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.map-panel-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.map-panel-close:hover {
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
}

.map-demo-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(124, 58, 237, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.22);
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.map-demo-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(34, 211, 238, 0.18);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: var(--accent-cyan-bright);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* Search Field */
.map-search-form {
  margin-bottom: 16px;
}

.map-field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.map-search-row {
  display: flex;
  gap: 8px;
}

.map-search-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.map-search-input::placeholder {
  color: var(--text-subtle);
}

.map-search-input:focus {
  border-color: var(--accent-cyan-bright);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.map-search-submit {
  flex-shrink: 0;
  padding-inline: 14px;
}

.map-city-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.city-preset-btn {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.city-preset-btn:hover {
  border-color: rgba(34, 211, 238, 0.45);
  color: var(--accent-cyan-bright);
  background: rgba(34, 211, 238, 0.1);
}

.map-search-status {
  min-height: 18px;
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--accent-cyan-bright);
}

.map-search-status.is-error {
  color: #fca5a5;
}

/* Filter Chips */
.map-filter-group {
  margin-bottom: 14px;
}

.filter-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.filter-chip.is-active {
  background: rgba(37, 99, 235, 0.24);
  border-color: rgba(34, 211, 238, 0.55);
  color: #ffffff;
  box-shadow: 0 4px 14px -4px rgba(6, 182, 212, 0.45);
}

.filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-dot--all { background: var(--accent-cyan-bright); }
.filter-dot--potholes { background: #f59e0b; }
.filter-dot--garbage { background: #10b981; }
.filter-dot--water { background: #22d3ee; }
.filter-dot--drainage { background: #a78bfa; }
.filter-dot--streetlights { background: #60a5fa; }
.filter-dot--other { background: #94a3b8; }

.map-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border);
}

.map-results-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.map-reset-btn {
  background: none;
  border: none;
  color: var(--accent-cyan-bright);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

.map-reset-btn:hover {
  background: rgba(34, 211, 238, 0.12);
}

/* ==========================================================================
   TOP-RIGHT QUICK MAP ACTIONS
   ========================================================================== */

.map-quick-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 490;
  display: flex;
  align-items: center;
  gap: 8px;
}

.glass-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: rgba(8, 14, 28, 0.84);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}

.glass-btn:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-1px);
  color: var(--accent-cyan-bright);
}

.glass-btn--accent {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.86), rgba(6, 182, 212, 0.86));
  border-color: rgba(125, 211, 252, 0.45);
  color: #ffffff;
}

.glass-btn--accent:hover {
  color: #ffffff;
  box-shadow: var(--shadow-glow-cyan);
}

.glass-btn.is-loading {
  opacity: 0.78;
  cursor: wait;
}

/* ==========================================================================
   BOTTOM CLICK-TO-SELECT LOCATION DOCK
   ========================================================================== */

.map-bottom-dock {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 480;
  width: min(520px, calc(100% - 110px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.glass-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: rgba(8, 14, 28, 0.84);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  box-shadow: var(--shadow-card);
  pointer-events: auto;
}

.selected-location-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(8, 14, 28, 0.9);
  border: 1px solid rgba(34, 211, 238, 0.4);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 44px -16px rgba(0, 0, 0, 0.9);
  pointer-events: auto;
}

.selected-location-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-cyan-bright);
  margin-bottom: 2px;
}

.selected-location-coords {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text-primary);
}

.selected-location-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.is-hidden {
  display: none !important;
}

/* ==========================================================================
   CUSTOM GLOWING MARKERS & LEAFLET POPUPS
   ========================================================================== */

.gis-marker-wrap {
  background: transparent;
  border: none;
}

.gis-marker {
  position: relative;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
}

.gis-marker-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0.45;
  animation: gisPulse 2.4s ease-out infinite;
}

.gis-marker-core {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #060b16;
  box-shadow: 0 0 14px currentColor;
  transition: transform 180ms var(--ease-out);
}

.gis-marker:hover .gis-marker-core {
  transform: scale(1.22);
}

.gis-marker--potholes { color: #f59e0b; }
.gis-marker--potholes .gis-marker-core,
.gis-marker--potholes .gis-marker-pulse { background: #f59e0b; }

.gis-marker--garbage { color: #10b981; }
.gis-marker--garbage .gis-marker-core,
.gis-marker--garbage .gis-marker-pulse { background: #10b981; }

.gis-marker--water_leakage { color: #22d3ee; }
.gis-marker--water_leakage .gis-marker-core,
.gis-marker--water_leakage .gis-marker-pulse { background: #22d3ee; }

.gis-marker--drainage { color: #a78bfa; }
.gis-marker--drainage .gis-marker-core,
.gis-marker--drainage .gis-marker-pulse { background: #a78bfa; }

.gis-marker--broken_streetlights { color: #60a5fa; }
.gis-marker--broken_streetlights .gis-marker-core,
.gis-marker--broken_streetlights .gis-marker-pulse { background: #60a5fa; }

.gis-marker--other_civic { color: #94a3b8; }
.gis-marker--other_civic .gis-marker-core,
.gis-marker--other_civic .gis-marker-pulse { background: #94a3b8; }

/* Selected Location Pin */
.gis-selected-pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, #22d3ee 32%, rgba(34, 211, 238, 0.22) 34%);
  border: 2px solid #ffffff;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.85);
}

/* User GPS Pin */
.gis-user-pin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.35);
}

@keyframes gisPulse {
  0% {
    transform: scale(0.7);
    opacity: 0.65;
  }
  100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

/* Dark Glassmorphic Leaflet Popups */
.civic-map .leaflet-popup-content-wrapper,
.civic-map .leaflet-popup-tip {
  background: rgba(10, 17, 34, 0.94) !important;
  color: var(--text-primary) !important;
  border: 1px solid rgba(56, 189, 248, 0.3);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.85) !important;
}

.civic-map .leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
}

.civic-map .leaflet-popup-content {
  margin: 14px 16px !important;
  min-width: 225px;
  max-width: 270px;
  font-family: var(--font-sans);
}

.civic-map .leaflet-popup-close-button {
  color: var(--text-muted) !important;
  padding: 6px 8px 0 0 !important;
}

.civic-map .leaflet-popup-close-button:hover {
  color: var(--accent-cyan-bright) !important;
}

.gis-popup-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.gis-popup-category {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan-bright);
}

.gis-popup-demo {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-muted);
}

.gis-popup-desc {
  margin: 0 0 10px;
  font-size: 0.88rem;
  line-height: 1.48;
  color: var(--text-primary);
}

.gis-popup-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--glass-border);
  font-size: 0.76rem;
}

.gis-popup-status {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.gis-popup-status--reported {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.gis-popup-status--in_progress {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.gis-popup-status--resolved {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.gis-popup-date {
  color: var(--text-muted);
}

/* Feedback Toast */
.map-toast {
  position: absolute;
  top: 68px;
  right: 16px;
  z-index: 510;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(10, 17, 34, 0.94);
  border: 1px solid rgba(34, 211, 238, 0.38);
  color: var(--text-primary);
  font-size: 0.82rem;
  box-shadow: var(--shadow-card);
}

.map-toast.is-error {
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
}

/* ==========================================================================
   RESPONSIVE BEHAVIOR
   ========================================================================== */

@media (max-width: 860px) {
  .map-panel {
    width: min(340px, calc(100% - 24px));
    top: 12px;
    left: 12px;
    max-height: calc(100% - 92px);
  }

  .map-quick-actions {
    top: 12px;
    right: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .map-bottom-dock {
    width: calc(100% - 24px);
    bottom: 14px;
  }

  .civic-map .leaflet-control-zoom {
    margin: 0 12px 92px 0 !important;
  }
}

@media (max-width: 540px) {
  .map-quick-actions {
    gap: 6px;
  }

  .glass-btn {
    padding: 8px 11px;
    font-size: 0.78rem;
  }

  .selected-location-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .selected-location-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gis-marker-pulse {
    animation: none;
  }
}
