#map {
  flex: 1;
  width: 100%;
  position: relative;
  min-height: 500px;
}

/* Floating Search Box */
.map-search-container {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 100;
  width: 300px;
}

.map-search-container input {
  width: 100%;
  padding: 12px 15px;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: box-shadow 0.2s;
}

.map-search-container input:focus {
  outline: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Clear Button */
#clearSearch {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  padding: 5px 8px;
  display: none;
  line-height: 1;
  transition: color 0.2s;
}

#clearSearch:hover {
  color: #333;
}

/* Dropdown Results */
.search-results {
  background: white;
  margin-top: 8px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  position: relative;
  z-index: 2000;
}

.search-results.show {
  display: block;
}

.search-result-item {
  padding: 12px 15px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
}

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

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

.search-result-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.search-result-details {
  font-size: 0.85rem;
  color: #666;
}

.search-no-results {
  padding: 20px 15px;
  text-align: center;
  color: #999;
  font-size: 0.9rem;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 150px;
  left: 20px;
  z-index: 500;
  background: rgba(255, 255, 255, 0.5);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Sensor Legend */
.sensor-legend {
  position: absolute;
  bottom: 30px;
  left: 20px;
  z-index: 500;
  background: rgba(255, 255, 255, 0.5);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.map-legend h2,
.sensor-legend h2 {
  margin: 0 0 10px 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-item img {
  width: 15px;
  height: 24px;
}

.legend-item span {
  font-size: 0.9rem;
  color: #666;
}

/* Mobile adjustments for legends */
@media (max-width: 768px) {
  .map-legend {
    bottom: 125px;
    left: 15px;
    padding: 12px;
  }

  .sensor-legend {
    bottom: 15px;
    left: 15px;
    padding: 12px;
  }

  .map-legend h2,
  .sensor-legend h2 {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }

  .legend-item {
    gap: 6px;
    margin-bottom: 4px;
  }

  .legend-item img {
    width: 12px;
    height: 20px;
  }

  .legend-item span {
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) {
  #map {
    height: calc(100vh - 120px);
  }

  /* Move search container to top, spanning full width */
  .map-search-container {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
  }

  .map-search-container input {
    padding: 10px 35px 10px 12px;
    font-size: 0.9rem;
  }

  .search-results {
    max-height: 250px;
  }

  .search-result-item {
    padding: 10px 12px;
  }

  .search-result-name {
    font-size: 0.9rem;
  }

  .search-result-details {
    font-size: 0.8rem;
  }

  /* Move zoom controls to bottom-right */
  .leaflet-control-zoom {
    display: none !important;
  }

  /* Keep sensor toggle visible but move to top-left with more spacing */
  .sensor-toggle-control {
    margin-top: 80px !important;
  }
}

@media (max-width: 480px) {
  #map {
    height: calc(100vh - 110px);
  }

  .map-search-container {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .map-search-container input {
    font-size: 0.85rem;
    padding: 8px 32px 8px 10px;
  }

  /* Reduce gap between search and sensor toggle */
  .sensor-toggle-control {
    margin-top: 60px !important;
  }

  /* Even more compact legends */
  .map-legend {
    bottom: 175px;
    left: 12px;
    padding: 8px;
    width: 110px;
  }

  .sensor-legend {
    bottom: 10px;
    left: 12px;
    padding: 8px;
    width: 110px;
  }

  .map-legend h2,
  .sensor-legend h2 {
    font-size: 0.75rem;
    margin-bottom: 5px;
  }

  .legend-item {
    gap: 4px;
    margin-bottom: 3px;
  }

  .legend-item span {
    font-size: 0.7rem;
  }

  .legend-item img {
    width: 10px;
    height: 16px;
  }
}
