/* =============================================================
   Rotar Popup Manager — Frontend CSS
   Popup centrado con overlay, animaciones y responsive design
   ============================================================= */

/* ----------------------------------------
   OVERLAY (FONDO OSCURO)
   ---------------------------------------- */

.rpmgr-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    will-change: opacity;
}

.rpmgr-overlay.rpmgr-visible {
    display: flex !important;
}

.rpmgr-overlay.rpmgr-fade-in {
    opacity: 1;
}

/* ----------------------------------------
   POPUP (VENTANA)
   ---------------------------------------- */

.rpmgr-popup {
    background: #ffffff;
    width: 100%;
    position: relative;
    overflow: hidden;
    transform-origin: center center;
    will-change: transform, opacity;
}

/* ----------------------------------------
   ANIMACIONES DE ENTRADA
   ---------------------------------------- */

/* Fade In */
.rpmgr-anim-fade {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.rpmgr-overlay.rpmgr-fade-in .rpmgr-anim-fade {
    opacity: 1;
}

/* Slide Down */
.rpmgr-anim-slide {
    opacity: 0;
    transform: translateY(-40px);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rpmgr-overlay.rpmgr-fade-in .rpmgr-anim-slide {
    opacity: 1;
    transform: translateY(0);
}

/* Zoom In */
.rpmgr-anim-zoom {
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rpmgr-overlay.rpmgr-fade-in .rpmgr-anim-zoom {
    opacity: 1;
    transform: scale(1);
}

/* Bounce */
.rpmgr-anim-bounce {
    opacity: 0;
    transform: scale(0.6) translateY(-20px);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.rpmgr-overlay.rpmgr-fade-in .rpmgr-anim-bounce {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* ----------------------------------------
   BOTÓN DE CIERRE
   ---------------------------------------- */

.rpmgr-close-btn {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    /* Color de liquidación (Cyan Gradient) */
    background: linear-gradient(135deg, #4facfe, #00f2fe) !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(79, 172, 254, 0.4) !important;
    cursor: pointer !important;
    
    /* Garantizar centrado de la X */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    
    z-index: 10 !important;
    transition: all 0.2s ease !important;
    color: #ffffff !important;
    line-height: 1 !important;
    backdrop-filter: blur(4px) !important;
    outline: none !important;
}

.rpmgr-close-btn svg {
    width: 18px !important;
    height: 18px !important;
    display: block;
    pointer-events: none;
    fill: none !important;
    stroke: currentColor !important;
}

.rpmgr-close-btn:hover {
    background: linear-gradient(135deg, #00f2fe, #4facfe) !important;
    box-shadow: 0 6px 14px rgba(79, 172, 254, 0.6) !important;
    color: #ffffff !important;
    transform: scale(1.1) rotate(90deg) !important;
}

.rpmgr-close-btn:active {
    transform: scale(0.95) !important;
    box-shadow: 0 2px 5px rgba(79, 172, 254, 0.4) !important;
}

/* ----------------------------------------
   CONTENIDO DEL POPUP
   ---------------------------------------- */

.rpmgr-popup-content {
    padding: 0;
    /* El HTML del usuario define su propio padding */
}

.rpmgr-popup-content img {
    max-width: 100%;
    height: auto;
    display: block;
}

.rpmgr-popup-content video {
    max-width: 100%;
    height: auto;
}

.rpmgr-popup-content iframe {
    max-width: 100%;
}

/* ----------------------------------------
   BARRA DE PROGRESO (AUTO-CIERRE)
   ---------------------------------------- */

.rpmgr-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(0,0,0,0.08);
    overflow: hidden;
}

.rpmgr-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    width: 100%;
    animation: rpmgr-progress-drain linear forwards;
    transform-origin: left;
}

@keyframes rpmgr-progress-drain {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ----------------------------------------
   ANIMACIÓN SALIDA (CIERRE)
   ---------------------------------------- */

.rpmgr-overlay.rpmgr-closing {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.rpmgr-overlay.rpmgr-closing .rpmgr-popup {
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* ----------------------------------------
   MODO DOCUMENTO COMPLETO (iframe)
   ---------------------------------------- */

/**
 * En modo iframe el overlay es completamente transparente —
 * el usuario trae su propio fondo/overlay dentro del iframe.
 */
.rpmgr-overlay.rpmgr-doc-mode {
    background: transparent !important;
    padding: 0;
}

/* El iframe ocupa todo el viewport para que el HTML del usuario
   se renderice tal como fue diseñado (position:fixed funciona
   relativo al viewport del iframe = viewport del sitio) */
.rpmgr-full-iframe {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    z-index: 0;
    display: block;
    pointer-events: all;
}

/* Botón de cierre flotante sobre el iframe (siempre visible) */
.rpmgr-doc-close {
    position: fixed !important;
    top: 14px !important;
    right: 14px !important;
    z-index: 10 !important; /* encima del iframe dentro del overlay */
    width: 42px !important;
    height: 42px !important;
    background: rgba(20, 20, 20, 0.75) !important;
    backdrop-filter: blur(8px);
    color: #fff !important;
    border: 1.5px solid rgba(255,255,255,0.25) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important;
}

.rpmgr-doc-close svg {
    stroke: #fff !important;
}

.rpmgr-doc-close:hover {
    background: rgba(220, 38, 38, 0.85) !important;
    color: #fff !important;
    transform: scale(1.1) rotate(90deg) !important;
    border-color: rgba(220,38,38,0.5) !important;
}

/* ----------------------------------------
   POSICIONES VERTICALES
   ---------------------------------------- */


.rpmgr-overlay[style*="flex-start"] {
    padding-top: 40px;
}

.rpmgr-overlay[style*="flex-end"] {
    padding-bottom: 40px;
}

/* ----------------------------------------
   RESPONSIVE
   ---------------------------------------- */

@media (max-width: 600px) {
    .rpmgr-overlay {
        padding: 12px;
        align-items: center !important;
    }

    .rpmgr-popup {
        max-width: 100% !important;
        border-radius: 12px !important;
    }

    .rpmgr-close-btn {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
    }
}

/* ----------------------------------------
   ACCESIBILIDAD
   ---------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .rpmgr-anim-fade,
    .rpmgr-anim-slide,
    .rpmgr-anim-zoom,
    .rpmgr-anim-bounce {
        transition: none !important;
    }
}
