/* Mapa de propiedades (mapa.php): ocupa toda la pantalla debajo del menú */

.pagina-mapa {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.pagina-mapa .navbar { flex: 0 0 auto; width: 100%; }

.mapa-app {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 16px;
  padding: 16px;
}

/* ---------------- Panel de búsqueda y lista ---------------- */

.mapa-panel {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-md);
  overflow: hidden;
}
.mapa-panel__cabecera { padding: 16px 16px 10px; border-bottom: 1px solid var(--gris-100); }
.mapa-panel__titulo { display: flex; align-items: center; justify-content: space-between; }
.mapa-panel__titulo h1 { font-size: 1.15rem; font-weight: 600; margin: 0 0 12px; }
.mapa-panel__cerrar { display: none; border: none; background: var(--gris-100); border-radius: 50%; width: 36px; height: 36px; margin-bottom: 12px; }

.mapa-buscar { position: relative; }
.mapa-buscar i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--tinta-500); }
.mapa-buscar input,
.mapa-selectores select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--gris-200);
  border-radius: 999px;
  background-color: var(--gris-050);
  color: var(--tinta-900);
  font-size: 0.9rem;
}
.mapa-buscar input { padding: 0 16px 0 40px; }
.mapa-selectores select { padding: 0 10px; cursor: pointer; }
.mapa-buscar input:focus,
.mapa-selectores select:focus { outline: none; border-color: var(--verde-500); box-shadow: 0 0 0 3px var(--verde-100); }

.mapa-operacion { display: flex; gap: 4px; margin-top: 10px; padding: 4px; background: var(--gris-100); border-radius: 999px; }
.mapa-operacion button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 6px 0;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--tinta-700);
}
.mapa-operacion button.activa { background: var(--verde-600); color: var(--blanco); box-shadow: var(--sombra-sm); }

.mapa-selectores { display: flex; gap: 8px; margin-top: 10px; }
.mapa-selectores select { flex: 1; min-width: 0; }

.mapa-resumen { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.82rem; color: var(--tinta-500); }
.mapa-resumen button { border: none; background: none; padding: 0; color: var(--verde-700); font-weight: 600; }

.mapa-lista { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; overscroll-behavior: contain; }
.mapa-item {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: var(--radio-md);
  background: transparent;
  text-align: left;
  transition: background-color 0.2s var(--easing);
}
.mapa-item:hover { background: var(--verde-050); }
.mapa-item.activa { background: var(--verde-050); border-color: var(--verde-400); }
.mapa-item img { flex: 0 0 96px; width: 96px; height: 72px; object-fit: cover; border-radius: var(--radio-sm); background: var(--gris-100); }
.mapa-item span { display: block; min-width: 0; }
.mapa-item strong, .mapa-item small, .mapa-item b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapa-item b { font-family: var(--font-display); font-size: 0.92rem; color: var(--verde-700); }
.mapa-item strong { font-size: 0.85rem; color: var(--tinta-900); }
.mapa-item small { font-size: 0.76rem; color: var(--tinta-500); }
.mapa-item > span { flex: 1; }

/* ---------------- Mapa ---------------- */

.mapa-lienzo {
  position: relative;
  flex: 1;
  min-width: 0;
  border-radius: var(--radio-lg);
  overflow: hidden;
  box-shadow: var(--sombra-md);
  background: #f1eee2;
}
#mapa { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; }

.mapa-aviso {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--tinta-700);
  background: #f1eee2;
  z-index: 5;
}
.mapa-aviso[hidden] { display: none; }

.mapa-controles { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 3; }
.mapa-controles button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--blanco);
  color: var(--tinta-900);
  font-size: 1.1rem;
  box-shadow: var(--sombra-md);
  transition: background-color 0.2s var(--easing), color 0.2s var(--easing);
}
.mapa-controles button:hover, .mapa-controles button:focus-visible { background: var(--verde-600); color: var(--blanco); }
.mapa-controles button.mapa-controles__todas { padding: 0; font-family: var(--font-display); font-size: 0.6rem; font-weight: 600; line-height: 1.15; }

/* ---------------- Ficha de la propiedad elegida ---------------- */

.mapa-ficha {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 330px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-lg);
  z-index: 4;
  animation: aparecer 0.3s var(--easing);
}
.mapa-ficha[hidden] { display: none; }
.mapa-ficha__foto { position: relative; display: block; aspect-ratio: 16 / 10; background: var(--gris-100); }
.mapa-ficha__foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mapa-ficha__cerrar {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  color: var(--tinta-900);
  box-shadow: var(--sombra-sm);
}
.mapa-ficha__cuerpo { padding: 12px 16px 16px; }
.mapa-ficha__precio { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--verde-700); }
.mapa-ficha h2 { font-size: 1rem; font-weight: 600; margin: 2px 0; }
.mapa-ficha__zona { font-size: 0.8rem; color: var(--tinta-500); margin-bottom: 8px; }
.mapa-ficha__datos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.mapa-ficha__datos span { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: var(--verde-050); font-size: 0.78rem; color: var(--tinta-700); }
.mapa-ficha__datos i { color: var(--verde-600); }
.mapa-ficha__ver {
  display: block;
  text-align: center;
  padding: 11px;
  border-radius: 999px;
  background: var(--verde-600);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--blanco) !important;
}
.mapa-ficha__ver:hover { background: var(--verde-700); }

.mapa-abrir { display: none; }

/* ---------------- Celular y tablet ---------------- */

@media (max-width: 900px) {
  .mapa-app { padding: 0; margin-top: 8px; }
  .mapa-lienzo { border-radius: var(--radio-md) var(--radio-md) 0 0; }

  .mapa-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 82vh;
    height: 82dvh;
    z-index: 1600;
    border-radius: var(--radio-lg) var(--radio-lg) 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.25);
    transform: translateY(110%);
    visibility: hidden;
    transition: transform 0.3s var(--easing), visibility 0.3s;
  }
  .mapa-panel.abierto { transform: translateY(0); visibility: visible; }
  .mapa-panel__cerrar { display: block; }
  /* 16px evita que el celular haga zoom al tocar un campo */
  .mapa-buscar input, .mapa-selectores select { font-size: 16px; }

  .mapa-abrir {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 3;
    height: 44px;
    padding: 0 18px;
    border: none;
    border-radius: 999px;
    background: var(--blanco);
    box-shadow: var(--sombra-md);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--tinta-900);
  }
  .mapa-abrir span { padding: 1px 8px; border-radius: 999px; background: var(--verde-600); color: var(--blanco); font-size: 0.75rem; }

  .mapa-ficha { left: 10px; right: 10px; bottom: 10px; width: auto; max-width: none; max-height: 70%; }
  .mapa-ficha__foto { aspect-ratio: 2 / 1; }
}
