/**
 * Beaver Builder Smart Popup - Styles
 * 
 * @package Beaver_Builder_Smart_Popup
 * @version 1.0.1
 */

/* Hide automatic popups completely - High specificity to avoid theme conflicts */
.universal-popup-controller .uabb-modal-parent-wrapper[data-modal-on="automatic"] .uabb-modal,
.universal-popup-controller .uabb-modal-parent-wrapper .uabb-modal[data-modal-on="automatic"],
.uabb-modal-parent-wrapper[data-modal-on="automatic"] .uabb-modal,
.uabb-modal-parent-wrapper .uabb-modal[data-modal-on="automatic"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Only show when manually triggered by our smart triggers - High specificity */
.universal-popup-controller .uabb-modal-parent-wrapper.popup-triggered .uabb-modal,
.uabb-modal-parent-wrapper.popup-triggered .uabb-modal {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Dynamic class support - These will be updated via JavaScript based on admin settings */
.universal-popup-controller [data-popup-wrapper][data-modal-on="automatic"] [data-popup-modal],
.universal-popup-controller [data-popup-wrapper] [data-popup-modal][data-modal-on="automatic"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

.universal-popup-controller [data-popup-wrapper][data-popup-show] [data-popup-modal],
[data-popup-wrapper][data-popup-show] [data-popup-modal] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Smooth popup animations and proper centering */
.uabb-modal {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 999999 !important;
    max-width: 90vw !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
}

/* Prevent multiple popups */
.popup-triggered {
    pointer-events: auto;
}

/* Mobile optimization for popup structure */
@media (max-width: 768px) {
    .uabb-modal {
        /* Ensure mobile-friendly sizing */
        max-width: 95vw !important;
        max-height: 95vh !important;
        margin: 0 !important;
        /* Keep the same centering as desktop */
        transform: translate(-50%, -50%) !important;
    }
    
    /* Optimize images in popup for mobile */
    .uabb-modal .fl-photo-img {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Prevent popup when user is filling forms - Compatible with theme's popup-blocking class */
body.user-filling-form .uabb-modal-parent-wrapper,
body.popup-blocking .uabb-modal-parent-wrapper {
    pointer-events: none;
}

/* Enhanced close button styling */
.uabb-modal-close {
    transition: all 0.2s ease-in-out;
}

.uabb-modal-close:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

/* Ensure popup content is properly visible */
.uabb-modal-content-data {
    position: relative;
    z-index: 1001;
}

/* Optimize the overlay */
.uabb-overlay {
    transition: opacity 0.3s ease-in-out;
}

/* Loading state for popup initialization */
.beaver-builder-popup-loading .uabb-modal-parent-wrapper {
    opacity: 0.5;
    pointer-events: none;
}

/* Debug mode indicators */
.beaver-builder-debug-mode .uabb-modal-parent-wrapper {
    border: 2px dashed #0073aa;
    position: relative;
}

.beaver-builder-debug-mode .uabb-modal-parent-wrapper::before {
    content: "Beaver Builder Smart Popup";
    position: absolute;
    top: -20px;
    left: 0;
    background: #0073aa;
    color: white;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
    z-index: 1000;
}

/* Accessibility improvements */
.uabb-modal:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .uabb-modal {
        border: 2px solid currentColor;
    }
    
    .uabb-modal-close {
        border: 1px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .uabb-modal,
    .uabb-overlay,
    .uabb-modal-close {
        transition: none !important;
    }
}

/* Override page builder positioning conflicts */
.uabb-modal-parent-wrapper .uabb-modal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 999999 !important;
}

/* Ensure overlay covers full screen */
.uabb-modal-parent-wrapper .uabb-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999998 !important;
}

/* Print styles - hide popups when printing */
@media print {
    .uabb-modal-parent-wrapper {
        display: none !important;
    }
}
