/* Estilos base para los elementos del anuncio */
.mi-publicidad-item {
    text-align: center;
    border: none;
    box-shadow: none;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch; /* Permite que el contenido se estire para ocupar el ancho */
    width: 100%; /* Ocupa el 100% del ancho del slide */
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
    flex-grow: 1;
}

/* --- REGLAS DE VISIBILIDAD DE IMÁGENES --- */

/* Por defecto (para escritorio y pantallas grandes): */
/* La imagen de escritorio se muestra */
.mi-publicidad-item img.desktop-banner {
    display: block !important;
    width: 100% !important;
    height: auto !important; /* La altura se ajusta proporcionalmente al ancho */
    object-fit: contain !important; /* La imagen se verá completa, sin recortes. */
    margin: 0 auto !important;
}

/* La imagen móvil se oculta */
.mi-publicidad-item img.mobile-banner {
    display: none !important;
}

/* --- FIN REGLAS DE VISIBILIDAD DE IMÁGENES --- */


body.mi-publicidad-hide-title .mi-publicidad-item h3 {
    display: none;
}

.mi-publicidad-item h3 {
    margin: 0;
    font-size: 1.2em;
    line-height: 1.3;
    padding: 0 10px;
    height: 0;
    overflow: hidden;
}

/* Sobrescribimos si la opción de ocultar título NO está activa */
body:not(.mi-publicidad-hide-title) .mi-publicidad-item h3 {
    height: auto;
    margin-top: 5px;
}


/* Estilos para el CONTENEDOR WRAPPER que envuelve el carrusel */
.mi-publicidad-wrapper {
    width: 100%;
    max-width: 1200px; /* Ancho máximo deseado para el carrusel en escritorio */
    margin: 0 auto 20px auto; /* Centrar el wrapper y darle margen inferior */
    box-sizing: border-box; /* Incluir padding y borde en el ancho/alto */
    padding: 0; /* Eliminar padding por defecto en escritorio */
}


/* Estilos para el contenedor del carrusel (Swiper) */
.mi-publicidad-grid-container.swiper-container {
    width: 100% !important; /* Se adapta al 100% del ancho del WRAPPER */
    max-width: 100% !important; /* No excederá el ancho del WRAPPER */
    height: auto !important; /* El contenedor se ajusta a la altura de la imagen */
    overflow: hidden;
    position: relative;
    border: none;
    padding: 0;
}

.swiper-wrapper {
    height: 100% !important;
    align-items: center !important;
}

.swiper-slide {
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Estilos de las flechas de navegación de Swiper */
.swiper-button-prev,
.swiper-button-next {
    color: rgba(100, 100, 100, 0.3) !important;
    transition: opacity 0.3s ease, color 0.3s ease;
    opacity: 0.3 !important;
    font-size: 2.2em !important;
    width: 40px !important;
    height: 40px !important;
    margin-top: -20px !important;
    border-radius: 50% !important;
}

.swiper-button-prev:hover,
.swiper-button-next:hover {
    opacity: 1 !important;
    color: #0073aa !important;
}

/* Estilos de la paginación (puntos) de Swiper */
.swiper-pagination-bullet {
    background: #ccc !important;
    opacity: 1 !important;
}
.swiper-pagination-bullet-active {
    background: #0073aa !important;
}

/* ====================================================================== */
/* AJUSTES PARA DISPOSITIVOS MÓVILES (PANTALLAS PEQUEÑAS) */
/* Se aplica a pantallas con un ancho máximo de 768px (típico para tablets y móviles) */
@media (max-width: 768px) {
    /* Ocultar la imagen de escritorio en móvil */
    .mi-publicidad-item img.desktop-banner {
        display: none !important;
    }
    /* Mostrar la imagen móvil en móvil */
    .mi-publicidad-item img.mobile-banner {
        display: block !important;
    }

    /* Contenedor del carrusel en móvil: Altura fija y cubre el espacio */
    .mi-publicidad-grid-container.swiper-container {
        height: 100px !important; /* Altura fija para carrusel en tablets/móviles */
        margin-bottom: 15px !important;
    }

    /* Imagen dentro del carrusel en móvil: Ocupa el 100% de la altura y cubre */
    .mi-publicidad-item img.mi-publicidad-image {
        height: 100% !important; /* La imagen ocupa el 100% de la altura del contenedor */
        object-fit: cover !important; /* Cubre el espacio, puede recortar los lados de la IMAGEN MÓVIL */
    }

    /* Ajustar flechas para móvil */
    .swiper-button-prev,
    .swiper-button-next {
        font-size: 1.5em !important;
        width: 25px !important;
        height: 25px !important;
        margin-top: -12px !important;
    }

    /* Ajustes para el wrapper en móvil: ¡FORZAR ANCHO COMPLETO! */
    .mi-publicidad-wrapper {
        width: 100vw !important; /* Forzar ancho completo del viewport */
        margin-left: calc(50% - 50vw) !important; /* Centrar y compensar cualquier margen/padding del padre */
        padding: 0 !important; /* Eliminar cualquier padding interno del wrapper */
    }

    /* ¡NUEVO! Forzar que el contenedor del tema se expanda también */
    /* Este selector es muy específico para Astra/UAGB */
    .entry-content-wrap > .uagb-block-wrap > .mi-publicidad-wrapper,
    .uagb-block-wrap.wp-block-uagb-container > .mi-publicidad-wrapper {
        max-width: 100vw !important;
        width: 100vw !important;
        margin-left: calc(50% - 50vw) !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    /* Si lo anterior no funciona, intenta con este más genérico */
    .ast-container {
        max-width: 100% !important; /* Permitir que ocupe todo el ancho disponible */
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Ajustes para dispositivos móviles muy pequeños (ej. anchos menores a 480px) */
@media (max-width: 480px) {
    /* Contenedor del carrusel en móvil muy pequeño */
    .mi-publicidad-grid-container.swiper-container {
        height: 80px !important; /* Altura aún más pequeña para móviles muy estrechos */
    }

    /* Imagen dentro del carrusel en móvil muy pequeño */
    .mi-publicidad-item img.mi-publicidad-image {
        height: 100% !important; /* La imagen ocupa el 100% de la altura del contenedor */
        object-fit: cover !important; /* Cubre el espacio, puede recortar los lados de la IMAGEN MÓVIL */
    }

    .swiper-button-prev,
    .swiper-button-next {
        font-size: 1.2em !important;
        width: 20px !important;
        height: 20px !important;
        margin-top: -10px !important;
    }

    /* Ajustes para el wrapper en móvil muy pequeño: ¡FORZAR ANCHO COMPLETO! */
    .mi-publicidad-wrapper {
        width: 100vw !important; /* Forzar ancho completo del viewport */
        margin-left: calc(50% - 50vw) !important; /* Centrar y compensar cualquier margen/padding del padre */
        padding: 0 !important; /* Eliminar cualquier padding interno del wrapper */
    }
    /* ¡NUEVO! Forzar que el contenedor del tema se expanda también */
    /* Este selector es muy específico para Astra/UAGB */
    .entry-content-wrap > .uagb-block-wrap > .mi-publicidad-wrapper,
    .uagb-block-wrap.wp-block-uagb-container > .mi-publicidad-wrapper {
        max-width: 100vw !important;
        width: 100vw !important;
        margin-left: calc(50% - 50vw) !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    /* Si lo anterior no funciona, intenta con este más genérico */
    .ast-container {
        max-width: 100% !important; /* Permitir que ocupe todo el ancho disponible */
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}
