/* =============================================
   CATÁLOGO — Página dedicada
   ============================================= */

.catalogo-page {
  padding: 3.5rem 0 6rem;
  background: linear-gradient(180deg, #ffffff 0%, #f0f5fc 25%, #e8eef9 50%, #f0f5fc 75%, #ffffff 100%);
  position: relative;
  z-index: 2;
  overflow: hidden;
  min-height: 100vh;
}

.catalogo-page .container {
  position: relative;
  z-index: 2;
}

/* ——— Hero del catálogo ——— */
.cat-hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.cat-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #204A97;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 1.25rem;
  transition: color 0.2s ease, transform 0.2s ease;
}

.cat-back:hover {
  color: #204A97;
  transform: translateX(-4px);
}

.cat-page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  color: #1d3557;
  margin-bottom: 0.5rem;
}

.cat-page-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  margin: 0.7rem auto 0;
  border-radius: 999px;
  background: #204A97;
  animation: catLineGlow 3s ease infinite alternate;
}

@keyframes catTitleShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes catLineGlow {
  0% { width: 40px; opacity: 0.6; }
  100% { width: 80px; opacity: 1; }
}

.cat-page-subtitle {
  font-size: 1.05rem;
  color: #1d3557;
  margin-top: 0.6rem;
}

/* Botón Ver todo (dentro de la barra de filtros) */
.btn-ver-todas-viviendas {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.4rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #3A67C4 0%, #2A4F9E 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(32, 74, 151, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-ver-todas-viviendas:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(32, 74, 151, 0.45);
}

/* ——— Barra de filtros ——— */
.cat-filtros {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: #ffffff;
  border: 1px solid rgba(32, 74, 151, 0.15);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.cat-filtro-buscar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  color: #204A97;
}

.cat-buscar-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  color: #1d3557;
}

.cat-buscar-input::placeholder {
  color: rgba(29, 53, 87, 0.5);
}

.cat-filtro-selects {
  display: flex;
  gap: 0.65rem;
  flex-shrink: 0;
}

.cat-select {
  padding: 0.55rem 2rem 0.55rem 0.85rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: #1d3557;
  background: #f8fafd;
  border: 1px solid rgba(32, 74, 151, 0.18);
  border-radius: 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #204A97 50%), linear-gradient(135deg, #204A97 50%, transparent 50%);
  background-position: calc(100% - 0.9rem) calc(50% - 2px), calc(100% - 0.6rem) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cat-select option {
  background: #fff;
  color: #fff;
}

.cat-select:focus {
  outline: none;
  border-color: #204A97;
  box-shadow: 0 0 0 3px rgba(32, 74, 151, 0.15);
}

/* ——— Vista de comunas ——— */
.cat-comunas-view {
  margin-bottom: 2rem;
}

.cat-comunas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* ——— Vista de propiedades por comuna ——— */
.cat-propiedades-view {
  margin-bottom: 2rem;
}

.cat-comuna-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.cat-btn-volver-comunas {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(32, 74, 151, 0.2);
  border-radius: 12px;
  color: #204A97;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}

.cat-btn-volver-comunas:hover {
  background: #fff;
  border-color: rgba(32, 74, 151, 0.4);
  transform: translateX(-4px);
}

.cat-btn-volver-comunas svg {
  transition: transform 0.25s ease;
}

.cat-btn-volver-comunas:hover svg {
  transform: translateX(-2px);
}

.cat-comuna-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 700;
  color: #1d3557;
  margin: 0;
  flex: 1;
}

.cat-comuna-title span {
  color: #204A97;
  font-style: italic;
}

/* ——— Contador de resultados ——— */
.cat-resultados-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.cat-resultados-info p {
  font-size: 0.9rem;
  color: rgba(29, 53, 87, 0.6);
}

.cat-resultados-info strong {
  color: #204A97;
  font-weight: 700;
}

.cat-resultados-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.cat-orden-label {
  font-size: 0.88rem;
  color: rgba(29, 53, 87, 0.6);
  font-weight: 500;
  margin: 0;
}

.cat-select-inline {
  min-width: 140px;
}

.cat-limpiar {
  background: transparent;
  border: 1px solid rgba(32, 74, 151, 0.2);
  color: #204A97;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.cat-limpiar:hover {
  background: rgba(32, 74, 151, 0.12);
  border-color: rgba(32, 74, 151, 0.35);
  color: #204A97;
}

/* ——— Bloque de comuna ——— */
.cat-comuna-block {
  margin-bottom: 3rem;
}

.cat-comuna-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(32, 74, 151, 0.1);
}

.cat-comuna-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(32, 74, 151, 0.2) 0%, rgba(32, 74, 151, 0.1) 100%);
  color: #204A97;
  flex-shrink: 0;
}

