/* ==========================================================================
   BarrioRadar - Interactive Neighbourhood Map Widget V2 (embed/map.html)
   Isolated styles using system UI font stack (zero external font dependencies)
   ========================================================================== */

:root {
  --mv2-accent: #10B981;
  --mv2-accent-soft: rgba(16, 185, 129, 0.14);
  --mv2-bg: #FFFFFF;
  --mv2-bg-subtle: #F8FAFC;
  --mv2-border: #E2E8F0;
  --mv2-text: #0F172A;
  --mv2-text-secondary: #475569;
  --mv2-text-muted: #64748B;
  --mv2-card-bg: #FFFFFF;
  --mv2-card-active: #F0FDF4;
  --mv2-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --mv2-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mv2-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

body.map-v2-body[data-theme="dark"] {
  --mv2-bg: #0F172A;
  --mv2-bg-subtle: #1E293B;
  --mv2-border: #334155;
  --mv2-text: #F8FAFC;
  --mv2-text-secondary: #CBD5E1;
  --mv2-text-muted: #94A3B8;
  --mv2-card-bg: #1E293B;
  --mv2-card-active: rgba(16, 185, 129, 0.16);
  --mv2-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

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

html,
body.map-v2-body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--mv2-font-sans);
  background: var(--mv2-bg);
  color: var(--mv2-text);
  -webkit-font-smoothing: antialiased;
}

.map-v2-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  background: var(--mv2-bg);
  border: 1px solid var(--mv2-border);
  border-radius: 12px;
  overflow: hidden;
}

.map-v2-active {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Header */
.map-v2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--mv2-bg);
  border-bottom: 1px solid var(--mv2-border);
  flex-shrink: 0;
}

.map-v2-header-left {
  min-width: 0;
  flex: 1;
}

.map-v2-badge-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.map-v2-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--mv2-accent-soft);
  color: var(--mv2-accent);
  border: 1px solid var(--mv2-accent);
}

.map-v2-mode-badge[data-mode="exact"] {
  background: rgba(245, 158, 11, 0.15);
  color: #D97706;
  border-color: #F59E0B;
}

.map-v2-municipality-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--mv2-text-muted);
}

.map-v2-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--mv2-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-v2-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--mv2-text-secondary);
  background: var(--mv2-bg-subtle);
  border: 1px solid var(--mv2-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.map-v2-reset-btn:hover {
  border-color: var(--mv2-accent);
  color: var(--mv2-accent);
}

/* Category Tabs */
.map-v2-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--mv2-bg-subtle);
  border-bottom: 1px solid var(--mv2-border);
  overflow-x: auto;
  scrollbar-width: thin;
  flex-shrink: 0;
}

.map-v2-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--mv2-border);
  background: var(--mv2-card-bg);
  color: var(--mv2-text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.map-v2-tab-btn:hover {
  border-color: var(--mv2-accent);
  color: var(--mv2-text);
}

.map-v2-tab-btn.is-active {
  background: var(--mv2-accent);
  border-color: var(--mv2-accent);
  color: #FFFFFF;
}

.map-v2-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-family: var(--mv2-font-mono);
  font-size: 11px;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.08);
  color: inherit;
}

.map-v2-tab-btn.is-active .map-v2-tab-count {
  background: rgba(255, 255, 255, 0.24);
  color: #FFFFFF;
}

/* Map Canvas */
.map-v2-canvas-wrap {
  position: relative;
  flex: 1 1 440px;
  min-height: 260px;
  width: 100%;
  background: #E2E8F0;
}

.map-v2-canvas {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Mobile Two-Finger Gesture Hint Overlay */
.map-v2-touch-hint {
  position: absolute;
  inset: 0;
  z-index: 650;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.48);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.map-v2-touch-hint.is-visible {
  opacity: 1;
}

/* Map Legend Overlay */
.map-v2-legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
  font-size: 11px;
  font-weight: 600;
  color: #1E293B;
  pointer-events: none;
}

body.map-v2-body[data-theme="dark"] .map-v2-legend {
  background: rgba(15, 23, 42, 0.9);
  border-color: #334155;
  color: #E2E8F0;
}

