/*
 * Anuncios.css: Estilos para la sección de anuncios y el banner principal.
 * ----------------------------------------------------------------------
 */

/* ======================================================================
 * Contenedor genérico para centrar y limitar el ancho
 * ====================================================================== */
.contenedor-principal {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
}

/* ======================================================================
 * BANNER PUBLICITARIO ONE
 * ====================================================================== */
.banner-one {
    width: 100%;
    height: 480px;
    background: url("../img/Publicidad/MaxDrean.jpg") no-repeat center center/cover;
    margin: 50px auto 20px auto;
    position: relative;
}

.banner-one .content {
    width: 50%;
    padding: 50px;
    color: #fff;
    text-align: left;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 5%;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

.banner-one h2 {
    font-weight: 900;
    color: #fff;
    text-decoration: none;
    margin-bottom: 10px;
}

.banner-one p {
    margin: 10px 0 20px 0;
    color: #fff;
    font-weight: bold;
}

/* Estilo para el botón del banner */
.banner-one .boton_personalizado {
    padding: 10px 20px;
    background-color: #007bff;
    border-radius: 5px;
    display: inline-block;
    max-width: 200px;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.3s;
    color: #fff;
}

.banner-one .boton_personalizado:hover {
    background-color: #0056b3;
}

/* ======================================================================
 * POP-UP Y OVERLAY (CORREGIDO)
 * ====================================================================== */
#overlay-anuncio.anuncios-overlay { /* Usar el ID en vez de la clase */
    background: rgba(0, 0, 0, .7);
    position: fixed;
    top: 95px;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity .5s ease;
    z-index: 999;
}

/* Estado activo del overlay */
#overlay-anuncio.anuncios-overlay.active {
    visibility: visible;
    opacity: 1;
}

#popup-anuncio { /* Usar el ID en vez de la clase */
    background: #fff;
    box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.3);
    border-radius: 15px;
    padding: 40px 20px 20px 20px;
    text-align: center;
    width: 90%;
    max-width: 600px;
    transition: transform .5s ease;
    transform: scale(0.7);
    position: relative;
    z-index: 999;
}

/* Estado activo del pop-up */
#popup-anuncio.active {
    transform: scale(1);
    margin-top: 0;
}

.btn-cerrar-popup {
    font-size: 24px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    transition: color .3s ease;
    position: absolute;
    top: 10px;
    right: 15px;
}

.btn-cerrar-popup:hover {
    color: #6890b8;
}

/* Contenido dentro del pop-up */
#anuncio-detalle-contenido {
    text-align: center;
    padding: 20px;
}

#anuncio-detalle-contenido .popup-header {
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

#anuncio-detalle-contenido .popup-descripcion {
    font-style: italic;
    color: #555;
    margin-top: -5px;
}

#anuncio-detalle-contenido .popup-body p {
    line-height: 1.6;
    margin-bottom: 15px;
}

#anuncio-detalle-contenido .popup-body img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    margin-bottom: 20px;
}

#anuncio-detalle-contenido .popup-footer {
    padding-top: 15px;
    border-top: 1px solid #eee;
    text-align: center;
}

#anuncio-detalle-contenido img {
    max-width: 100%;
    height: auto;
    margin-bottom: 15px;
    border-radius: 10px;
}

#anuncio-detalle-contenido h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
}

#anuncio-detalle-contenido p {
    font-size: 16px;
    color: #666;
    margin-bottom: 20px;
}

/* ======================================================================
 * SECCIÓN DE ANUNCIOS
 * ====================================================================== */
.anuncios-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    padding: 20px 0;
    margin-top: 20px;
}

.anuncio-item {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    aspect-ratio: 3 / 1;
    position: relative; /* Asegúrate de que el elemento esté posicionado para que z-index funcione */
    z-index: 999; /* Un valor alto para asegurar que esté por encima de todo lo demás */
    opacity: 1
}

.anuncio-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.anuncio-item a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.anuncio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

/* ======================================================================
 * MEDIA QUERIES (se unifican aquí)
 * ====================================================================== */
/* Estilos para móviles y tablets */
@media (max-width: 768px) {
    /* Estilos para el banner */
    .banner-one {
        height: 300px;
        margin-top: 20px;
    }
    
    .banner-one .content {
        position: static;
        width: 100%;
        padding: 20px;
        text-align: center;
        transform: none;
        background: none;
    }

    .banner-one h2 {
        font-size: 20px;
        line-height: 1.2;
        color: #6890b8;
    }

    .banner-one p {
        font-size: 16px;
        color: #2d6ba8;
    }

    .banner-one .boton_personalizado {
        width: auto;
        max-width: 100%;
    }
}

/* MEDIA QUERIES (Sección de anuncios para dispositivos medianos)*/
@media (max-width: 992px) {
    .anuncios-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Media query para dispositivos muy pequeños (móviles) */
@media (max-width: 500px) {
    .anuncios-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .anuncio-item {
        aspect-ratio: 3 / 1;
    }
}