.cat-comuna-icon svg {
  width: 18px;
  height: 18px;
}

.cat-comuna-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1d3557;
}

.cat-comuna-count {
  font-size: 0.82rem;
  color: rgba(29, 53, 87, 0.5);
  margin-left: auto;
}

/* ——— Grid de tarjetas ——— */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

/* Reutilizamos la tarjeta card-vivienda de styles.css */

/* ——— Mensaje vacío ——— */
.cat-empty {
  text-align: center;
  padding: 4rem 2rem;
  margin-top: 2rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.cat-empty svg {
  color: rgba(32, 74, 151, 0.4);
  margin-bottom: 1.5rem;
}

.cat-empty-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: #1d3557;
  margin-bottom: 0.5rem;
}

.cat-empty-title span {
  color: #204A97;
  font-style: italic;
}

.cat-empty-text {
  font-size: 1rem;
  color: rgba(29, 53, 87, 0.6);
  margin-top: 0.5rem;
}

/* ——— Responsive ——— */
@media (max-width: 1024px) {
  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .catalogo-page {
    padding: 3rem 0 4rem;
    padding-bottom: max(4rem, env(safe-area-inset-bottom, 0px) + 4rem);
  }

  .cat-page-title {
    font-size: 2.2rem;
  }

  .cat-filtros {
    flex-direction: column;
    gap: 0.85rem;
    flex-wrap: wrap;
  }

  .cat-filtro-selects {
    width: 100%;
    min-width: 0;
  }

  .cat-select {
    flex: 1;
    min-width: 0;
    min-height: 48px;
  }

  .btn-ver-todas-viviendas,
  .cat-btn-mapa {
    min-height: 48px;
    width: 100%;
    justify-content: center;
  }

  .cat-comuna-name {
    font-size: 1.3rem;
  }

  .cat-card,
  .card-vivienda {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .cat-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .cat-page-title {
    font-size: 1.8rem;
  }

  .cat-resultados-info {
    flex-direction: column;
    gap: 0.6rem;
    align-items: flex-start;
  }

  .cat-comunas-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .cat-comuna-title {
    font-size: 1.5rem;
  }

  .cat-comuna-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .cat-btn-volver-comunas {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  .catalogo-contacto-panel {
    padding: 1rem;
    align-items: stretch;
    justify-content: flex-end;
  }

  .catalogo-contacto-panel-inner {
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
  }

  .catalogo-contacto-panel-content {
    padding: 1.5rem 1rem 2rem;
    padding-top: 3rem;
  }

  .catalogo-contacto-panel-close {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ——— Pestaña Contacto (modal centrado desde "Consultar por esta propiedad") ——— */
.catalogo-contacto-panel {
  position: fixed;
  inset: 0;
  z-index: 10002;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.3s ease, opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
}

.catalogo-contacto-panel.is-open {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

.catalogo-contacto-panel-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 2, 18, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.catalogo-contacto-panel-inner {
  position: relative;
  width: 100%;
  max-width: 780px;
  max-height: 94vh;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
  transform: scale(0.96);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.catalogo-contacto-panel.is-open .catalogo-contacto-panel-inner {
  transform: scale(1);
  opacity: 1;
}

.catalogo-contacto-panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(32, 74, 151, 0.08);
  border-radius: 12px;
  color: #1d3557;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.catalogo-contacto-panel-close:hover {
  background: rgba(32, 74, 151, 0.15);
}

.catalogo-contacto-panel-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding: 2.5rem 1.5rem 3rem;
  padding-top: 4rem;
}

.catalogo-contacto-info .contacto-badge,
.catalogo-contacto-info .contacto-heading,
.catalogo-contacto-info .contacto-desc,
.catalogo-contacto-info .contacto-datos {
  margin-bottom: 1rem;
}

.catalogo-contacto-info .contacto-desc {
  margin-bottom: 1.5rem;
}

.catalogo-contacto-box {
  background: #ffffff;
  padding: 1.75rem;
  border-radius: 16px;
  border: 1px solid rgba(32, 74, 151, 0.15);
  position: relative;
  box-shadow: 0 4px 20px rgba(29, 53, 87, 0.06);
}

.catalogo-contacto-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, #204A97, #24324f);
}

.catalogo-contacto-burbuja-wrap .contacto-burbuja-item {
  margin-bottom: 0.5rem;
}

/* Área de mensaje con altura suficiente para que no se corte el texto */
#catalogo-contacto-mensaje {
  min-height: 160px;
  resize: vertical;
}

@media (min-width: 640px) {
  .catalogo-contacto-panel-content {
    grid-template-columns: 1fr 1.1fr;
    padding: 2.5rem 2rem 3rem;
    padding-top: 4rem;
  }
}
