/**
 * NP Pop Up Builder — Styles Front-end (Glassmorphism)
 * Préfixage systématique nppb- pour isolation Divi.
 * v1.1.0
 */

/* ══════════════════════════════════════════════════════════════
   VARIABLES CSS
   ══════════════════════════════════════════════════════════════ */

:root {
    --nppb-glass-bg-light: rgba(255, 255, 255, 0.90);
    --nppb-glass-border-light: rgba(255, 255, 255, 0.50);
    --nppb-glass-shadow-light: 0 12px 40px rgba(0, 0, 0, 0.15);
    --nppb-text-primary-light: #121221;
    --nppb-text-secondary-light: #3a3a5a;

    --nppb-glass-bg-dark: rgba(25, 25, 35, 0.85);
    --nppb-glass-border-dark: rgba(255, 255, 255, 0.15);
    --nppb-glass-shadow-dark: 0 12px 40px rgba(0, 0, 0, 0.45);
    --nppb-text-primary-dark: #ffffff;
    --nppb-text-secondary-dark: #d0d0e5;

    --nppb-blur: 16px;
    --nppb-radius: 24px;
    --nppb-radius-img: 14px;
    --nppb-z: 999999;
}


/* ══════════════════════════════════════════════════════════════
   KEYFRAMES — Animations d'entrée / sortie
   ══════════════════════════════════════════════════════════════ */

@keyframes nppb-overlay-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes nppb-popup-in {
    0% {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes nppb-overlay-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes nppb-popup-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
}


/* ══════════════════════════════════════════════════════════════
   OVERLAY
   ══════════════════════════════════════════════════════════════ */

html body .nppb-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--nppb-z);
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: var(--nppb-overlay-color, rgba(0, 0, 0, 0.55));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease-out, visibility 0s linear 0.35s;
}

html body .nppb-overlay.nppb-overlay--visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.35s ease-out, visibility 0s linear 0s;
}


/* ══════════════════════════════════════════════════════════════
   POPUP — Structure de base
   ══════════════════════════════════════════════════════════════ */

html body .nppb-overlay .nppb-popup {
    position: relative;
    width: calc(100% - 40px);
    max-width: 520px;
    max-height: calc(100vh - 80px);
    margin: auto;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: var(--nppb-radius);
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    opacity: 0;
    transform: translateY(30px) scale(0.96);
    transition: opacity 0.5s ease-out 0.1s, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.1s;

    /* Scrollbar stylée */
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 128, 0.3) transparent;
}

html body .nppb-overlay .nppb-popup::-webkit-scrollbar {
    width: 6px;
}

html body .nppb-overlay .nppb-popup::-webkit-scrollbar-track {
    background: transparent;
}

html body .nppb-overlay .nppb-popup::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
}

html body .nppb-overlay.nppb-overlay--visible .nppb-popup {
    opacity: 1;
    transform: translateY(0) scale(1);
}


/* ══════════════════════════════════════════════════════════════
   THÈME CLAIR (par défaut)
   ══════════════════════════════════════════════════════════════ */

body .nppb-overlay .nppb-popup.nppb-theme--light,
body .nppb-overlay .nppb-popup.nppb-theme--auto {
    background-color: #ffffff; /* Fallback */
    background: var(--nppb-glass-bg-light);
    backdrop-filter: blur(var(--nppb-blur));
    -webkit-backdrop-filter: blur(var(--nppb-blur));
    border: 1px solid var(--nppb-glass-border-light);
    box-shadow: var(--nppb-glass-shadow-light);
    color: var(--nppb-text-primary-light);
}

body .nppb-overlay .nppb-popup.nppb-theme--light .nppb-popup__text,
body .nppb-overlay .nppb-popup.nppb-theme--auto .nppb-popup__text {
    color: var(--nppb-text-secondary-light);
}

