/**
 * Correcciones específicas para el tema Astra
 * Soluciona problemas de posicionamiento del modal
 */

/* ==========================================================================
   OVERRIDE COMPLETO PARA ASTRA THEME
   ========================================================================== */

/* Reset completo del modal overlay para Astra */
body.astra-theme .idg-modal-overlay,
.ast-desktop .idg-modal-overlay,
.ast-mobile .idg-modal-overlay,
.ast-header-break-point .idg-modal-overlay,
.ast-theme-transparent-header .idg-modal-overlay,
[class*="ast-"] .idg-modal-overlay,
body[class*="astra"] .idg-modal-overlay {
    /* Reset completo de posición */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    
    /* Z-index alto para superar header de Astra */
    z-index: 9999999 !important;
    
    /* Reset de margin/padding que Astra pueda agregar */
    margin: 0 !important;
    padding: 0 !important;
    
    /* Background y display */
    background: rgba(0, 0, 0, 0.6) !important;
    display: none !important;
    
    /* Box model */
    box-sizing: border-box !important;
    
    /* Overflow para scroll */
    overflow: auto !important;
}

/* Estado activo del overlay en Astra */
body.astra-theme .idg-modal-overlay.active,
.ast-desktop .idg-modal-overlay.active,
.ast-mobile .idg-modal-overlay.active,
.ast-header-break-point .idg-modal-overlay.active,
.ast-theme-transparent-header .idg-modal-overlay.active,
[class*="ast-"] .idg-modal-overlay.active,
body[class*="astra"] .idg-modal-overlay.active {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    padding: 20px !important;
}

/* Modal container específico para Astra */
body.astra-theme .idg-modal,
.ast-desktop .idg-modal,
.ast-mobile .idg-modal,
.ast-header-break-point .idg-modal,
.ast-theme-transparent-header .idg-modal,
[class*="ast-"] .idg-modal,
body[class*="astra"] .idg-modal {
    /* Dimensiones correctas */
    max-width: 600px !important;
    width: 100% !important;
    margin: auto !important;
    
    /* Posicionamiento */
    position: relative !important;
    
    /* Apariencia */
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    
    /* Box model */
    box-sizing: border-box !important;
    
    /* Reset de estilos de Astra */
    border: none !important;
    outline: none !important;
    
    /* Flexbox */
    display: flex !important;
    flex-direction: column !important;
}

/* Header del modal en Astra */
body.astra-theme .idg-modal-header,
.ast-desktop .idg-modal-header,
.ast-mobile .idg-modal-header,
.ast-header-break-point .idg-modal-header,
.ast-theme-transparent-header .idg-modal-header,
[class*="ast-"] .idg-modal-header,
body[class*="astra"] .idg-modal-header {
    width: 100% !important;
    background: #f8f9fa !important;
    padding: 20px 25px !important;
    border-bottom: 1px solid #e9ecef !important;
    border-radius: 12px 12px 0 0 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
}

/* Títulos del header en Astra */
body.astra-theme .idg-modal-header h1,
body.astra-theme .idg-modal-header h2,
body.astra-theme .idg-modal-header h3,
body.astra-theme .idg-modal-header h4,
body.astra-theme .idg-modal-header h5,
body.astra-theme .idg-modal-header h6,
.ast-desktop .idg-modal-header h1,
.ast-desktop .idg-modal-header h2,
.ast-desktop .idg-modal-header h3,
.ast-desktop .idg-modal-header h4,
.ast-desktop .idg-modal-header h5,
.ast-desktop .idg-modal-header h6,
.ast-mobile .idg-modal-header h1,
.ast-mobile .idg-modal-header h2,
.ast-mobile .idg-modal-header h3,
.ast-mobile .idg-modal-header h4,
.ast-mobile .idg-modal-header h5,
.ast-mobile .idg-modal-header h6,
[class*="ast-"] .idg-modal-header h1,
[class*="ast-"] .idg-modal-header h2,
[class*="ast-"] .idg-modal-header h3,
[class*="ast-"] .idg-modal-header h4,
[class*="ast-"] .idg-modal-header h5,
[class*="ast-"] .idg-modal-header h6,
body[class*="astra"] .idg-modal-header h1,
body[class*="astra"] .idg-modal-header h2,
body[class*="astra"] .idg-modal-header h3,
body[class*="astra"] .idg-modal-header h4,
body[class*="astra"] .idg-modal-header h5,
body[class*="astra"] .idg-modal-header h6 {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    color: #2c3e50 !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    text-align: left !important;
    font-size: 1.4em !important;
    flex: 1 !important;
    padding-right: 20px !important;
}

