/* popup-styles.css */

/* Blocca scroll della pagina quando popup è aperto */
body.popup-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* FORZA header, footer e elementi specifici sotto il popup */
body.popup-open #header-outer,
body.popup-open #header-space,
body.popup-open header,
body.popup-open footer,
body.popup-open #footer-outer,
body.popup-open .nectar-slider-wrap,
body.popup-open #slide-out-widget-area,
body.popup-open .off-canvas-menu-container,
body.popup-open #ajax-loading-screen,
body.popup-open .admin-bar-search,
body.popup-open .banner-search,
body.popup-open .wpb_row.banner-search,
body.popup-open .nectar-video-wrap,
body.popup-open .row-bg-layer {
    z-index: 1 !important;
    position: relative !important;
}

/* Container popup principale */
#fullscreen-popup {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 2147483647 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#fullscreen-popup.active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Forza visibilità bottone quando popup è attivo */
#fullscreen-popup.active #popup-close,
body.popup-open #fullscreen-popup #popup-close {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 9999 !important;
    cursor: pointer !important;
}

/* Overlay scuro */
.popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.9) !important;
    cursor: pointer;
    z-index: 1 !important;
    pointer-events: auto !important;
}

/* Contenitore scrollabile */
.popup-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 2 !important; /* Sotto al bottone close ma sopra all'overlay */
    -webkit-overflow-scrolling: touch;
    /* IMPORTANTE: trasparente ai click per far passare i click al bottone X */
    pointer-events: none;
    /* Nasconde la scrollbar ma mantiene lo scroll */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Nasconde scrollbar per WebKit (Chrome, Safari, Edge) */
.popup-container::-webkit-scrollbar {
    display: none;
}

/* Area contenuto */
.popup-content-item {
    display: none;
    position: relative !important;
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 40px 80px;
    min-height: 100vh;
    background: #fff;
    z-index: 1 !important; /* Basso per stare sotto al bottone close */
    /* Riabilita i click sul contenuto */
    pointer-events: auto;
}

/* Pulsante chiusura */
#popup-close {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    width: 50px;
    height: 50px;
    background: #fff !important;
    border: none !important;
    border-radius: 50%;
    cursor: pointer !important;
    z-index: 9999 !important; /* Sopra a tutto dentro il popup */
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    line-height: 1;
    transition: background 0.3s ease, transform 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    /* Importante: isola il bottone dal container scrollabile */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    isolation: isolate;
}

#popup-close:hover {
    background: #f0f0f0 !important;
    transform: rotate(90deg);
}

#popup-close::before {
    content: "×";
    color: #333;
    pointer-events: none;
    display: block;
}

/* Stili contenuto popup */
.popup-content-item h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #333;
}

.popup-content-item h2 {
    font-size: 2em;
    margin: 30px 0 15px;
    color: #444;
}

.popup-content-item h3 {
    font-size: 1.5em;
    margin: 20px 0 10px;
    color: #555;
}

.popup-content-item p {
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 15px;
    color: #666;
}

/* Bottoni popup */
.popup-button {
    display: inline-block;
    padding: 12px 30px;
    margin: 10px 10px 10px 0;
    background: #0066cc;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 5px;
    transition: background 0.3s ease, transform 0.2s ease;
    font-weight: 600;
    font-size: 1em;
}

.popup-button:hover {
    background: #0052a3;
    transform: translateY(-2px);
}

.popup-button.secondary {
    background: #6c757d;
}

.popup-button.secondary:hover {
    background: #545b62;
}

.popup-button.success {
    background: #28a745;
}

.popup-button.success:hover {
    background: #218838;
}

.button-group {
    margin-top: 30px;
}

/* Responsive */
@media (max-width: 768px) {
    .popup-content-item {
        padding: 80px 20px 60px;
        /* Assicura che il contenuto non copra il bottone */
        margin-top: 0;
    }
    
    /* Forza visibilità bottone close su mobile */
    #popup-close,
    #fullscreen-popup #popup-close,
    #fullscreen-popup.active #popup-close,
    body.popup-open #popup-close {
        position: fixed !important;
        width: 44px !important;
        height: 44px !important;
        top: 15px !important;
        right: 15px !important;
        font-size: 28px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 9999 !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        background: #fff !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6) !important;
        transform: translateZ(0) !important;
        -webkit-transform: translateZ(0) !important;
        isolation: isolate;
        border: none !important;
        border-radius: 50% !important;
    }
    
    /* Supporto per admin bar WordPress su mobile */
    .admin-bar #popup-close {
        top: 61px !important; /* 46px admin bar + 15px */
    }
    
    @media (max-width: 600px) {
        .admin-bar #popup-close {
            top: 15px !important; /* Admin bar nascosta sotto 600px */
        }
    }
    
    .popup-content-item h1 {
        font-size: 2em;
    }
    
    .popup-button {
        width: 100%;
        text-align: center;
        margin: 10px 0;
    }
}

/* Fix per schermi ultra-wide (4K e superiori) */
@media (min-width: 2000px) {
    /* Limita il container per non interferire col bottone */
    .popup-container {
        width: calc(100% - 100px) !important;
        right: auto !important;
    }
    
    /* Aumenta distanza bottone dal bordo su schermi grandi */
    #popup-close {
        top: 30px !important;
        right: 30px !important;
        width: 60px !important;
        height: 60px !important;
        font-size: 36px !important;
    }
}