body .nppb-overlay .nppb-popup.nppb-theme--light .nppb-close,
body .nppb-overlay .nppb-popup.nppb-theme--auto .nppb-close {
    color: #ffffff;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body .nppb-overlay .nppb-popup.nppb-theme--light .nppb-close:hover,
body .nppb-overlay .nppb-popup.nppb-theme--auto .nppb-close:hover {
    background: rgba(0, 0, 0, 0.65);
}


/* ══════════════════════════════════════════════════════════════
   THÈME SOMBRE
   ══════════════════════════════════════════════════════════════ */

body .nppb-overlay .nppb-popup.nppb-theme--dark {
    background-color: #1e1e32; /* Fallback */
    background: var(--nppb-glass-bg-dark);
    backdrop-filter: blur(var(--nppb-blur));
    -webkit-backdrop-filter: blur(var(--nppb-blur));
    border: 1px solid var(--nppb-glass-border-dark);
    box-shadow: var(--nppb-glass-shadow-dark);
    color: var(--nppb-text-primary-dark);
}

body .nppb-overlay .nppb-popup.nppb-theme--dark .nppb-popup__text {
    color: var(--nppb-text-secondary-dark);
}

body .nppb-overlay .nppb-popup.nppb-theme--dark .nppb-close {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body .nppb-overlay .nppb-popup.nppb-theme--dark .nppb-close:hover {
    background: rgba(255, 255, 255, 0.35);
}


/* ══════════════════════════════════════════════════════════════
   THÈME AUTO — Media query prefers-color-scheme
   ══════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
    body .nppb-overlay .nppb-popup.nppb-theme--auto {
        background: var(--nppb-glass-bg-dark);
        border-color: var(--nppb-glass-border-dark);
        box-shadow: var(--nppb-glass-shadow-dark);
        color: var(--nppb-text-primary-dark);
    }

    body .nppb-overlay .nppb-popup.nppb-theme--auto .nppb-popup__text {
        color: var(--nppb-text-secondary-dark);
    }

    body .nppb-overlay .nppb-popup.nppb-theme--auto .nppb-close {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.2);
    }

    body .nppb-overlay .nppb-popup.nppb-theme--auto .nppb-close:hover {
        background: rgba(255, 255, 255, 0.35);
    }
}


/* ══════════════════════════════════════════════════════════════
   BOUTON FERMER — Très visible sur les images
   ══════════════════════════════════════════════════════════════ */

html body .nppb-overlay .nppb-popup .nppb-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s ease, transform 0.25s ease;
    padding: 0;
    margin: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    line-height: 1;
    font-size: 0;
}

html body .nppb-overlay .nppb-popup .nppb-close:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

html body .nppb-overlay .nppb-popup .nppb-close:focus-visible {
    outline: 2px solid var(--nppb-accent, #6C5CE7);
    outline-offset: 2px;
}

html body .nppb-overlay .nppb-popup .nppb-close svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}


/* ══════════════════════════════════════════════════════════════
   IMAGE
   ══════════════════════════════════════════════════════════════ */

body .nppb-overlay .nppb-popup .nppb-popup__image {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--nppb-radius) var(--nppb-radius) 0 0;
    line-height: 0;
    margin: 0;
    padding: 0;
}

body .nppb-overlay .nppb-popup .nppb-popup__image img {
    width: 100%;
    height: auto;
    max-height: 260px;
    object-fit: cover;
    display: block;
    border: none;
    outline: none;
    margin: 0;
    padding: 0;
}


/* ══════════════════════════════════════════════════════════════
   ALIGNEMENT
   ══════════════════════════════════════════════════════════════ */

body .nppb-overlay .nppb-popup.nppb-align--left {
    text-align: left;
}

body .nppb-overlay .nppb-popup.nppb-align--center {
    text-align: center;
}

body .nppb-overlay .nppb-popup.nppb-align--right {
    text-align: right;
}


/* ══════════════════════════════════════════════════════════════
   CONTENU
   ══════════════════════════════════════════════════════════════ */

body .nppb-overlay .nppb-popup .nppb-popup__content {
    padding: 28px 32px 32px;
    box-sizing: border-box;
}

