/* Mapa de propiedades — misma paleta blanca y azul que la página principal */
:root {
  --mapa-bg: #ffffff;
  --mapa-bg-card: #ffffff;
  --mapa-border: rgba(32, 74, 151, 0.2);
  --mapa-accent: #204A97;
  --mapa-accent-strong: #204A97;
  --mapa-text: #1d3557;
  --mapa-text-muted: rgba(29, 53, 87, 0.7);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  box-sizing: border-box;
}

body {
  min-height: 100%;
  margin: 0;
  padding: 1rem;
  box-sizing: border-box;
  overflow: hidden;
  font-family: 'DM Sans', system-ui, sans-serif;
  color: #1d3557;
  background: #f8f9fa;
  border: 1px solid var(--mapa-border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(32, 74, 151, 0.08);
}

/* Header — mismo azul que la página principal */
.mapa-header {
  height: 56px;
  background: linear-gradient(135deg, #204A97 0%, #24324f 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px 15px 0 0;
  box-shadow: 0 4px 20px rgba(32, 74, 151, 0.25);
  z-index: 100;
  position: relative;
}

.mapa-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0.3), rgba(255,255,255,0.15));
  opacity: 0.8;
}

.mapa-header-inner {
  max-width: 100%;
  height: 100%;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.mapa-logo {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #ffffff;
  font-weight: 600;
  cursor: default;
  transition: filter 0.35s ease, box-shadow 0.35s ease;
}

.mapa-logo:hover .logo-img-wrap-mapa {
  box-shadow: 0 0 16px 2px rgba(255, 255, 255, 0.2);
}

/* Recorte del logo en mapa: solo el espacio necesario */
.logo-img-wrap-mapa {
  width: 100px;
  height: 48px;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: box-shadow 0.35s ease;
}

.logo-img-wrap-mapa .mapa-logo-img {
  display: block;
  height: 48px;
  width: auto;
  min-width: 100%;
  max-width: none;
  object-fit: cover;
  object-position: left center;
  border-radius: 0;
  border: none;
}

.mapa-logo-img {
  height: 56px;
  width: auto;
  min-width: 180px;
  max-width: 280px;
  object-fit: contain;
  object-position: left center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.mapa-logo .logo-svg {
  display: block;
  height: 56px;
  width: auto;
  min-width: 180px;
  max-width: 280px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.logo-brand-mapa .logo-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.logo-brand-mapa .logo-tagline {
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  opacity: 0.9;
}

.mapa-logo-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.mapa-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 0;
}

.mapa-header-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
}

.mapa-header-count {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
}

.mapa-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #204A97;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  text-decoration: none;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.mapa-back-btn:hover {
  background: #f0f4fc;
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  color: #1a3a7a;
}

/* Layout principal — altura ajustada al espacio dentro del borde */
.mapa-app {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: calc(100vh - 56px - 2rem);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

/* Sidebar — fondo blanco, borde azul */
.mapa-sidebar {
  background: #ffffff;
  border-right: 1px solid var(--mapa-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 10;
  box-shadow: 4px 0 20px rgba(32, 74, 151, 0.08);
}

.mapa-sidebar-toggle {
  display: none;
  position: absolute;
  top: 0.75rem;
  right: -44px;
  width: 40px;
  height: 40px;
  border-radius: 0 12px 12px 0;
  background: #ffffff;
  border: 1px solid var(--mapa-border);
  border-left: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #204A97;
  box-shadow: 4px 2px 16px rgba(0, 0, 0, 0.1);
  z-index: 20;
  transition: background 0.2s, color 0.2s;
}

.mapa-sidebar-toggle:hover {
  background: rgba(32, 74, 151, 0.1);
  color: #204A97;
}

/* Filtros */
.mapa-filters {
  padding: 1.25rem;
  border-bottom: 1px solid var(--mapa-border);
  flex-shrink: 0;
  font-family: 'Outfit', system-ui, sans-serif;
}

.mapa-filters-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1d3557;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mapa-filters-title::before {
  content: '';
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #204A97, #2a5bb5);
}

.mapa-filters-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.mf-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1d3557;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  position: relative;
  padding-left: 0.5rem;
}

.mf-field label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 14px;
  background: #204A97;
  border-radius: 2px;
}

.mf-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid rgba(32, 74, 151, 0.25);
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: #1d3557;
  background: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  box-shadow: 0 2px 8px rgba(32, 74, 151, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  transition: all 0.25s ease;
  cursor: text;
}

.mf-input:hover {
  border-color: rgba(32, 74, 151, 0.4);
  box-shadow: 0 4px 12px rgba(32, 74, 151, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.9) inset;
}

