/* =========================================================================
   MODULAR PRIVACY POPUP (OS26 - PIXEL PERFECT)
   ========================================================================= */

:root {
    --privacy-bg-color: #000000;
    --privacy-app-icon: url('app-icon.png');
    --os-blue: #007AFF;
    --os-radius-desk: 26px;
    --os-radius-mob: 33px;
}

/* --- VIEWPORT & OVERLAY --- */
#optout-popup {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    position: fixed;
    z-index: 99999;
    top: 0; left: 0; width: 100vw; height: 100vh;
}

#optout-popup.active {
    opacity: 1;
    pointer-events: auto;
}

.c-popup-viewport {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%; height: 100%;
    /* SF Pro Priority */
    font-family: "SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

.c-popup-viewport::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--privacy-bg-color);
    opacity: 0.5;
    z-index: -1;
}

.c-popup-before { flex-grow: 0.8; }
.c-popup-after { flex-grow: 1.2; }


/* =========================================
   DESKTOP STYLES (Défaut)
   ========================================= */

.c-popup {
    position: relative;
    width: 260px; /* Fixe */
    height: auto; /* La hauteur s'adapte au contenu, min 256px */
    min-height: 256px;
    
    /* DESK LIGHT */
    background-color: rgba(255,255,255,0.74);
    border: 1px solid rgba(255,255,255,0.20);
    box-shadow: 
        inset 0 0.5px 0.5px 0 rgba(255,255,255,0.45), 
        0 0 1px 0 rgba(0,0,0,0.60), 
        0 10px 30px 0 rgba(0,0,0,0.15), 
        0 20px 50px 0 rgba(0,0,0,0.30);
    border-radius: var(--os-radius-desk);
    
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    
    overflow: hidden;
    transform: scale(1.1);
    opacity: 0;
}

#optout-popup.active .c-popup {
    animation: popup-appear-desk 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards;
}

