/* =========================================
   EME EXTERNAL MEDIA EMBED - ESTILOS FRONTEND (Versión Estable 1.0)
   ========================================= */

/* Contenedor Principal */
.eme-media {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    background: #000;
    margin-bottom: 20px;
    z-index: 1;
}

/* CENTINELA (Wrapper Invisible para evitar saltos de layout) */
.eme-sentinel {
    display: block;
    width: 100%;
    position: relative;
    transition: height 0.1s linear; 
}

/* Ratios de Aspecto */
.eme-embed .eme-sizer { display: block; width: 100%; }
.is-16by9 .eme-sizer { padding-top: 56.25%; }   /* 16:9 */
.is-9by16 .eme-sizer { padding-top: 177.7778%; } /* 9:16 */

/* --- CAPAS ABSOLUTAS --- */
.eme-poster, 
.eme-embed iframe,
.eme-playbtn {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: 0;
    margin: 0;
    padding: 0;
}

/* 1. Portada */
.eme-poster {
    object-fit: cover !important;
    background-color: #000;
    z-index: 5;
    display: block;
}
.eme-media img.eme-poster {
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: 100% !important;
}

/* 2. Botón de Play */
.eme-playbtn {
    background-color: transparent !important;
    background: rgba(0, 0, 0, 0.3) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: none !important;
    outline: none !important;
}
.eme-playbtn:hover {
    background: rgba(0, 0, 0, 0.5) !important;
}

/* Icono */
.eme-playicon {
    width: 60px;
    height: 60px;
    fill: #fff;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5));
    transition: transform 0.2s ease;
}
.eme-playbtn:hover .eme-playicon {
    transform: scale(1.1);
}

/* 3. Iframe (Video activo) */
.eme-mode-video iframe,
.eme-media.is-playing iframe {
    z-index: 20;
    background: #000;
}

.eme-mode-image .eme-poster {
    cursor: default;
}

/* --- STICKY VIDEO (FLOTANTE) --- */
.eme-sticky-active {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    width: 300px !important;
    height: auto !important;
    aspect-ratio: 16/9;
    z-index: 99999 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border-radius: 8px;
    animation: emeSlideUp 0.3s ease-out;
    overflow: visible !important; /* Para ver botón cerrar */
}

/* Ajuste Vertical Sticky */
.eme-sticky-active.is-9by16 {
    width: 280px !important;
    aspect-ratio: 9/16;
}

/* Botón Cerrar Sticky */
.eme-close-sticky {
    position: absolute;
    top: -12px;
    right: -12px;
    background: #ff4757 !important;
    color: white !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    width: 26px;
    height: 26px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

@keyframes emeSlideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- AJUSTES MÓVILES --- */
@media (max-width: 768px) {
    .eme-sticky-active {
        width: 160px !important;
        bottom: 30px !important;
        right: 15px !important;
    }
    .eme-sticky-active.is-9by16 {
        width: 110px !important;
    }

    .eme-media {
        min-height: 1px;
    }
}