body .nppb-overlay .nppb-popup .nppb-popup__title {
    margin: 0 0 12px 0;
    padding: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

body .nppb-overlay .nppb-popup .nppb-popup__text {
    margin: 0 0 24px 0;
    padding: 0;
    font-size: 15px;
    line-height: 1.65;
}

body .nppb-overlay .nppb-popup .nppb-popup__text p {
    margin: 0 0 10px 0;
}

body .nppb-overlay .nppb-popup .nppb-popup__text p:last-child {
    margin-bottom: 0;
}


/* ══════════════════════════════════════════════════════════════
   BOUTON CTA
   ══════════════════════════════════════════════════════════════ */

html body .nppb-overlay .nppb-popup .nppb-popup__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    background: var(--nppb-accent, #6C5CE7);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    margin: 0;
    line-height: 1;
    box-sizing: border-box;
}

html body .nppb-overlay .nppb-popup .nppb-popup__cta:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(108, 92, 231, 0.45);
    filter: brightness(1.08);
    color: #ffffff;
    text-decoration: none;
}

html body .nppb-overlay .nppb-popup .nppb-popup__cta:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(108, 92, 231, 0.3);
}

html body .nppb-overlay .nppb-popup .nppb-popup__cta:focus-visible {
    outline: 2px solid var(--nppb-accent, #6C5CE7);
    outline-offset: 3px;
}


/* ══════════════════════════════════════════════════════════════
   ANIMATION DE SORTIE
   ══════════════════════════════════════════════════════════════ */

body .nppb-overlay.nppb-overlay--closing {
    animation: nppb-overlay-out 0.3s ease-in forwards;
}

body .nppb-overlay.nppb-overlay--closing .nppb-popup {
    animation: nppb-popup-out 0.25s ease-in forwards;
}


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   ══════════════════════════════════════════════════════════════ */

@media screen and (max-width: 600px) {
    body .nppb-overlay {
        padding: 10px;
        align-items: flex-end;
    }

    body .nppb-overlay .nppb-popup {
        max-width: 100%;
        width: 100%;
        max-height: 85vh;
        border-radius: var(--nppb-radius) var(--nppb-radius) 0 0;
        margin-bottom: 0;
    }

    body .nppb-overlay .nppb-popup .nppb-popup__content {
        padding: 20px 20px 28px;
    }

    body .nppb-overlay .nppb-popup .nppb-popup__title {
        font-size: 19px;
        padding-right: 40px;
    }

    body .nppb-overlay .nppb-popup .nppb-popup__text {
        font-size: 14px;
    }

    body .nppb-overlay .nppb-popup .nppb-popup__cta {
        width: 100%;
        text-align: center;
        padding: 16px 24px;
        font-size: 16px;
    }

    body .nppb-overlay .nppb-popup .nppb-popup__image img {
        max-height: 200px;
    }

    body .nppb-overlay .nppb-popup .nppb-close {
        top: 8px;
        right: 8px;
    }
}

@media screen and (max-width: 380px) {
    body .nppb-overlay .nppb-popup .nppb-popup__content {
        padding: 16px 16px 24px;
    }

    body .nppb-overlay .nppb-popup .nppb-popup__title {
        font-size: 17px;
    }
}


/* ══════════════════════════════════════════════════════════════
   RESET DIVI — Override des styles globaux Divi
   ══════════════════════════════════════════════════════════════ */

body .nppb-overlay,
body .nppb-overlay *,
body .nppb-overlay *::before,
body .nppb-overlay *::after {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body .nppb-overlay .nppb-popup h2,
body .nppb-overlay .nppb-popup h3 {
    padding-bottom: 0 !important;
    border: none !important;
    text-transform: none !important;
    letter-spacing: -0.02em !important;
}

body .nppb-overlay .nppb-popup a {
    text-decoration: none;
}

body .nppb-overlay .nppb-popup img {
    box-shadow: none !important;
}


/* ══════════════════════════════════════════════════════════════
   RÉDUCTION DE MOUVEMENT (Accessibilité)
   ══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    body .nppb-overlay,
    body .nppb-overlay .nppb-popup,
    body .nppb-overlay .nppb-popup .nppb-close,
    body .nppb-overlay .nppb-popup .nppb-popup__cta {
        transition-duration: 0.01s !important;
        animation: none !important;
    }
}
