/* ========================================
   DYNAMIC POPUP STYLES
   ======================================== */

/* Base Overlay Styles */
.dynamic-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
}

/* Overlay Opacity Classes */
.dynamic-popup-overlay.overlay-opacity-none {
    background-color: rgba(0, 0, 0, 0) !important;
}

.dynamic-popup-overlay.overlay-opacity-low {
    background-color: rgba(0, 0, 0, 0.3) !important;
}

.dynamic-popup-overlay.overlay-opacity-medium {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

.dynamic-popup-overlay.overlay-opacity-high {
    background-color: rgba(0, 0, 0, 0.9) !important;
}

.dynamic-popup-overlay.open {
    display: block;
}

/* Modal style needs flex when open */
.dynamic-popup-overlay.style-modal.open {
    display: flex !important;
}

/* ========================================
   DEVICE TARGETING
   ======================================== */

/* Hide on mobile/tablet for desktop-only popups */
@media (max-width: 1024px) {
    .dynamic-popup-overlay.device-desktop {
        display: none !important;
    }
}

/* Hide on desktop for mobile-only popups */
@media (min-width: 1025px) {
    .dynamic-popup-overlay.device-mobile {
        display: none !important;
    }
}

/* Popup Content Container Base */
.dynamic-popup-content-container {
    position: relative;
    margin: auto;
    max-height: 90vh;
    overflow-y: auto;
}

/* ========================================
   STYLE: MODAL (Centered Modal)
   ======================================== */
.dynamic-popup-overlay.style-modal {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px;
}

.dynamic-popup-overlay.style-modal .dynamic-popup-content-container {
    margin: 0 !important;
    transform: none !important;
    position: relative !important;
    flex-shrink: 0;
}

/* ========================================
   SIZE VARIANTS (Apply to all styles)
   ======================================== */

/* Size: Small */
.dynamic-popup-overlay.size-small .dynamic-popup-content-container {
    max-width: 400px;
}

/* Size: Medium */
.dynamic-popup-overlay.size-medium .dynamic-popup-content-container {
    max-width: 600px;
}

/* Size: Large */
.dynamic-popup-overlay.size-large .dynamic-popup-content-container {
    max-width: 900px;
}

/* Size: Full (Full Screen) */
.dynamic-popup-overlay.size-full .dynamic-popup-content-container {
    width: 95vw;
    height: 95vh;
    margin: auto;
}

/* Size: Custom - handled via inline styles from backend */
.dynamic-popup-overlay.size-custom .dynamic-popup-content-container {
    /* Width and height set via inline styles */
}

/* Modal-specific size adjustments */
.dynamic-popup-overlay.style-modal.size-small .dynamic-popup-content-container,
.dynamic-popup-overlay.style-modal.size-medium .dynamic-popup-content-container,
.dynamic-popup-overlay.style-modal.size-large .dynamic-popup-content-container {
    width: 100%;
}

.dynamic-popup-overlay.style-modal.size-full .dynamic-popup-content-container {
    width: 95vw;
    height: 95vh;
    margin: 2.5vh 2.5vw;
}

/* ========================================
   STYLE: BANNER TOP
   ======================================== */
.dynamic-popup-overlay.style-bannerTop {
    background-color: transparent;
    pointer-events: none;
}

.dynamic-popup-overlay.style-bannerTop .dynamic-popup-content-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    height: auto !important;
    margin: 0 !important;
    border-radius: 0 !important;
    pointer-events: all;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    overflow-y: visible !important;
}

.dynamic-popup-overlay.style-bannerTop .dynamic-popup-inner-content {
    max-width: 100% !important;
    width: 100% !important;
}

.dynamic-popup-overlay.style-bannerTop .mmb-container {
    pointer-events: all;
}

/* ========================================
   STYLE: BANNER BOTTOM
   ======================================== */
.dynamic-popup-overlay.style-bannerBottom {
    background-color: transparent;
    pointer-events: none;
}

.dynamic-popup-overlay.style-bannerBottom .dynamic-popup-content-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    height: auto !important;
    margin: 0 !important;
    border-radius: 0 !important;
    pointer-events: all;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    overflow-y: visible !important;
}

.dynamic-popup-overlay.style-bannerBottom .dynamic-popup-inner-content {
    max-width: 100% !important;
    width: 100% !important;
}

.dynamic-popup-overlay.style-bannerBottom .mmb-container {
    pointer-events: all;
}

/* ========================================
   STYLE: SLIDE IN LEFT
   ======================================== */
.dynamic-popup-overlay.style-slideInLeft {
    /*background-color: transparent !important;*/
    pointer-events: none;
}