.mf-input:focus {
  outline: none;
  border-color: #204A97;
  box-shadow: 0 0 0 4px rgba(32, 74, 151, 0.15), 0 4px 16px rgba(32, 74, 151, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.95) inset;
  background: #fff;
  transform: translateY(-1px);
}

/* Custom dropdown para selects del mapa */
.mf-custom-dropdown {
  position: relative;
  width: 100%;
}

.mf-select-native {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

.mf-select-trigger {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 0.75rem 1rem;
  padding-right: 2.5rem;
  border: 2px solid rgba(32, 74, 151, 0.25);
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: #1d3557;
  background: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  box-shadow: 0 2px 8px rgba(32, 74, 151, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  transition: all 0.25s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.mf-select-trigger:hover {
  border-color: rgba(32, 74, 151, 0.4);
  box-shadow: 0 4px 12px rgba(32, 74, 151, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.9) inset;
  transform: translateY(-1px);
}

.mf-select-trigger:focus {
  outline: none;
  border-color: #204A97;
  box-shadow: 0 0 0 4px rgba(32, 74, 151, 0.15), 0 4px 16px rgba(32, 74, 151, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.95) inset;
  background: #fff;
}

.mf-select-label {
  flex: 1;
  min-width: 0;
}

.mf-select-arrow {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--mapa-accent-strong);
  border-bottom: 2px solid var(--mapa-accent-strong);
  transform: rotate(45deg);
  transition: transform 0.25s ease;
}

.mf-custom-dropdown.is-open .mf-select-arrow {
  transform: rotate(-135deg) translateY(-2px);
}

.mf-select-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  background: #ffffff;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(32, 74, 151, 0.2);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(32, 74, 151, 0.18), 0 4px 16px rgba(0, 0, 0, 0.1);
  padding: 8px;
  max-height: 280px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.mf-custom-dropdown.is-open .mf-select-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mf-custom-dropdown.is-open .mf-select-panel[hidden] {
  display: block;
}

.mf-select-panel::-webkit-scrollbar {
  width: 6px;
}

.mf-select-panel::-webkit-scrollbar-thumb {
  background: rgba(32, 74, 151, 0.3);
  border-radius: 999px;
}

.mf-select-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 999px;
}

.mf-select-option {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  margin: 0 0 4px 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #1d3557;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.mf-select-option:last-child {
  margin-bottom: 0;
}

.mf-select-option:hover {
  background: rgba(32, 74, 151, 0.1);
  color: #204A97;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(32, 74, 151, 0.1);
}

.mf-select-option:focus {
  outline: none;
  background: rgba(32, 74, 151, 0.12);
  box-shadow: 0 0 0 2px rgba(32, 74, 151, 0.2);
}

.mf-select-option.is-selected {
  background: linear-gradient(135deg, #204A97 0%, #2a5bb5 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(32, 74, 151, 0.25);
}

.mf-select-option.is-selected:hover {
  background: linear-gradient(135deg, #2a5bb5 0%, #204A97 100%);
  transform: translateX(4px) scale(1.02);
  box-shadow: 0 6px 16px rgba(32, 74, 151, 0.3);
}

.mf-input {
  cursor: text;
}

.mf-input:hover {
  border-color: rgba(32, 74, 151, 0.4);
  box-shadow: 0 2px 8px rgba(32, 74, 151, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.9) inset;
}

.mf-input::placeholder {
  color: rgba(29, 53, 87, 0.5);
  font-weight: 400;
}

.mf-precio-moneda-toggle {
  display: flex;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(29, 53, 87, 0.2);
  margin-bottom: 0.5rem;
  background: rgba(29, 53, 87, 0.06);
}

.mf-moneda-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: #1d3557;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.mf-moneda-btn:hover {
  background: rgba(29, 53, 87, 0.08);
}

.mf-moneda-btn.is-active {
  background: linear-gradient(135deg, #204A97 0%, #2a5bb5 100%);
  color: #fff;
}

.mf-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.4rem;
  align-items: center;
}

.mf-range span {
  color: #1d3557;
  font-size: 0.85rem;
}

.mf-btn {
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #204A97 0%, #2a5bb5 100%);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(32, 74, 151, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.mf-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(32, 74, 151, 0.45);
}

/* Listado */
.mapa-listado {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mapa-listado::-webkit-scrollbar { width: 6px; }
.mapa-listado::-webkit-scrollbar-thumb {
  background: rgba(32, 74, 151, 0.3);
  border-radius: 999px;
}
.mapa-listado::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 999px;
}

/* Card de propiedad en listado — fondo blanco, acentos azules */
.ml-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 14px;
  border: 2px solid rgba(32, 74, 151, 0.2);
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s, background 0.2s;
}

.ml-card:hover, .ml-card.active {
  border-color: rgba(32, 74, 151, 0.45);
  box-shadow: 0 8px 24px rgba(32, 74, 151, 0.12), 0 0 0 1px rgba(32, 74, 151, 0.1) inset;
  transform: translateY(-1px);
  background: #ffffff;
}

.ml-card.active {
  background: rgba(32, 74, 151, 0.06);
  border-color: #204A97;
}

.ml-card-img-wrap {
  position: relative;
  flex-shrink: 0;
}

.ml-card-img {
  width: 100px;
  height: 80px;
  border-radius: 10px;
  object-fit: cover;
  background: #f0f2f5;
  border: 1px solid var(--mapa-border);
}

.ml-card-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  font-size: 0.55rem;
  font-weight: 600;
  background: linear-gradient(135deg, #204A97 0%, #E7282F 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(231, 40, 47, 0.4);
  letter-spacing: 0.02em;
}

.ml-card-badge svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.ml-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
}

