/* =======================================================================
   SULLA SOGLIA — Searchbar mappa (mappa-search.css)
   Input fixed top-center + dropdown risultati. Mobile-first.
   ======================================================================= */

.map-search {
  position: fixed;
  top: calc(var(--nav-height, 72px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  width: min(440px, calc(100% - 24px));
  font-family: inherit;
}

.map-search__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 22px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.2s;
}

.map-search__input-wrap:focus-within {
  box-shadow: 0 4px 18px rgba(181, 58, 30, 0.25);
}

.map-search__icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: #6b6b6b;
  pointer-events: none;
  flex-shrink: 0;
}

.map-search__input {
  width: 100%;
  padding: 11px 44px 11px 42px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  color: #2c2c2c;
  border-radius: 22px;
  outline: none;
  min-height: 44px;
}

.map-search__input::placeholder {
  color: #888;
}

.map-search__clear {
  position: absolute;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #e5e7eb;
  color: #555;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.map-search__clear:hover {
  background: #d1d5db;
  color: #222;
}

.map-search.has-value .map-search__clear {
  display: flex;
}

.map-search__results {
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  max-height: min(60vh, 440px);
  overflow-y: auto;
  display: none;
}

.map-search.is-open .map-search__results {
  display: block;
}

.map-search__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: #2c2c2c;
}

.map-search__item:last-child {
  border-bottom: none;
}

.map-search__item:hover,
.map-search__item.is-active {
  background: #fef3ef;
}

.map-search__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.map-search__body {
  flex: 1;
  min-width: 0;
}

.map-search__name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #2c2c2c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-search__meta {
  font-size: 0.75rem;
  color: #6b6b6b;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-search__meta-cat {
  font-weight: 600;
  color: #888;
}

.map-search__empty {
  padding: 16px;
  text-align: center;
  color: #888;
  font-size: 0.85rem;
}

/* Dark mode */
[data-theme='dark'] .map-search__input-wrap {
  background: rgba(30, 30, 34, 0.94);
}

[data-theme='dark'] .map-search__input {
  color: #e5e7eb;
}

[data-theme='dark'] .map-search__input::placeholder {
  color: #9ca3af;
}

[data-theme='dark'] .map-search__icon {
  color: #9ca3af;
}

[data-theme='dark'] .map-search__clear {
  background: #374151;
  color: #d1d5db;
}

[data-theme='dark'] .map-search__clear:hover {
  background: #4b5563;
  color: #f3f4f6;
}

[data-theme='dark'] .map-search__results {
  background: rgba(24, 24, 27, 0.97);
}

[data-theme='dark'] .map-search__item {
  color: #e5e7eb;
  border-bottom-color: #2a2a2e;
}

[data-theme='dark'] .map-search__item:hover,
[data-theme='dark'] .map-search__item.is-active {
  background: #2a1d19;
}

[data-theme='dark'] .map-search__name {
  color: #f3f4f6;
}

[data-theme='dark'] .map-search__meta {
  color: #9ca3af;
}

[data-theme='dark'] .map-search__meta-cat {
  color: #6b6b6b;
}

/* Mobile: occupa quasi tutta la larghezza e lascia spazio al toggle tema */
@media (max-width: 600px) {
  .map-search {
    top: calc(var(--nav-height, 72px) + 8px);
    width: calc(100% - 20px);
  }

  .map-search__input {
    font-size: 0.88rem;
    padding: 10px 40px 10px 40px;
  }

  .map-search__icon {
    left: 12px;
    width: 16px;
    height: 16px;
  }

  .map-search__item {
    padding: 11px 12px;
  }
}

/* Quando la searchbar è attiva, nascondi il titolo fluttuante per non sovrapporsi */
.map-search.is-open ~ .map-title {
  opacity: 0;
  pointer-events: none;
}