/* Botón de cerrar en Astra */
body.astra-theme .idg-modal-close,
.ast-desktop .idg-modal-close,
.ast-mobile .idg-modal-close,
.ast-header-break-point .idg-modal-close,
.ast-theme-transparent-header .idg-modal-close,
[class*="ast-"] .idg-modal-close,
body[class*="astra"] .idg-modal-close {
    background: transparent !important;
    border: none !important;
    font-size: 28px !important;
    color: #6c757d !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    line-height: 1 !important;
    box-shadow: none !important;
    text-decoration: none !important;
    outline: none !important;
}

/* Hover del botón de cerrar en Astra */
body.astra-theme .idg-modal-close:hover,
.ast-desktop .idg-modal-close:hover,
.ast-mobile .idg-modal-close:hover,
.ast-header-break-point .idg-modal-close:hover,
.ast-theme-transparent-header .idg-modal-close:hover,
[class*="ast-"] .idg-modal-close:hover,
body[class*="astra"] .idg-modal-close:hover {
    background: #004582 !important;
    color: #ffffff !important;
    border: none !important;
    text-decoration: none !important;
}

/* Focus del botón de cerrar en Astra */
body.astra-theme .idg-modal-close:focus,
.ast-desktop .idg-modal-close:focus,
.ast-mobile .idg-modal-close:focus,
.ast-header-break-point .idg-modal-close:focus,
.ast-theme-transparent-header .idg-modal-close:focus,
[class*="ast-"] .idg-modal-close:focus,
body[class*="astra"] .idg-modal-close:focus {
    background: #004582 !important;
    color: #ffffff !important;
    outline: 2px solid #3498db !important;
    outline-offset: 1px !important;
    border: none !important;
}

/* Contenido del modal en Astra */
body.astra-theme .idg-modal-content,
.ast-desktop .idg-modal-content,
.ast-mobile .idg-modal-content,
.ast-header-break-point .idg-modal-content,
.ast-theme-transparent-header .idg-modal-content,
[class*="ast-"] .idg-modal-content,
body[class*="astra"] .idg-modal-content {
    padding: 25px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border: none !important;
    flex: 1 !important;
    overflow-y: visible !important;
}

/* Body del modal en Astra */
body.astra-theme .idg-modal-body,
.ast-desktop .idg-modal-body,
.ast-mobile .idg-modal-body,
.ast-header-break-point .idg-modal-body,
.ast-theme-transparent-header .idg-modal-body,
[class*="ast-"] .idg-modal-body,
body[class*="astra"] .idg-modal-body {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 0 12px 12px !important;
    overflow: visible !important;
    max-height: none !important;
}

/* ==========================================================================
   CORRECCIONES ESPECÍFICAS PARA CONTAINERS DE ASTRA
   ========================================================================== */

/* Resetear contenedores de Astra que puedan interferir */
.ast-container .idg-modal-overlay,
.ast-page-builder-template .idg-modal-overlay,
.ast-separate-container .idg-modal-overlay,
.ast-plain-container .idg-modal-overlay,
.ast-page-builder-template .idg-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999999 !important;
    transform: none !important;
}

/* Headers de Astra que pueden tener z-index alto */
.ast-header,
.ast-primary-header,
.ast-above-header,
.ast-below-header {
    z-index: 99 !important;
}

/* Asegurar que el modal está por encima de todo en Astra */
body.astra-theme .idg-modal-overlay,
body[class*="astra"] .idg-modal-overlay,
[class*="ast-"] .idg-modal-overlay {
    z-index: 9999999 !important;
}

/* ==========================================================================
   RESPONSIVE ESPECÍFICO PARA ASTRA
   ========================================================================== */

/* Tablet en Astra */
@media (max-width: 1024px) {
    body.astra-theme .idg-modal-overlay.active,
    .ast-desktop .idg-modal-overlay.active,
    .ast-mobile .idg-modal-overlay.active,
    [class*="ast-"] .idg-modal-overlay.active,
    body[class*="astra"] .idg-modal-overlay.active {
        padding: 15px !important;
        align-items: flex-start !important;
        padding-top: 40px !important;
    }
    
    body.astra-theme .idg-modal,
    .ast-desktop .idg-modal,
    .ast-mobile .idg-modal,
    [class*="ast-"] .idg-modal,
    body[class*="astra"] .idg-modal {
        max-width: 90% !important;
        margin: 0 auto 40px auto !important;
    }
}

/* Móvil en Astra */
@media (max-width: 768px) {
    body.astra-theme .idg-modal-overlay.active,
    .ast-desktop .idg-modal-overlay.active,
    .ast-mobile .idg-modal-overlay.active,
    [class*="ast-"] .idg-modal-overlay.active,
    body[class*="astra"] .idg-modal-overlay.active {
        padding: 10px !important;
        padding-top: 20px !important;
    }
    
    body.astra-theme .idg-modal,
    .ast-desktop .idg-modal,
    .ast-mobile .idg-modal,
    [class*="ast-"] .idg-modal,
    body[class*="astra"] .idg-modal {
        max-width: 100% !important;
        width: calc(100% - 20px) !important;
        margin: 0 auto 30px auto !important;
    }
    
    body.astra-theme .idg-modal-header,
    .ast-desktop .idg-modal-header,
    .ast-mobile .idg-modal-header,
    [class*="ast-"] .idg-modal-header,
    body[class*="astra"] .idg-modal-header {
        padding: 18px 20px !important;
    }
    
    body.astra-theme .idg-modal-content,
    .ast-desktop .idg-modal-content,
    .ast-mobile .idg-modal-content,
    [class*="ast-"] .idg-modal-content,
    body[class*="astra"] .idg-modal-content {
        padding: 20px !important;
    }
}

