/* Price Map - interaktywna mapa cen mieszkań
 * Używana na /mapa-cen-mieszkan i w mini-mapach na stronach lokalnych
 */

/* ===== Hero ===== */
.price-map-hero {
  background: linear-gradient(135deg, #1E3A5F 0%, #1E88E5 50%, #8B5CF6 100%);
  color: white;
  padding: 60px 0 40px;
  text-align: center;
}
.price-map-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 16px;
  line-height: 1.2;
}
.price-map-hero .lead {
  font-size: 1.1rem;
  opacity: 0.92;
  margin: 0 auto 24px;
  max-width: 720px;
}
.price-map-hero-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.price-map-hero-badge {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ===== Selector + Map card ===== */
.price-map-section {
  padding: 40px 0;
  background: #f8faff;
}
.price-map-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(30, 58, 95, 0.08);
  overflow: hidden;
}
.price-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #eef2f7;
  flex-wrap: wrap;
  gap: 12px;
}
.price-map-toolbar h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1E3A5F;
  margin: 0;
}
.price-map-city-select {
  display: flex;
  align-items: center;
  gap: 10px;
}
.price-map-city-select label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin: 0;
}
.price-map-city-select select {
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1E3A5F;
  background: white;
  cursor: pointer;
  min-width: 160px;
}
.price-map-city-select select:focus {
  outline: none;
  border-color: #1E88E5;
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.15);
}

/* ===== Market type tabs ===== */
.price-map-market-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 24px 16px;
  border-bottom: 1px solid #eef2f7;
  flex-wrap: wrap;
}
.price-map-market-tab {
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  transition: all 0.15s;
}
.price-map-market-tab:hover:not(.active) {
  background: #f0f7ff;
  border-color: #c7dcff;
}
.price-map-market-tab.active {
  background: #1E88E5;
  color: white;
  border-color: #1E88E5;
}
.price-map-market-tab:focus-visible {
  outline: 2px solid #1E88E5;
  outline-offset: 2px;
}

/* ===== Map container ===== */
.price-map-container {
  position: relative;
  width: 100%;
  height: 600px;
  background: #e8eef5;
}
.price-map-container.mini {
  height: 400px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
.price-map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  z-index: 1000;
  font-size: 0.95rem;
  color: #64748b;
  font-weight: 600;
}
.price-map-loading.hidden {
  display: none;
}
.price-map-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 241, 230, 0.96);
  z-index: 1000;
  padding: 20px;
  text-align: center;
  color: #92400e;
  font-size: 0.95rem;
}
.price-map-error.hidden {
  display: none;
}

/* ===== Legend ===== */
.price-map-legend {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  padding: 10px 14px;
  font-size: 0.8rem;
  line-height: 1.4;
}
.price-map-legend-title {
  font-weight: 700;
  color: #1E3A5F;
  margin-bottom: 6px;
  font-size: 0.8rem;
}
.price-map-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
  color: #475569;
}
.price-map-legend-swatch {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

/* ===== District panel ===== */
.price-map-panel {
  padding: 20px 24px;
  border-top: 1px solid #eef2f7;
  background: #fafbfd;
  min-height: 120px;
}
.price-map-panel-empty {
  color: #94a3b8;
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0;
}
.price-map-panel-district {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .price-map-panel-district {
    grid-template-columns: 1fr;
  }
}
.price-map-panel-district h3 {
  grid-column: 1 / -1;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1E3A5F;
  margin: 0 0 4px 0;
}
.price-map-panel-note {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: #94a3b8;
  font-style: italic;
  margin-top: -4px;
}
.price-map-stat {
  background: white;
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid #eef2f7;
}
.price-map-stat-label {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.price-map-stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1E3A5F;
  margin-top: 4px;
}
.price-map-stat-unit {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 500;
}
.price-map-panel-source {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: #166534;
  background: #dcfce7;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
  margin-top: 4px;
  width: fit-content;
}

/* ===== Fallback table ===== */
.price-map-table-section {
  padding: 40px 0;
  background: white;
}
.price-map-table-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1E3A5F;
  margin-bottom: 8px;
}
.price-map-table-section .subtitle {
  color: #64748b;
  margin-bottom: 20px;
  font-size: 0.95rem;
}
.price-map-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.price-map-table th {
  background: #f0f7ff;
  color: #1E3A5F;
  font-weight: 600;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 2px solid #dbeafe;
}
.price-map-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.price-map-table tr:hover {
  background: #f8faff;
}
.price-map-table .city-header td {
  background: #e0f2fe;
  font-weight: 700;
  color: #1E3A5F;
  padding: 10px 14px;
}