@keyframes popup-appear-desk {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.c-popup-content {
    padding: 20px 16px 16px 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

.inside-popup {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* --- ICONE (Desk) --- */
.app-icon {
    width: 64px; height: 64px;
    margin: 0 auto 16px 0;
    background-image: var(--privacy-app-icon);
    background-size: contain;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

/* --- TEXTE (Desk) --- */
p.c-message {
    font-size: 13px;
    font-weight: 700;
    line-height: 16px;
    color: #000;
    margin: 0 0 22px 0;
    text-align: left;
    letter-spacing: 0;
}

/* --- CHECKBOX ROW (Desk) --- */
.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    cursor: default !important;
}

.checkbox-label {
    font-size: 13px;
    font-weight: 510; /* Semi-bold spécifique */
    line-height: 16px;
    text-align: left;
    color: #000;
    opacity: 0.8; /* Légère atténuation pour hiérarchie */
    letter-spacing: -0.2px;
}

/* CUSTOM NATIVE CHECKBOX */
.checkbox-container input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    background-color: rgba(0,0,0,0.07); /* Match button bg when unchecked */
    margin: 0;
    font: inherit;
    width: 16px;
    height: 16px;
    border-radius: 4px; /* Standard macOS checkbox radius */
    border: none; /* Pas de bordure demandée en unchecked */
    display: grid;
    place-content: center;
    flex-shrink: 0;
    cursor: default !important;
    margin-top: 1px; /* Alignement optique avec le texte */
}

/* État Checked (Bleu natif) */
.checkbox-container input[type="checkbox"]:checked {
    background-color: var(--os-blue);
}

/* Le check (SVG encodé ou CSS) */
.checkbox-container input[type="checkbox"]::before {
    content: "";
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: 0.1s transform ease-in-out;
    box-shadow: inset 1em 1em white;
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.checkbox-container input[type="checkbox"]:checked::before {
    transform: scale(1);
}


/* --- BUTTON (Desk) --- */
.inside-popup button.leave-button {
    width: 100%;
    height: 29px; /* Hauteur spécifique desk */
    background-color: rgba(0,0,0,0.07); /* Light mode */
    color: #000; /* Texte noir en light */
    border: none;
    border-radius: 99px; /* Max radius */
    font-size: 13px;
    font-weight: 510;
    letter-spacing: -0.2px;
    cursor: default !important;
    margin-top: auto; /* Pousse en bas si espace */
    transition: background-color 0.1s;
}

.inside-popup button.leave-button:active {
    background-color: rgba(0,0,0,0.15);
}


/* =========================================
   DARK MODE DESK
   ========================================= */
@media (prefers-color-scheme: dark) {
    .c-popup {
        background-color: rgba(32,32,32,0.57);
        /* Bordures et Ombres identiques au light (spécifié dans prompt) */
        border: 1px solid rgba(255,255,255,0.20);
        box-shadow: inset 0 0.5px 0.5px 0 rgba(255,255,255,0.45), 0 0 1px 0 rgba(0,0,0,0.60), 0 10px 30px 0 rgba(0,0,0,0.15), 0 20px 50px 0 rgba(0,0,0,0.30);
    }

    p.c-message { color: #fff; }
    .checkbox-label { color: #fff; opacity: 1; font-weight: 400; /* Ajustement optique dark */ }
    
    /* Checkbox Dark Unchecked */
    .checkbox-container input[type="checkbox"] {
        background-color: rgba(255,255,255,0.08);
    }
    
    /* Bouton Dark */
    .inside-popup button.leave-button {
        background-color: rgba(255,255,255,0.08);
        color: #fff;
    }
    .inside-popup button.leave-button:active {
        background-color: rgba(255,255,255,0.15);
    }
}


#matomo-opt-out {
    padding: 0 6px;
}

/* =========================================
   MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 600px) {
    
    #matomo-opt-out {
        padding: 0 14px;
    }

    .c-popup {
        /* Largeur dynamique */
        width: auto;
        max-width: 320px;
        margin: 0 36px; /* 36px des bords */
        height: auto;
        min-height: auto;
        
        /* MOBILE LIGHT */
        border-radius: var(--os-radius-mob);
        background-color: rgba(255,255,255,0.74);
        border: 1px solid rgba(255,255,255,0.20);
        /* Ombre Mobile Spécifique */
        box-shadow: inset 0 0 1px 1px #FFFFFF, 0 10px 60px 0 rgba(0,0,0,0.15), 0 20px 200px 0 rgba(0,0,0,0.15);
    }

    .c-popup-content {
        padding: 21px 16px 16px 16px;
    }

    #optout-popup.active .c-popup {
        animation: popup-appear-mobile 0.3s ease forwards;
    }
    @keyframes popup-appear-mobile {
        from { transform: scale(1.2); opacity: 0; }
        to   { transform: scale(1); opacity: 1; }
    }

    /* Pas d'icône sur mobile */
    .app-icon { display: none; }

    /* TEXTE Mobile */
    p.c-message {
        font-size: 17px;
        font-weight: 600;
        line-height: 22px;
        margin-bottom: 30px;
    }

    /* CHECKBOX Mobile */
    .checkbox-container {
        margin-bottom: 30px;
    }
    .checkbox-label {
        font-size: 15px;
        font-weight: 400;
        line-height: 20px;
        letter-spacing: 0;
    }
    .checkbox-container input[type="checkbox"] {
        width: 18px;
        height: 18px;
        background-color: rgba(0,0,0,0.10); /* Match button mobile light */
    }

    /* BOUTON Mobile */
    .inside-popup button.leave-button {
        height: 48px;
        font-size: 17px;
        line-height: 16px; /* Tight line-height demandé */
        font-weight: 510;
        letter-spacing: -0.06px;
        background-color: rgba(0,0,0,0.10);
    }
}

/* DARK MODE MOBILE OVERRIDES */
@media (max-width: 600px) and (prefers-color-scheme: dark) {
    .c-popup {
        background: rgba(32,32,32,0.57);
        border: 1px solid rgba(255,255,255,0.20);
        /* Ombre Mobile Dark Spécifique */
        box-shadow: 0 10px 60px 0 rgba(0,0,0,0.15), 0 20px 200px 0 rgba(0,0,0,0.15);
    }
    
    .checkbox-container input[type="checkbox"] {
        background-color: rgba(255,255,255,0.12);
    }
    
    .inside-popup button.leave-button {
        background-color: rgba(255,255,255,0.12);
    }
}