/* ========================================
   POPUP PREMIUM - Z-INDEX MÁXIMO ABSOLUTO
   Garante que o popup apareça ACIMA DE TUDO
   ======================================== */

/* Isolamento de Stacking Context - Popup fica em seu próprio universo */
#popup-overlay {
    /* Z-INDEX MÁXIMO (valor máximo de 32-bit signed integer) */
    z-index: 2147483647 !important;

    /* Posicionamento fixo para cobrir toda a viewport */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;

    /* Backdrop blur forte */
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;

    /* Fundo escuro translúcido */
    background: rgba(0, 0, 0, 0.85) !important;

    /* Novo stacking context isolado */
    isolation: isolate !important;

    /* Centralizar conteúdo quando visível */
    align-items: center !important;
    justify-content: center !important;

    /* Garantir que eventos de clique funcionem */
    pointer-events: auto !important;
}

/* FORÇAR EXIBIÇÃO quando ativado pelo JS */
#popup-overlay.show,
#popup-overlay.active,
body.popup-open #popup-overlay {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Container do popup */
#popup-container {
    z-index: 2147483647 !important;
    position: relative !important;
    pointer-events: auto !important;
}

/* FORÇAR todos os elementos da página a ficarem ATRÁS */
body.popup-open {
    overflow: hidden !important;
    position: relative !important;
}

/* Header fixo DEVE ficar atrás quando popup aberto */
body.popup-open #site-header {
    z-index: 10 !important;
    position: relative !important;
}

/* Menu mobile DEVE ficar atrás quando popup aberto */
body.popup-open #mobile-menu,
body.popup-open #mobile-menu-overlay {
    z-index: 10 !important;
}

/* Qualquer outro elemento com z-index alto deve ser reduzido */
body.popup-open .search-popup-overlay,
body.popup-open .search-container,
body.popup-open nav,
body.popup-open header {
    z-index: 10 !important;
}

/* Garantir que NADA além do popup tenha z-index alto */
body.popup-open>*:not(#popup-overlay) {
    z-index: 1 !important;
    position: relative !important;
}

/* Resetar z-index de elementos problemáticos comuns */
body.popup-open .fixed,
body.popup-open .sticky,
body.popup-open [class*="z-"] {
    z-index: 1 !important;
}

/* Responsivo - Design mobile */
@media (max-width: 640px) {
    #popup-overlay {
        padding: 0.5rem !important;
        overflow-y: auto !important;
        align-items: flex-start !important;
        padding-top: 5vh !important;
        padding-bottom: 5vh !important;
    }

    #popup-container {
        max-width: 95vw !important;
        max-height: 90vh !important;
        margin: 0 auto !important;
        overflow-y: auto !important;
    }
}

/* Celulares muito pequenos */
@media (max-width: 480px) {
    #popup-overlay {
        padding: 0.25rem !important;
        padding-top: 3vh !important;
        padding-bottom: 3vh !important;
    }

    #popup-container {
        max-width: 98vw !important;
        max-height: 94vh !important;
    }
}

/* Animação de entrada suave */
#popup-overlay.show {
    animation: popupFadeIn 0.3s ease-out forwards !important;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }

    to {
        opacity: 1;
        backdrop-filter: blur(15px);
    }
}