.map-v2-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.map-v2-legend-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.map-v2-swatch-boundary {
  border-radius: 3px;
  background: var(--mv2-accent-soft);
  border: 2px solid var(--mv2-accent);
}

.map-v2-swatch-inside {
  background: var(--mv2-accent);
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 0 1px var(--mv2-accent);
}

.map-v2-swatch-nearby {
  background: #FFFFFF;
  border: 2px dashed var(--mv2-accent);
}

.map-v2-swatch-exact {
  background: #EF4444;
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 0 1px #EF4444;
}

/* Custom Leaflet DivIcon Markers */
.mv2-pin-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mv2-pin {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mv2-font-mono);
  font-size: 11px;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mv2-pin--inside {
  background: var(--mv2-accent);
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.28);
}

.mv2-pin--nearby {
  background: #FFFFFF;
  color: #0F172A;
  border: 2px solid var(--mv2-accent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.mv2-pin--exact {
  width: 32px;
  height: 32px;
  background: #EF4444;
  color: #FFFFFF;
  border: 3px solid #FFFFFF;
  box-shadow: 0 3px 10px rgba(239, 68, 68, 0.5);
}

.mv2-pin.is-highlighted {
  transform: scale(1.26);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95), 0 0 0 6px var(--mv2-accent), 0 4px 12px rgba(15, 23, 42, 0.35);
  z-index: 950;
}

/* Cluster Markers & Spiderfy Legs */
.mv2-cluster-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mv2-cluster {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mv2-font-mono);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mv2-cluster:hover {
  transform: scale(1.1);
}

.mv2-cluster--inside {
  background: var(--mv2-accent);
  color: #FFFFFF;
  border: 2.5px solid #FFFFFF;
  box-shadow: 0 0 0 3px var(--mv2-accent-soft), 0 3px 10px rgba(15, 23, 42, 0.3);
}

.mv2-cluster--nearby {
  background: #FFFFFF;
  color: #0F172A;
  border: 2.5px dashed var(--mv2-accent);
  box-shadow: 0 0 0 3px var(--mv2-accent-soft), 0 3px 10px rgba(15, 23, 42, 0.22);
}

.mv2-cluster--mixed {
  background: var(--mv2-accent);
  color: #FFFFFF;
  border: 2.5px dashed #FFFFFF;
  box-shadow: 0 0 0 2px var(--mv2-accent), 0 3px 10px rgba(15, 23, 42, 0.3);
}

.mv2-cluster.is-highlighted {
  transform: scale(1.16);
  box-shadow: 0 0 0 3px #FFFFFF, 0 0 0 6px var(--mv2-accent), 0 4px 12px rgba(15, 23, 42, 0.35);
}

/* Leaflet Popup Styling */
.mv2-popup {
  font-family: var(--mv2-font-sans);
  min-width: 210px;
  max-width: 260px;
  color: #0F172A;
}

.mv2-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.mv2-popup-subcat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mv2-accent);
}

.mv2-popup-scope {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: #F1F5F9;
  color: #475569;
}

.mv2-popup-name {
  margin: 0 0 6px 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: #0F172A;
}

.mv2-popup-routes {
  margin: 6px 0 6px 0;
  padding-top: 6px;
  border-top: 1px solid #E2E8F0;
}

.mv2-popup-routes-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748B;
  margin-bottom: 4px;
}

.mv2-route-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.mv2-route-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  min-width: 22px;
  border-radius: 5px;
  font-family: var(--mv2-font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1D4ED8;
  white-space: nowrap;
}

.mv2-route-badge--tram {
  background: #FFFBEB;
  border-color: #FDE68A;
  color: #B45309;
}

.mv2-route-badge--metro,
.mv2-route-badge--rail {
  background: #ECFDF5;
  border-color: #A7F3D0;
  color: #047857;
}

.mv2-route-badge--sm {
  padding: 1px 5px;
  min-width: 19px;
  font-size: 9.5px;
  border-radius: 4px;
}

.mv2-route-badge--more {
  background: #F1F5F9;
  border-color: #CBD5E1;
  color: #475569;
}

