/* Custom Video Popup Design */
.custom-video-popup {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 99999 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 2rem !important;
    animation: fadeIn 0.3s ease-out;
    background: transparent !important;
    box-shadow: none !important;
    pointer-events: none !important; /* Don't block clicks when hidden */
}

.custom-video-popup.active {
    pointer-events: auto !important; /* Allow clicks when active */
}

.custom-video-popup.active {
    display: flex !important;
}

.custom-video-popup.closing {
    display: flex !important; /* Keep visible during closing animation */
}

/* Override TRX Addons popup styles */
.custom-video-popup.sc_layouts_popup {
    display: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

.custom-video-popup.sc_layouts_popup.active {
    display: flex !important;
}

.mfp-content .custom-video-popup.sc_layouts_popup {
    display: none !important;
}

.mfp-content .custom-video-popup.sc_layouts_popup.active {
    display: flex !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Overlay */
.video-popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    z-index: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    display: none !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out !important;
}

.custom-video-popup.active .video-popup-overlay {
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    pointer-events: auto !important;
}

.custom-video-popup:not(.active) .video-popup-overlay,
.custom-video-popup.closing .video-popup-overlay {
    opacity: 0 !important;
    visibility: hidden !important;
    display: none !important;
    pointer-events: none !important;
    z-index: -1 !important; /* Ensure it's behind everything when hidden */
}

/* Container */
.video-popup-container {
    position: relative !important;
    z-index: 2 !important;
    width: calc(100% - 4rem) !important;
    max-width: 1200px !important;
    max-height: 90vh !important;
    background: rgba(20, 20, 25, 0.95) !important;
    backdrop-filter: blur(30px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
    border: 1px solid rgba(170, 255, 0, 0.2) !important;
    border-radius: 24px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 40px rgba(170, 255, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    overflow: hidden !important;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0 auto !important;
    box-sizing: border-box !important;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Top Border Glow */
.video-popup-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(170, 255, 0, 0.5) 50%,
        transparent);
    z-index: 1;
}

/* Close Button */
.video-popup-close {
    position: absolute !important;
    top: 1.5rem !important;
    right: 1.5rem !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(170, 255, 0, 0.2) !important;
    border-radius: 12px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 100 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    margin: 0 !important;
    padding: 0 !important;
}

.video-popup-close:hover {
    background: rgba(170, 255, 0, 0.15);
    border-color: rgba(170, 255, 0, 0.5);
    color: rgba(170, 255, 0, 1);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 20px rgba(170, 255, 0, 0.3),
                0 0 20px rgba(170, 255, 0, 0.2);
}

.video-popup-close:active {
    transform: scale(0.95) rotate(90deg);
}

.video-popup-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Content */
.video-popup-content {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(90vh - 6rem) !important;
    padding: 3rem 2rem 2rem !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

/* Video Container */
.custom-video-popup .trx_addons_video_player {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 0 !important;
    padding-bottom: 56.25% !important; /* 16:9 Aspect Ratio */
    overflow: hidden !important;
    border-radius: 16px !important;
    background: rgba(0, 0, 0, 0.3) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.custom-video-popup .video_embed,
.custom-video-popup .video_frame {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.custom-video-popup .video_embed iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .custom-video-popup {
        padding: 1rem !important;
    }
    
    .video-popup-container {
        width: calc(100% - 2rem) !important;
        max-width: 95% !important;
        max-height: 85vh !important;
    }
    
    .video-popup-content {
        padding: 2.5rem 1.5rem 1.5rem !important;
        max-height: calc(85vh - 5rem) !important;
    }
}

@media (max-width: 768px) {
    .custom-video-popup {
        padding: 1rem !important;
    }
    
    .video-popup-container {
        width: calc(100% - 2rem) !important;
        max-width: 100% !important;
        max-height: 80vh !important;
        border-radius: 20px !important;
    }
    
    .video-popup-content {
        padding: 2rem 1rem 1rem !important;
        max-height: calc(80vh - 4rem) !important;
    }
    
    .video-popup-close {
        top: 1rem !important;
        right: 1rem !important;
        width: 40px !important;
        height: 40px !important;
    }
    
    .video-popup-close svg {
        width: 18px !important;
        height: 18px !important;
    }
}

@media (max-width: 480px) {
    .custom-video-popup {
        padding: 0.5rem !important;
    }
    
    .video-popup-container {
        width: calc(100% - 1rem) !important;
        border-radius: 16px !important;
        max-height: 75vh !important;
    }
    
    .video-popup-content {
        padding: 1.5rem 0.75rem 0.75rem !important;
        max-height: calc(75vh - 3rem) !important;
    }
    
    .video-popup-close {
        top: 0.75rem !important;
        right: 0.75rem !important;
        width: 36px !important;
        height: 36px !important;
    }
    
    .video-popup-close svg {
        width: 16px !important;
        height: 16px !important;
    }
}

/* Animation for closing */
.custom-video-popup.closing {
    animation: fadeOut 0.3s ease-out forwards;
}

.custom-video-popup.closing .video-popup-overlay,
.custom-video-popup:not(.active) .video-popup-overlay {
    opacity: 0 !important;
    visibility: hidden !important;
    display: none !important;
}

.custom-video-popup.closing .video-popup-container {
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes slideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(30px);
        opacity: 0;
    }
}

/* Override Elementor styles */
.custom-video-popup .elementor,
.custom-video-popup .elementor-463,
.custom-video-popup .elementor-element,
.custom-video-popup .e-con,
.custom-video-popup .e-parent {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.custom-video-popup .elementor-widget-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.custom-video-popup .widget_area,
.custom-video-popup .widget {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}
