/* ===========================================
           RESET Y VARIABLES | test bub
=========================================== */

:root {
  --color-primary: #2d7d9a;
  --color-primary-dark: #1e5a6e;
  --color-secondary: #f5f5f5;
  --color-text: #333;
  --color-text-light: #666;
  --color-border: #e0e0e0;
  --color-white: #fff;
  --color-success: #4caf50;
  --transition: all 0.3s ease;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  background-color: var(--color-white);
  color: var(--color-text);
  line-height: 1.6;
}

/* ===========================================
           CONTENEDOR PRINCIPAL
=========================================== */

.destacados-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ===========================================
           CABECERA CON CONTROLES
=========================================== */

.destacados-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 25px;
  padding: 15px 20px;
  background: var(--color-white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-card);
}

.destacados-count {
  font-size: 1rem;
  color: var(--color-primary);
  font-weight: 500;
}

.destacados-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.control-label {
  font-size: 0.9rem;
  color: var(--color-text-light);
}

.select-orden {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  background: var(--color-white);
  cursor: pointer;
  min-width: 180px;
  color: var(--color-text-light); /* Color gris para la opción placeholder */
}

.select-orden:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Cuando tiene una opción válida seleccionada */
.select-orden.has-value {
  color: var(--color-text); /* Negro cuando hay selección */
}

/* Color negro para las opciones del dropdown */
.select-orden option {
  color: var(--color-text); /* Color negro (#333) */
}

/* Color gris solo para el placeholder */
.select-orden option[disabled] {
  color: var(--color-text-light);
}

/* Botones de vista */
.view-buttons {
  display: flex;
  gap: 5px;
}

.view-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
}

.view-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.view-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

.view-btn svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 768px) {
  /* Ocultar solo el botón con data-view="map" en mv */
  .view-btn[data-view="map"] {
    display: none;
  }
}

/* ===========================================
           CONTENEDOR DE VISTAS
=========================================== */

.view-container {
  display: none;
}

.view-container.active {
  display: block;
}

/* ===========================================
           VISTA GRID
=========================================== */

.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 25px;
}

/* ===========================================
           TARJETA DE INMUEBLE (GRID)
=========================================== */

.property-card {
  background: var(--color-white);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.property-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

/* Carrusel de imágenes */
.card-carousel {
  position: relative;
  width: 100%;
  height: 220px;
  overflow: hidden;
  background: #f0f0f0;
}

.carousel-slides {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease;
}

.carousel-slide {
  min-width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Flechas del carrusel */
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
  z-index: 10;
}

.property-card:hover .carousel-arrow {
  opacity: 1;
}

.carousel-arrow:hover {
  background: var(--color-white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.carousel-arrow.prev {
  left: 10px;
}

.carousel-arrow.next {
  right: 10px;
}

.carousel-arrow svg {
  width: 16px;
  height: 16px;
  color: var(--color-text);
}

/* Indicadores del carrusel */
.carousel-indicators {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 10;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: var(--transition);
}

.carousel-dot.active {
  background: var(--color-white);
}

/* Contador de fotos */
.carousel-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  z-index: 10;
}

/* Etiquetas sobre imagen */
.card-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10;
}

.badge {
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-operacion {
  background: var(--color-primary);
  color: var(--color-white);
}

.badge-tipo {
  background: rgba(0, 0, 0, 0.7);
  color: var(--color-white);
}

/* Favoritos */
.btn-favorite {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  background: var(--color-white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: var(--transition);
  display: none;
}

.btn-favorite:hover {
  transform: scale(1.1);
}

.btn-favorite svg {
  width: 20px;
  height: 20px;
  color: var(--color-text-light);
}

.btn-favorite.active svg {
  fill: #e53935;
  color: #e53935;
}

/* Contenido de la tarjeta */
.card-content {
  padding: 15px;
}

.card-location {
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-bottom: 5px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-title a {
  color: inherit;
  text-decoration: none;
}

.card-title a:hover {
  color: var(--color-primary);
}

.card-description {
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Características */
.card-features {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--color-border);
}

.feature {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.feature svg {
  width: 16px;
  height: 16px;
}

/* Footer de la tarjeta */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-meta {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.card-price {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* ===========================================
           PARTE CLICABLE DE LA TARJETA
=========================================== */

.property-card {
  position: relative;
  cursor: pointer;
}

.property-card .card-title a::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.property-card .card-carousel {
  position: relative;
  z-index: 2;
}

.property-card .carousel-arrow,
.property-card .btn-favorite {
  z-index: 3;
}

/* ===========================================
           VISTA LISTADO
=========================================== */

.list-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.list-view .property-card {
  display: flex;
  flex-direction: row;
}

.list-view .card-carousel {
  width: 350px;
  min-width: 350px;
  height: 220px;
}

.list-view .card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
}

.list-view .card-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.list-view .card-info {
  flex: 1;
}

.list-view .card-price-container {
  text-align: right;
}

.list-view .card-price {
  font-size: 1.5rem;
}

/* ===========================================
           VISTA MAPA
=========================================== */

.map-view {
  display: flex;
  gap: 20px;
  height: 700px;
}

#map-container {
  flex: 1;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

#map {
  width: 100%;
  height: 100%;
}

.map-sidebar {
  width: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.map-sidebar .property-card {
  cursor: pointer;
}

.map-sidebar .property-card.highlighted {
  border: 2px solid var(--color-primary);
}

.map-sidebar .card-carousel {
  height: 150px;
}

/* Popup del mapa */
.map-popup {
  min-width: 250px;
}

.map-popup-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 10px;
}

.map-popup-title {
  font-weight: 600;
  margin-bottom: 5px;
}

.map-popup-price {
  color: var(--color-primary);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 5px;
}

.map-popup-link {
  display: inline-block;
  padding: 5px 15px;
  background: var(--color-primary);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-top: 5px;
}

.map-popup-link:hover {
  background: var(--color-primary-dark);
}

.leaflet-container a {
  /* Arreglo de texto en boton de tarjeta en mapa */
  color: #fff !important;
}

/* ===========================================
           SIN RESULTADOS
=========================================== */

.no-results {
  text-align: center;
  padding: 60px 20px;
  background: var(--color-white);
  border-radius: var(--border-radius);
}

.no-results svg {
  width: 80px;
  height: 80px;
  color: var(--color-border);
  margin-bottom: 20px;
}

.no-results h3 {
  margin-bottom: 10px;
  color: var(--color-text);
}

.no-results p {
  color: var(--color-text-light);
}

/* ===========================================
           RESPONSIVE
=========================================== */

@media (max-width: 992px) {
  .map-view {
    flex-direction: column;
    height: auto;
  }

  #map-container {
    height: 400px;
  }

  .map-sidebar {
    width: 100%;
    max-height: 500px;
  }

  .list-view .property-card {
    flex-direction: column;
  }

  .list-view .card-carousel {
    width: 100%;
    min-width: 100%;
  }

  .list-view .card-main {
    flex-direction: column;
    gap: 15px;
  }

  .list-view .card-price-container {
    text-align: left;
  }
}

@media (max-width: 768px) {
  .destacados-header {
    flex-direction: column;
    align-items: stretch;
  }

  .destacados-controls {
    flex-wrap: wrap;
  }

  .grid-view {
    grid-template-columns: 1fr;
  }
}