.mv2-route-badge.is-hidden {
  display: none;
}

.mv2-route-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid #CBD5E1;
  background: #F8FAFC;
  color: #334155;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  transition: all 0.12s ease;
}

.mv2-route-more-btn:hover {
  border-color: var(--mv2-accent);
  color: var(--mv2-accent);
  background: #FFFFFF;
}

.mv2-popup-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #334155;
  border-top: 1px solid #E2E8F0;
  padding-top: 6px;
}

.mv2-popup-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.mv2-popup-meta-label {
  color: #64748B;
  font-weight: 600;
}

.mv2-popup-meta-val {
  font-weight: 600;
  text-align: right;
  color: #0F172A;
}

/* Horizontal POI Strip & Navigation Arrows */
.map-v2-poi-strip-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--mv2-bg-subtle);
  border-top: 1px solid var(--mv2-border);
  padding: 10px 10px;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.map-v2-carousel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--mv2-border);
  background: var(--mv2-card-bg);
  color: var(--mv2-text-secondary);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: all 0.15s ease;
}

.map-v2-carousel-btn:hover:not(:disabled) {
  border-color: var(--mv2-accent);
  color: var(--mv2-accent);
  transform: scale(1.05);
}

.map-v2-carousel-btn:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.map-v2-poi-strip {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 4px 2px;
  scrollbar-width: thin;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.map-v2-poi-card {
  flex: 0 0 232px;
  min-width: 232px;
  max-width: 232px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--mv2-card-bg);
  border: 1.5px solid var(--mv2-border);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
}

.map-v2-poi-card:hover {
  border-color: var(--mv2-accent);
}

.map-v2-poi-card.is-selected {
  border-color: var(--mv2-accent);
  background: var(--mv2-card-active);
  box-shadow: 0 0 0 2px var(--mv2-accent-soft), 0 2px 8px rgba(15, 23, 42, 0.08);
}

.map-v2-poi-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.map-v2-poi-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-family: var(--mv2-font-mono);
  font-size: 10px;
  font-weight: 700;
  background: var(--mv2-accent);
  color: #FFFFFF;
  flex-shrink: 0;
}

.map-v2-poi-card[data-scope="nearby_area"] .map-v2-poi-index {
  background: transparent;
  color: var(--mv2-text);
  border: 1.5px solid var(--mv2-accent);
}

.map-v2-poi-subcat {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--mv2-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-v2-poi-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--mv2-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  min-height: 17px;
}

.map-v2-poi-detail {
  font-size: 11px;
  color: var(--mv2-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-v2-poi-routes {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 3px;
  overflow: hidden;
  min-height: 18px;
}

.map-v2-empty-msg {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--mv2-text-muted);
}

/* Footer */
.map-v2-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 14px;
  background: var(--mv2-bg);
  border-top: 1px solid var(--mv2-border);
  font-size: 11px;
  color: var(--mv2-text-muted);
  flex-shrink: 0;
}

.map-v2-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--mv2-text);
  text-decoration: none;
  white-space: nowrap;
}

.map-v2-brand-link:hover {
  color: var(--mv2-accent);
}

/* Inactive View */
.map-v2-inactive {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  padding: 32px 24px;
  gap: 10px;
}

.map-v2-inactive-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--mv2-bg-subtle);
  border: 1px solid var(--mv2-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--mv2-text-muted);
}

.map-v2-inactive-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--mv2-text);
}

.map-v2-inactive-desc {
  margin: 0;
  max-width: 400px;
  font-size: 13px;
  color: var(--mv2-text-secondary);
}

@media (max-width: 560px) {
  .map-v2-canvas-wrap {
    flex: 1 1 340px;
    min-height: 220px;
  }
  .map-v2-header {
    padding: 10px 12px;
  }
  .map-v2-title {
    font-size: 14px;
  }
  .map-v2-reset-btn span {
    display: none;
  }
  .map-v2-poi-card {
    flex: 0 0 198px;
    min-width: 198px;
    max-width: 198px;
  }
  .map-v2-footer {
    justify-content: flex-end;
    gap: 6px;
  }
}