/* Móvil pequeño en Astra */
@media (max-width: 480px) {
    body.astra-theme .idg-modal-overlay.active,
    .ast-desktop .idg-modal-overlay.active,
    .ast-mobile .idg-modal-overlay.active,
    [class*="ast-"] .idg-modal-overlay.active,
    body[class*="astra"] .idg-modal-overlay.active {
        padding: 5px !important;
        padding-top: 10px !important;
    }
    
    body.astra-theme .idg-modal,
    .ast-desktop .idg-modal,
    .ast-mobile .idg-modal,
    [class*="ast-"] .idg-modal,
    body[class*="astra"] .idg-modal {
        width: calc(100% - 10px) !important;
        border-radius: 6px !important;
        margin: 0 auto 20px auto !important;
    }
    
    body.astra-theme .idg-modal-header,
    .ast-desktop .idg-modal-header,
    .ast-mobile .idg-modal-header,
    [class*="ast-"] .idg-modal-header,
    body[class*="astra"] .idg-modal-header {
        padding: 12px !important;
        border-radius: 6px 6px 0 0 !important;
    }
    
    body.astra-theme .idg-modal-content,
    .ast-desktop .idg-modal-content,
    .ast-mobile .idg-modal-content,
    [class*="ast-"] .idg-modal-content,
    body[class*="astra"] .idg-modal-content {
        padding: 12px !important;
    }
    
    body.astra-theme .idg-modal-body,
    .ast-desktop .idg-modal-body,
    .ast-mobile .idg-modal-body,
    [class*="ast-"] .idg-modal-body,
    body[class*="astra"] .idg-modal-body {
        border-radius: 0 0 6px 6px !important;
    }
}

/* ==========================================================================
   COMPATIBILIDAD CON ELEMENTOR EN ASTRA
   ========================================================================== */

/* Asegurar funcionamiento dentro de Elementor con Astra */
body.astra-theme .elementor-widget .idg-modal-overlay,
body.astra-theme .elementor-element .idg-modal-overlay,
.ast-desktop .elementor-widget .idg-modal-overlay,
.ast-desktop .elementor-element .idg-modal-overlay,
[class*="ast-"] .elementor-widget .idg-modal-overlay,
[class*="ast-"] .elementor-element .idg-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999999 !important;
}

/* Resetear transforms de Elementor que puedan afectar el modal */
body.astra-theme [data-elementor-type] .idg-modal-overlay,
.ast-desktop [data-elementor-type] .idg-modal-overlay,
[class*="ast-"] [data-elementor-type] .idg-modal-overlay {
    transform: none !important;
}

/* ==========================================================================
   FORZAR ANCHO COMPLETO - CASOS EXTREMOS
   ========================================================================== */

/* Override absoluto para casos problemáticos */
.idg-modal-overlay[id="idg-modal-overlay"] {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    min-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 9999999 !important;
    transform: none !important;
    box-sizing: border-box !important;
}

/* Forzar overlay activo */
.idg-modal-overlay.active[id="idg-modal-overlay"] {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    padding: 20px !important;
}

/* Resetear cualquier contenedor padre problemático */
* .idg-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
}

/* Específico para contenedores de Astra que corten el ancho */
.ast-container .idg-modal-overlay,
.container .idg-modal-overlay,
.ast-separate-container .idg-modal-overlay,
.site-content .idg-modal-overlay,
.entry-content .idg-modal-overlay {
    max-width: none !important;
    width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
}

/* Estado activo para contenedores problemáticos */
.ast-container .idg-modal-overlay.active,
.container .idg-modal-overlay.active,
.ast-separate-container .idg-modal-overlay.active,
.site-content .idg-modal-overlay.active,
.entry-content .idg-modal-overlay.active {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    padding: 20px !important;
}

/* Media query para asegurar responsive */
@media screen and (max-width: 2000px) {
    .idg-modal-overlay {
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 100vw !important;
    }
}

/* Casos específicos para tamaños de ventana */
@media screen and (min-width: 1200px) {
    .idg-modal-overlay {
        width: 100vw !important;
        max-width: none !important;
    }
}

@media screen and (max-width: 1199px) {
    .idg-modal-overlay {
        width: 100vw !important;
        max-width: none !important;
    }
}

