/* Offset canonici: bundle Laravel ed exporter Blog consumano lo stesso file. */
:root {
        /* Offset aggiornato via visualViewport per riallineare i fixed bottom quando la browser UI mobile cambia altezza. */
        --bp-mobile-fixed-bottom-offset: 0px;
        /* Nome storico: ora misura nello viewport corrente qualsiasi barra fissa, sia desktop sia mobile. */
        --bp-mobile-bottom-stack-height: 0px;
        /* Altezza dello stack più 24px di respiro: impedisce alle toolbar di coprire l'ultimo contenuto. */
        --bp-page-bottom-obstacle-reserve: 0px;
        --bp-mobile-visual-viewport-height: 100dvh;
        /* Un solo valore finale governa fallback e widget nativo su ogni pagina. */
        --bp-chat-viewport-bottom-offset: 0px;
        /* Lo stack include già l'eventuale inset della toolbar: la safe area copre solo il margine ancora scoperto. */
        --bp-chat-launcher-gap: max(0.75rem, calc(env(safe-area-inset-bottom, 0px) - var(--bp-mobile-bottom-stack-height, 0px)));
        --bp-chat-launcher-bottom: calc(
            var(--bp-mobile-bottom-stack-height, 0px)
            + var(--bp-chat-viewport-bottom-offset, 0px)
            + var(--bp-chat-launcher-gap, 0.75rem)
        );
    }

    html {
        /* Anche focus, anchor e scrollIntoView rispettano la stessa area sicura usata dal contenuto finale. */
        scroll-padding-bottom: var(--bp-page-bottom-obstacle-reserve, 0px);
    }

/* Fuori da @layer: la classe runtime non deve essere eliminata dal purge Tailwind. */
html.bp-page-bottom-obstacle-visible body {
    /* Il padding agisce soltanto in verticale e non può diventare una colonna vuota nelle shell flex/grid. */
    padding-bottom: var(--bp-page-bottom-obstacle-reserve, 0px);
}

html.bp-page-bottom-obstacle-visible.bp-page-bottom-reserve-in-footer body {
    /* Con il footer globale visibile, la sua barra finale assorbe la riserva e il body non crea una fascia bianca. */
    padding-bottom: 0;
}

    .bp-mobile-fixed-bottom {
        /* Le barre fixed mobile seguono il visualViewport reale, non il layout viewport lasciato dal browser. */
        bottom: var(--bp-mobile-fixed-bottom-offset, 0px) !important;
    }

    .bp-mobile-fixed-bottom-20 {
        /* Senza barra il launcher resta vicino al fondo; con una barra usa la misura condivisa. */
        z-index: 80 !important;
        bottom: var(--bp-chat-launcher-bottom, 0.75rem) !important;
    }

    @media (max-width: 767px) {
        :root {
            /* Su mobile il risultato include anche lo spostamento del visualViewport reale. */
            --bp-chat-viewport-bottom-offset: var(--bp-mobile-fixed-bottom-offset, 0px);
        }

        .bp-mobile-fixed-bottom-20 {
            /* La stessa variabile resta valida con browser chrome, tastiera e safe viewport. */
            z-index: 80 !important;
            bottom: var(--bp-chat-launcher-bottom, 0.75rem) !important;
        }
    }

    .bp-chat-floating-layer {
        /* Classe esplicita per il fallback chat: evita che shadow dei caroselli o footer sticky lo coprano. */
        z-index: 80 !important;
    }

    @media (min-width: 768px) {
        .bp-chat-floating-layer {
            /* Anche il fallback testuale usa il medesimo risultato del launcher nativo. */
            bottom: var(--bp-chat-launcher-bottom, 0.75rem) !important;
        }
    }

/* Solo il componente: nessuna dipendenza dalle utility Laravel o dagli stili WordPress. */
.bp-chat-launcher {
    position: fixed;
    right: 8px;
    z-index: 80 !important;
    bottom: var(--bp-chat-launcher-bottom, 0.75rem) !important;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: calc(100vw - 16px);
    border: 1px solid #2963d4;
    border-radius: 6px;
    padding: 6px 8px;
    background: #2963d4;
    color: #fff;
    font-family: "Lexend", sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease-in-out;
}
.bp-chat-launcher:hover { background: #427ae8; color: #fff; text-decoration: none; }
.bp-chat-launcher:focus-visible { outline: 2px solid #002f8b; outline-offset: 4px; }
.bp-chat-launcher[hidden] { display: none !important; }
@media (min-width: 768px) { .bp-chat-launcher { padding: 12px 16px; } }
@media (prefers-reduced-motion: reduce) { .bp-chat-launcher { transition: none; } }

/* Stesso riflesso discreto online/offline; nessun effetto su badge o hit area. */
.bp-chat-launcher, .bp-chat-launcher:hover {
    background-image: linear-gradient(110deg, transparent 35%, #ffffff55 50%, transparent 65%);
    background-size: 250% 100%;
    background-repeat: no-repeat;
    background-position: 200% 0;
    animation: bp-chat-launcher-shine 6s ease-in-out 1s infinite;
}
@keyframes bp-chat-launcher-shine {
    0%, 75% { background-position: 200% 0; }
    95%, 100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .bp-chat-launcher, .bp-chat-launcher:hover { animation: none; background-image: none; }
}