.ml-card-tag {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(32, 74, 151, 0.12);
  color: #204A97;
}

.ml-card-precio {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1d3557;
}

.ml-card-tipo {
  font-size: 0.82rem;
  color: var(--mapa-text-muted);
}

.ml-card-meta {
  font-size: 0.78rem;
  color: var(--mapa-text-muted);
}

/* Mapa — contenido con margen y borde */
.mapa-main {
  position: relative;
  background: #f0f2f5;
  padding: 0.75rem;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.mapa-leaflet {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(32, 74, 151, 0.2);
  box-shadow: 0 4px 20px rgba(32, 74, 151, 0.1);
}

/* Contenedor Leaflet — tema claro */
.mapa-main .leaflet-container {
  background: #e8eef5;
}
.mapa-main .leaflet-tile-pane {
  opacity: 1;
}

/* Markers — azul, misma paleta que la página */
.mapa-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #204A97 0%, #2a5bb5 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  box-shadow: 0 4px 16px rgba(32, 74, 151, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid rgba(255, 255, 255, 0.95);
  white-space: nowrap;
}

.mapa-marker.hovered, .mapa-marker.active {
  transform: scale(1.12);
  box-shadow: 0 8px 24px rgba(32, 74, 151, 0.5);
  background: linear-gradient(135deg, #2a5bb5 0%, #204A97 100%);
}

/* Popups del mapa */
.mapa-popup {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.75rem;
  align-items: center;
  min-width: 240px;
}

.mapa-popup img {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--mapa-border);
}

.mapa-popup-precio {
  font-weight: 700;
  font-size: 1rem;
  color: #204A97;
  margin-bottom: 0.15rem;
}

.mapa-popup-tipo {
  font-size: 0.82rem;
  color: var(--mapa-text-muted);
  margin-bottom: 0.3rem;
}

.mapa-popup-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(32, 74, 151, 0.12);
  color: #204A97;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid rgba(32, 74, 151, 0.3);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.mapa-popup-btn:hover {
  background: #204A97;
  color: #fff;
  border-color: #204A97;
}

/* Popups Leaflet — fondo blanco y azul */
.leaflet-popup-content-wrapper {
  background: #ffffff;
  border: 2px solid rgba(32, 74, 151, 0.2);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(32, 74, 151, 0.15);
  color: #1d3557;
}
.leaflet-popup-tip {
  background: #ffffff;
}
.leaflet-container a.leaflet-popup-close-button {
  color: var(--mapa-text-muted);
}
.leaflet-container a.leaflet-popup-close-button:hover {
  color: #204A97;
}

/* Responsive */
@media (max-width: 768px) {
  .mapa-app {
    grid-template-columns: 1fr;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .mapa-main {
    min-width: 0;
    min-height: 50vh;
  }

  .mapa-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(320px, calc(100vw - 3rem));
    max-width: 100%;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 50;
    background: rgba(18, 6, 58, 0.98);
    backdrop-filter: blur(20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mapa-sidebar.is-open {
    transform: translateX(0);
  }

  .mapa-sidebar-toggle {
    display: inline-flex;
    min-width: 48px;
    min-height: 48px;
    align-items: center;
    justify-content: center;
  }

  .mapa-header-center {
    display: none;
  }

  .mf-btn,
  .mapa-back-btn {
    min-height: 48px;
    padding: 0.75rem 1.25rem;
  }

  .ml-card {
    min-height: 0;
  }
}

@media (max-width: 480px) {
  .mapa-sidebar {
    width: 100%;
  }

  .mapa-filters-form .mf-field label {
    font-size: 0.9rem;
  }

  .mf-input,
  .mf-range input {
    min-height: 44px;
  }

  .mf-moneda-btn {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ml-card, .mapa-marker, .mf-btn, .mapa-back-btn {
    transition: none;
  }
}