.dynamic-popup-overlay.style-slideInLeft .dynamic-popup-content-container {
    position: fixed;
    left: -100%;
    top: 50%;
    transform: translateY(-50%);
    width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    margin: 0;
    pointer-events: all;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    transition: left 2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.dynamic-popup-overlay.style-slideInLeft.open .dynamic-popup-content-container {
    left: 0;
}

.dynamic-popup-overlay.style-slideInLeft .mmb-container {
    pointer-events: all;
}

/* ========================================
   STYLE: SLIDE IN RIGHT
   ======================================== */
.dynamic-popup-overlay.style-slideInRight {
    background-color: transparent !important;
    pointer-events: none;
}

.dynamic-popup-overlay.style-slideInRight .dynamic-popup-content-container {
    position: fixed;
    right: -100%;
    top: 50%;
    transform: translateY(-50%);
    width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    margin: 0;
    pointer-events: all;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    transition: right 2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.dynamic-popup-overlay.style-slideInRight.open .dynamic-popup-content-container {
    right: 0;
}

.dynamic-popup-overlay.style-slideInRight .mmb-container {
    pointer-events: all;
}

/* ========================================
   SIZE ADJUSTMENTS FOR SLIDE POPUPS
   ======================================== */

/* Slide Left/Right - Size Small */
.dynamic-popup-overlay.style-slideInLeft.size-small .dynamic-popup-content-container,
.dynamic-popup-overlay.style-slideInRight.size-small .dynamic-popup-content-container {
    width: 300px;
}

/* Slide Left/Right - Size Medium */
.dynamic-popup-overlay.style-slideInLeft.size-medium .dynamic-popup-content-container,
.dynamic-popup-overlay.style-slideInRight.size-medium .dynamic-popup-content-container {
    width: 400px;
}

/* Slide Left/Right - Size Large */
.dynamic-popup-overlay.style-slideInLeft.size-large .dynamic-popup-content-container,
.dynamic-popup-overlay.style-slideInRight.size-large .dynamic-popup-content-container {
    width: 500px;
}

/* Slide Left/Right - Size Full (takes significant width) */
.dynamic-popup-overlay.style-slideInLeft.size-full .dynamic-popup-content-container,
.dynamic-popup-overlay.style-slideInRight.size-full .dynamic-popup-content-container {
    width: 80vw;
    max-width: 80vw;
    height: 100vh;
    max-height: 100vh;
}

/* ========================================
   SIZE ADJUSTMENTS FOR BANNER POPUPS
   ======================================== */

/* Banners are always full width, but can control height with sizes */
.dynamic-popup-overlay.style-bannerTop.size-small .dynamic-popup-content-container,
.dynamic-popup-overlay.style-bannerBottom.size-small .dynamic-popup-content-container {
    max-height: 120px;
}

.dynamic-popup-overlay.style-bannerTop.size-medium .dynamic-popup-content-container,
.dynamic-popup-overlay.style-bannerBottom.size-medium .dynamic-popup-content-container {
    max-height: 200px;
}

.dynamic-popup-overlay.style-bannerTop.size-large .dynamic-popup-content-container,
.dynamic-popup-overlay.style-bannerBottom.size-large .dynamic-popup-content-container {
    max-height: 300px;
}

.dynamic-popup-overlay.style-bannerTop.size-full .dynamic-popup-content-container,
.dynamic-popup-overlay.style-bannerBottom.size-full .dynamic-popup-content-container {
    max-height: none;
    height: auto;
}

/* ========================================
   CLOSE BUTTON STYLING
   ======================================== */

/* Simple image-based close button */
.dynamic-popup-overlay .dynamic-popup-close-button {
    z-index: 10;
    position: absolute;
    top: 5px;
    right: 5px;
    width: 25px;
    height: 25px;
    cursor: pointer;
    background-repeat: no-repeat;
    background-size: cover;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.dynamic-popup-overlay .dynamic-popup-close-button:hover {
    opacity: 0.7;
    transform: scale(1.1);
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */
@media (max-width: 768px) {
    /* Modal on Mobile - Full Width */
    .dynamic-popup-overlay.style-modal {
        padding: 10px;
    }
    
    .dynamic-popup-overlay.style-modal.size-small .dynamic-popup-content-container,
    .dynamic-popup-overlay.style-modal.size-medium .dynamic-popup-content-container,
    .dynamic-popup-overlay.style-modal.size-large .dynamic-popup-content-container {
        max-width: 100%;
        width: 100%;
    }
    
    .dynamic-popup-overlay.style-modal.size-full .dynamic-popup-content-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
    }
    
    /* Slide Popups on Mobile - Smaller Width */
    .dynamic-popup-overlay.style-slideInLeft .dynamic-popup-content-container,
    .dynamic-popup-overlay.style-slideInRight .dynamic-popup-content-container {
        width: 320px;
        max-width: 85vw;
    }
    
    /* Banner Popups - Ensure Full Width */
    .dynamic-popup-overlay.style-bannerTop .dynamic-popup-content-container,
    .dynamic-popup-overlay.style-bannerBottom .dynamic-popup-content-container {
        width: 100%;
    }
    
    /* Inner Content Padding on Mobile */
    .dynamic-popup-inner-content {
        padding: 20px !important;
    }
    
    /* Buttons Stack on Mobile */
    .dynamic-popup-inner-content .btn-container {
        display: block !important;
        width: 100% !important;
        margin-bottom: 10px !important;
    }
    
    .dynamic-popup-inner-content .btn-container a,
    .dynamic-popup-inner-content .btn-container button {
        width: 100% !important;
        display: block !important;
    }
}

@media (max-width: 480px) {
    /* Extra Small Mobile Adjustments */
    .dynamic-popup-overlay.style-slideInLeft .dynamic-popup-content-container,
    .dynamic-popup-overlay.style-slideInRight .dynamic-popup-content-container {
        width: 280px;
        max-width: 90vw;
    }
    
    .dynamic-popup-content-container {
        font-size: 14px;
    }
    
    .dynamic-popup-inner-content h2,
    .dynamic-popup-inner-content .h3 {
        font-size: 1.3em !important;
    }
}

/* ========================================
   ANIMATION SUPPORT
   ======================================== */
.dynamic-popup-overlay.animated {
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

/* Fade Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.fadeIn { animation-name: fadeIn; }
.fadeOut { animation-name: fadeOut; }

/* Slide Animations */
@keyframes slideInUp {
    from {
        transform: translate3d(0, 100%, 0);
        visibility: visible;
    }
    to { transform: translate3d(0, 0, 0); }
}

@keyframes slideInDown {
    from {
        transform: translate3d(0, -100%, 0);
        visibility: visible;
    }
    to { transform: translate3d(0, 0, 0); }
}

@keyframes slideInLeft {
    from {
        transform: translate3d(-100%, 0, 0);
        visibility: visible;
    }
    to { transform: translate3d(0, 0, 0); }
}

@keyframes slideInRight {
    from {
        transform: translate3d(100%, 0, 0);
        visibility: visible;
    }
    to { transform: translate3d(0, 0, 0); }
}

@keyframes slideOutUp {
    from { transform: translate3d(0, 0, 0); }
    to {
        visibility: hidden;
        transform: translate3d(0, -100%, 0);
    }
}

@keyframes slideOutDown {
    from { transform: translate3d(0, 0, 0); }
    to {
        visibility: hidden;
        transform: translate3d(0, 100%, 0);
    }
}

@keyframes slideOutLeft {
    from { transform: translate3d(0, 0, 0); }
    to {
        visibility: hidden;
        transform: translate3d(-100%, 0, 0);
    }
}

@keyframes slideOutRight {
    from { transform: translate3d(0, 0, 0); }
    to {
        visibility: hidden;
        transform: translate3d(100%, 0, 0);
    }
}

.slideInUp { animation-name: slideInUp; }
.slideInDown { animation-name: slideInDown; }
.slideInLeft { animation-name: slideInLeft; }
.slideInRight { animation-name: slideInRight; }
.slideOutUp { animation-name: slideOutUp; }
.slideOutDown { animation-name: slideOutDown; }
.slideOutLeft { animation-name: slideOutLeft; }
.slideOutRight { animation-name: slideOutRight; }

/* Zoom Animations */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    50% { opacity: 1; }
}

@keyframes zoomOut {
    from { opacity: 1; }
    50% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 0.3);
    }
    to { opacity: 0; }
}

.zoomIn { animation-name: zoomIn; }
.zoomOut { animation-name: zoomOut; }

/* ========================================
   ACCESSIBILITY & UX IMPROVEMENTS
   ======================================== */
.dynamic-popup-overlay {
    -webkit-overflow-scrolling: touch;
}

.dynamic-popup-content-container {
    -webkit-overflow-scrolling: touch;
}

/* Focus Trap for Accessibility */
.dynamic-popup-overlay.open {
    overflow-y: auto;
}

/* Smooth Scrolling on Mobile */
@media (max-width: 768px) {
    .dynamic-popup-overlay {
        overflow-y: auto;
    }
}
