/* =======================
   1. VARIABLES Y UTILIDADES
   ======================= */
:root {
  --masisa-green: #009042;
  --masisa-green-75: rgba(0, 144, 67, 0.75);
  --masisa-dark: #555;
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --transition-base: 0.3s ease;
  --radius-lg: 20px;
  --radius-md: 15px;
}

.only-desktop { display: block; }
.only-mobile { display: none; }

/* =======================
   2. GALERÍA Y CARRUSEL (Swiper)
   ======================= */
.carrousel-con-popup {
  max-width: 1320px;
  padding: 20px 0;
  margin: 0 auto;
  display: block;
}

.swiper {
  padding: 0 1.8rem 2.6rem !important;
}

.swiper-slide {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.swiper-slide img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.swiper-slide.tarjeta {
  height: auto;
}

/* Contenedor y Navegación Swiper */
.swiper-container-externo {
  position: relative;
  width: 100%;
}

.swiper-container-externo .swiper-button-prev,
.swiper-container-externo .swiper-button-next {
  position: absolute;
  top: 50% !important;
  transform: translateY(-50%);
  z-index: 10;
  color: transparent !important;
}

.swiper-container-externo .swiper-button-prev::after,
.swiper-container-externo .swiper-button-next::after {
  color: var(--masisa-dark) !important;
}

.swiper-button-next, 
.swiper-rtl .swiper-button-prev {
  right: var(--swiper-navigation-sides-offset, -20px) !important;
  left: auto;
}

.swiper-button-prev, 
.swiper-rtl .swiper-button-next {
  left: var(--swiper-navigation-sides-offset, -20px) !important;
  right: auto;
}

/* =======================
   3. TARJETAS Y ENLACES
   ======================= */
.tarjeta {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 520px; /* Altura equilibrada */
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.tarjeta-link-wrapper {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none !important;
  color: inherit;
}

.tarjeta:hover {
  transform: scale(1.02);
}

.tarjeta img {
  width: 100%;
  height: inherit;
  object-fit: cover;
  border-radius: 0;
}

.tarjeta .titulo-tarjeta {
  position: absolute;
  bottom: 0;
  background: var(--masisa-green-75);
  color: white;
  width: 100%;
  padding: .5rem 1rem;
  min-height: 6rem;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  text-align: center;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.titulo-tarjeta img {
  width: 21px;
  margin-top: -4px;
}

.tarjeta .top-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: bold;
}

/* =======================
   4. EFECTOS HOVER (GIF vs ESTÁTICA)
   ======================= */
.gif-wrap-pop {
  position: relative;
  width: 100%;
  height: calc(520px - 6rem); /* Espacio reservado para el título */
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.gif-wrap-pop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: bottom;
  /* position-area: bottom; <- Eliminado: regla no válida */
  transition: transform 0.5s ease, opacity var(--transition-base);
}

/* Hover de tarjeta CON GIF */
.gif-wrap-pop .gif-pop {
  opacity: 0;
  pointer-events: none;
}
.gif-wrap-pop:hover .gif-pop { opacity: 1; }
.gif-wrap-pop:hover .poster { opacity: 0; }

/* Hover de tarjeta SIN GIF */
.carrousel-con-popup .swiper-slide.tarjeta.has-no-gif-hover:hover {
  box-shadow: 0 15px 30px rgba(0,0,0,0.18); 
}
.carrousel-con-popup .swiper-slide.tarjeta.has-no-gif-hover:hover .gif-wrap-pop img {
  transform: scale(1.06); /* Zoom sutil 6% */
}

/* =======================
   5. BOTONES Y FILTROS
   ======================= */
.img-filtro {
  filter: brightness(0) invert(1);
  transition: filter 0.5s ease;
  width: 25px !important;
  height: 25px !important;
}

.custom-button-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  color: #000;
  background-color: #f5f5f5;
  border-radius: 999px;
  font-weight: 500;
  font-size: 14px;
  transition: background-color var(--transition-base), color var(--transition-base);
}

.custom-button-badge img {
  height: 28px;
  width: 28px;
}

.custom-button-badge:hover {
  background-color: #e0e0e0;
}

/* =======================
   6. POPUP DETALLE
   ======================= */
.popup-detalle {
  display: none;
  position: fixed;
  inset: 0;
  background-color: var(--overlay-bg);
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 20px;
  box-sizing: border-box;
}

.popup-detalle .contenido {
  width: 100%;
  max-width: 1000px;
  height: 90vh;
  max-height: 700px;
  background-size: cover;
  background-position: center;
  border-radius: var(--radius-md);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  animation: fadeIn var(--transition-base) ease;
}

.close-btn-detalle {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(0,0,0,0.3);
  border: none;
  font-size: 28px;
  color: #fff;
  cursor: pointer;
  z-index: 10;
}

.close-btn-detalle:hover {
  background: var(--overlay-bg);
}

.popup-detalle .texto-popup {
  background: var(--masisa-green);
  padding: 20px;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.texto-popup h3 {
  font-size: 20px;
  font-weight: 400;
  color: #fff;
}

.popup-detalle .popup-texto {
  margin: 0;
  font-size: 16px;
  line-height: 18px;
  color: #ddd;
  max-width: 500px;
  text-align: justify;
}

.popup-detalle-texto {
  position: relative;
  width: 100%;
}

.text-popup {
  max-width: 600px;
  line-height: 19px;
  margin-bottom: 10px;
}

.texto-popup a {
  color: #fff;
  display: flex;
  gap: 6px;  
  font-weight: 500;
  text-transform: uppercase;
}

/* =======================
   7. CARRUSEL INTERNO (Popup)
   ======================= */
.carrusel-imagenes {
  position: relative;
  height: 100%;
  overflow: visible; /* Elimina duplicidad con initial !important */
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.slide {
  display: none;
  height: 100%;
  width: 100%;
  position: absolute;
}

.slide.active {
  display: block;
  animation: fadeIn 0.5s ease-in-out;
}

.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.carrusel-imagenes .prev, 
.carrusel-imagenes .next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 30px;
  font-weight: bold;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  padding: 10px;
  cursor: pointer;
  z-index: 2;
}

.carrusel-imagenes .prev { left: 10px; }
.carrusel-imagenes .next { right: 10px; }

@keyframes fadeIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* =======================
   8. RESPONSIVE COMPACTADO
   ======================= */
@media (max-width: 1024px) and (min-width: 769px) {  
  .tarjeta { width: 45%; }
}

@media (max-width: 768px) {
  .only-desktop { display: none; }
  .only-mobile { display: block; }
  
  .tarjeta { width: 100%; }
  .swiper { padding: 0 !important; }
  
  .popup-detalle .contenido { max-width: 100%; }
  .text-popup {
    font-size: 14px;
    line-height: 16px;
  }
  
  .swiper-container-externo .swiper-button-prev,
  .swiper-container-externo .swiper-button-next {
    display: none !important;
  }
}

// Forzar centrado slider
.swiper-wrapper {
  justify-content: center !important;
}