/* =========================================
   MAP PAGE - CLEAN & MOBILE FIRST
   ========================================= */

#map {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.marker-donut {
  pointer-events: none !important;
}

/* Search integrated in navbar */
.map-navbar-search {
  min-width: 260px;
}

.map-search-container--header {
  position: relative;
  width: 100%;
}

.map-search-input {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  outline: none;
  font-size: 0.95rem;
  padding: 0 14px 0 40px;
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23e2e8f0' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 1 0 1.415-1.414l-3.868-3.834zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.map-search-input::placeholder {
  color: rgba(241, 245, 249, 0.8);
}

.map-search-input:focus {
  background-color: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 0.2rem rgba(148, 163, 184, 0.18);
}

.map-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 1100;
  max-height: 320px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.22);
  display: none;
}

.search-result-item {
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  gap: 0.65rem;
  align-items: center;
  color: #0f172a;
}

.search-result-item:last-child {
  border-bottom: 0;
}

.search-result-item:hover {
  background: #f8fafc;
}

.search-result-icon {
  color: #2563eb;
}

.search-result-text {
  font-size: 0.92rem;
}

/* Map filters */
.map-controls-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.map-filters-toggle {
  pointer-events: auto;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.32);
}

.control-group {
  pointer-events: auto;
  width: min(320px, calc(100vw - 24px));
  padding: 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
}

.control-group.is-collapsed {
  display: none;
}

.control-section + .control-section {
  margin-top: 0.85rem;
}

.control-title {
  margin-bottom: 0.4rem;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.base-layer-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

.base-layer-option,
.layer-btn {
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.42rem 0.65rem;
  text-align: center;
}

.base-layer-option:hover,
.layer-btn:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.base-layer-option.active,
.layer-btn.active {
  border-color: #2563eb;
  background: #eaf2ff;
  color: #1d4ed8;
}

.layer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.layer-grid .layer-btn {
  flex: 1 1 calc(50% - 0.45rem);
  text-align: left;
}

/* Legend and popup */
.map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 900;
  max-width: 250px;
  padding: 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
  font-size: 0.76rem;
}

#map .maplibregl-popup-content {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 0;
  overflow: hidden;
  max-width: 300px !important;
}

#map .maplibregl-popup-close-button {
  font-size: 24px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  right: 5px;
  top: 5px;
}

@media (max-width: 991.98px) {
  .map-navbar-search {
    max-width: 100%;
    margin: 0.35rem 0.5rem !important;
  }

  .map-search-input {
    height: 38px;
    font-size: 0.9rem;
  }

  .map-controls-panel {
    top: 10px;
    right: 10px;
  }

  .map-filters-toggle {
    font-size: 0.82rem;
    padding: 0.45rem 0.75rem;
  }

  .control-group {
    width: min(290px, calc(100vw - 16px));
    padding: 0.75rem;
  }

  .layer-grid .layer-btn {
    flex-basis: 100%;
  }

  .map-legend {
    left: 8px;
    right: 8px;
    max-width: none;
    bottom: 8px;
  }
}

@media print {
  /* Hide unnecessary elements */
  nav, header, footer, .map-navbar-search, .map-controls-panel, .mapboxgl-ctrl, .maplibregl-ctrl {
    display: none !important;
  }

  /* Make map fill the page */
  body, html, .map-page, .map-shell, #map {
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
  }
}