/* ===== Leaflet overrides ===== */
.leaflet-container {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #eaf3fc;
}
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.leaflet-popup-content {
  margin: 12px 16px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.leaflet-popup-content strong {
  color: #1E3A5F;
  font-size: 1rem;
}
.leaflet-popup-content .popup-price {
  color: #1E88E5;
  font-weight: 800;
  font-size: 1.1rem;
  display: block;
  margin-top: 4px;
}
.leaflet-popup-content .popup-meta {
  color: #64748b;
  font-size: 0.78rem;
  margin-top: 4px;
}
.leaflet-popup-content .popup-source-badge {
  color: #166534;
  background: #dcfce7;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.72rem;
  margin-top: 6px;
}

/* District polygon base style (applied via JS) */
.price-map-district-polygon {
  cursor: pointer;
  transition: fill-opacity 0.2s ease;
}

/* Mini-map on local pages */
.local-mini-map-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin: 32px 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}
.local-mini-map-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1E3A5F;
  margin-bottom: 8px;
}
.local-mini-map-section .mini-map-subtitle {
  color: #64748b;
  margin-bottom: 16px;
  font-size: 0.95rem;
}
.local-mini-map-cta {
  margin-top: 20px;
  text-align: center;
}
.local-mini-map-cta .btn-view-poland {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1E88E5 0%, #8B5CF6 100%);
  color: #ffffff;
  padding: 14px 28px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(30, 136, 229, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  border: none;
  cursor: pointer;
}
.local-mini-map-cta .btn-view-poland:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(30, 136, 229, 0.38);
  text-decoration: none;
  color: #ffffff;
  filter: brightness(1.05);
}
.local-mini-map-cta .btn-view-poland:active {
  transform: translateY(0);
}
.local-mini-map-cta .btn-view-poland svg,
.local-mini-map-cta .btn-view-poland i[data-lucide] {
  width: 18px;
  height: 18px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .price-map-hero h1 {
    font-size: 1.7rem;
  }
  .price-map-hero .lead {
    font-size: 1rem;
  }
  .price-map-container {
    height: 420px;
  }
  .price-map-container.mini {
    height: 320px;
  }
  .price-map-toolbar {
    padding: 16px 18px;
  }
  .price-map-toolbar h2 {
    font-size: 1.1rem;
  }
  .price-map-city-select select {
    min-width: 140px;
    font-size: 0.9rem;
  }
  .price-map-market-tabs {
    padding: 10px 18px 14px;
    gap: 6px;
  }
  .price-map-market-tab {
    padding: 6px 12px;
    font-size: 0.82rem;
  }
  .price-map-panel {
    padding: 16px 18px;
  }
}

/* Confidence tier badges (tiered data quality indicators) */
.confidence-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-left: 6px;
  white-space: nowrap;
  vertical-align: middle;
}
.confidence-low {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.confidence-medium {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* Warning banner in side panel for LOW-confidence districts */
.price-map-panel-warning {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #78350f;
  margin-top: 16px;
}

/* ===============================================================
 * Market type filter UX (Łącznie / Rynek wtórny / Rynek pierwotny)
 * =============================================================== */

/* Subtitle under map toolbar showing active market filter */
.price-map-market-subtitle {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0;
  padding: 0 24px 12px;
}
.price-map-market-subtitle strong {
  color: #1E3A5F;
}

/* ARIA live region (screen-reader only, visually hidden) */
.sr-only-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Persistent market badge on map (Leaflet control, top-left) */
.price-map-market-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #1E88E5;
  color: #fff;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.25);
  border: 2px solid #fff;
  pointer-events: auto;
  user-select: none;
}
.price-map-market-badge-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
}
.market-badge-combined {
  background: #1E88E5;
}
.market-badge-secondary {
  background: #8B5CF6;
}
.market-badge-primary {
  background: #10B981;
}

/* Loading overlay with blur during map re-fetch */
.price-map-container.is-refreshing::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  z-index: 800;
  pointer-events: none;
  animation: priceMapFadeIn 0.2s ease-out;
}
@keyframes priceMapFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Market badge pill in the side panel next to district name */
.price-map-panel-market-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  vertical-align: middle;
  margin-left: 8px;
  white-space: nowrap;
}

/* No-data notice in side panel when district has no values for current filter */
.price-map-panel-nodata {
  background: #f1f5f9;
  border-left: 3px solid #64748b;
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #475569;
  border-radius: 6px;
  margin: 12px 0;
}
.price-map-panel-nodata strong {
  color: #1E3A5F;
}

/* Mini-map market label (per-city landing pages, under mini-map heading) */
.mini-map-market-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  margin: 8px 0 12px;
  background: #1E88E5;
  transition: background-color 0.2s ease;
}
.mini-map-market-label::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
}
.mini-map-market-label.market-badge-combined { background: #1E88E5; }
.mini-map-market-label.market-badge-secondary { background: #8B5CF6; }
.mini-map-market-label.market-badge-primary { background: #10B981; }

/* Popup: market type line styling */
.popup-market-type {
  color: #475569;
  font-size: 0.8rem;
}
.popup-market-type strong {
  color: #1E3A5F;
}
