/**
 * Map Search page: sidebar filters (same as /rent /buy via property-listing-sidebar) + map + marker popup card
 */

.map-search-page {
  --map-search-sidebar-width: 280px;
  --map-search-topbar-height: 56px;
}

.map-search {
  display: flex;
  height: calc(100vh - var(--header-height, 80px));
  min-height: 400px;
}

/* Sidebar and filters use .property-listing-sidebar* from block style.css (loaded on this template) */

.map-search__map-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 60vh;
  position: relative;
}

@media (max-width: 768px) {
  .map-search.block-property-listing-cards--with-sidebar {
    flex-direction: column;
  }
  .map-search__map-wrap {
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0));
    min-height: 50vh;
  }
}

/* Dynamic filter: "Searching…" overlay */
.map-search-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.map-search-overlay[hidden] {
  display: none !important;
}

.map-search-overlay__inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.map-search-overlay__icon {
  width: 24px;
  height: 24px;
  border: 2px solid var(--primary, #8b7355);
  border-top-color: transparent;
  border-radius: 50%;
  animation: map-search-spin 0.7s linear infinite;
}

.map-search-overlay__text {
  font-size: 1rem;
  font-weight: 500;
  color: #1a1a1a;
}

@keyframes map-search-spin {
  to {
    transform: rotate(360deg);
  }
}

.map-search__topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  margin: 12px 56px;
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.map-search__count {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #555555;
}

.map-search__search-wrap {
  flex: 1;
  max-width: 320px;
}

.map-search__search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  font-size: 0.9375rem;
  border: 1px solid #d0cecb;
  border-radius: 2rem;
  background: #f8f7f5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 0.65rem center;
}

.map-search__search-input:focus {
  outline: none;
  border-color: var(--primary, #8b7355);
}

.map-search__map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 300px;
  background: #d4cfc4;
}

/* Map tiles: dirt/sand tone to match brand (--primary #8b7355, warm neutrals) */

.map-search__map .leaflet-tile-pane {
  filter: sepia(0.32) saturate(0.7) hue-rotate(-6deg) brightness(1.04) contrast(0.97);
}

/* Leaflet controls: warm tone to match map */

.map-search__map .leaflet-control-zoom {
  border: 1px solid rgba(139, 115, 85, 0.35) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.map-search__map .leaflet-control-zoom a {
  background: rgba(248, 247, 245, 0.95) !important;
  color: #6b5344 !important;
  border-color: rgba(139, 115, 85, 0.2) !important;
}

.map-search__map .leaflet-control-zoom a:hover {
  background: rgba(232, 230, 227, 0.98) !important;
  color: #5a4a3a !important;
}

.map-search__map .leaflet-control-attribution {
  background: rgba(212, 207, 196, 0.88) !important;
  color: #6b5344 !important;
  font-size: 10px;
}

.map-search__map .leaflet-control-attribution a {
  color: #8b7355 !important;
}

/* Leaflet overrides */

.map-search__map .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.map-search__map .leaflet-popup-content {
  margin: 0;
  min-width: 280px;
  max-width: 320px;
}

.map-search__map .leaflet-popup-tip {
  background: #fff;
}

/* Popup card (reference: idealista-style) */

.map-search-popup {
  background: #fff;
}

.map-search-popup__image-wrap {
  position: relative;
  aspect-ratio: 4/3;
  background: #eee;
  overflow: hidden;
}

.map-search-popup__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.map-search-popup__carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #2b2b2b;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.map-search-popup__carousel-btn:hover {
  background: #fff;
  color: #8b7355;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.map-search-popup__carousel-prev {
  left: 8px;
}

.map-search-popup__carousel-next {
  right: 8px;
}

.map-search-popup__image-nav {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 2;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 4px;
}

.map-search-popup__approx {
  padding: 6px 12px;
  font-size: 0.75rem;
  color: #6b5344;
  background: #f5f0e8;
}

.map-search-popup__body {
  padding: 12px;
}

.map-search-popup__title {
  font-size: 0.9375rem;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.3;
}

.map-search-popup__title a {
  color: #8b7355;
  text-decoration: none;
}

.map-search-popup__title a:hover {
  text-decoration: underline;
}

.map-search-popup__price {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 6px;
}

.map-search-popup__specs {
  font-size: 0.8125rem;
  color: #4a4a4a;
  margin: 0 0 12px;
  line-height: 1.4;
}

.map-search-popup__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.map-search-popup__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  background: #8b7355;
  color: #fff !important;
  transition: background 0.2s ease;
}

.map-search-popup__btn:hover {
  background: #154a7a;
  color: #fff;
}

.map-search-popup__btn--icon {
  padding: 6px 10px;
  background: transparent;
  color: #6b6b6b;
}

.map-search-popup__btn--icon:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a1a;
}

.map-search-popup__phone {
  font-size: 0.8125rem;
  color: #4a4a4a;
  margin-left: auto;
}

/* Mobile-only floating bar: live result count + "View map" to close filters */
.map-search-mobile-bar {
  display: none;
}

@media (max-width: 768px) {
  .map-search-mobile-bar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
  }

  .map-search__sidebar--open ~ .map-search-mobile-bar {
    display: block;
  }

  .map-search-mobile-bar__btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    background: var(--primary, #8b7355);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    box-shadow: 0 2px 12px rgba(139, 115, 85, 0.35);
    transition: background 0.2s ease, transform 0.15s ease;
  }

  .map-search-mobile-bar__btn:hover {
    background: #7a6449;
    color: #fff;
  }

  .map-search-mobile-bar__btn:active {
    transform: scale(0.99);
  }

  .map-search-mobile-bar__count {
    flex: 1;
    margin-right: 0.5rem;
    font-weight: 600;
  }

  .map-search-mobile-bar__action {
    flex-shrink: 0;
    opacity: 0.95;
    font-size: 0.9375rem;
  }

  .map-search {
    flex-direction: column;
    height: auto;
    min-height: 80vh;
    padding-bottom: 80px; /* space for fixed bar */
  }
  .map-search__sidebar {
    width: 100%;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid #e8e6e3;
    background: #f8f7f5;
  }
  .map-search__sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    background: #f8f7f5;
    border: none;
    border-bottom: 1px solid #e8e6e3;
    cursor: pointer;
    text-align: left;
  }
  .map-search__sidebar-toggle:hover {
    background: #eee;
  }
  .map-search__sidebar-toggle-icon {
    flex-shrink: 0;
  }
  .map-search__sidebar--open .map-search__sidebar-toggle-icon {
    transform: rotate(-135deg);
  }
  .map-search__sidebar-inner {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  .map-search__sidebar--open .map-search__sidebar-inner {
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem;
  }
  .map-search__map-wrap {
    flex: 1;
    min-height: 55vh;
  }
  .map-search__map {
    min-height: 80vh;
  }
  .map-search__topbar {
    flex-wrap: wrap;
  }
  .map-search__search-wrap {
    max-width: none;
  }
}