/**
 * Popup Shell - Stili centralizzati
 *
 * Modifica questo file per cambiare l'aspetto di TUTTI i popup.
 * Variabili CSS per facile personalizzazione.
 *
 * NOTA: Usa prefisso "cldsh-" per evitare conflitti con _popup_custom.scss
 */

/* ==========================================================================
   VARIABILI CSS - Modifica qui per personalizzare
   ========================================================================== */
:root {
    /* Overlay */
    --cldsh-overlay-bg: rgba(0, 0, 0, 0.6);

    /* Shell / Box */
    --cldsh-bg: #ffffff;
    --cldsh-border-radius: 5px;
    --cldsh-padding-x: 50px;
    --cldsh-padding-y: 30px;
    --cldsh-max-width: 500px;
    --cldsh-min-width: 320px;

    /* Bottone X */
    --cldsh-close-size: 53px;
    --cldsh-close-bg: var(--blu-3, #0066CC);
    --cldsh-close-border: 2px solid #ffffff;

    /* Kicker / Titoletto */
    --cldsh-kicker-size: 0.75rem;
    --cldsh-kicker-weight: 600;
    --cldsh-kicker-color: inherit;

    /* Titolo */
    --cldsh-title-size: 2.25rem;
    --cldsh-title-weight: 700;
    --cldsh-title-color: var(--bs-primary, #0d6efd);

    /* Contenuto */
    --cldsh-content-size: 1.25rem;
    --cldsh-content-color: #000000;

    /* Bottoni - spaziatura */
    --cldsh-actions-gap: 1rem;
    --cldsh-actions-margin-top: 1.5rem;
}

/* ==========================================================================
   OVERLAY
   ========================================================================== */
.cldsh-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.cldsh-backdrop {
    position: absolute;
    inset: 0;
    background: var(--cldsh-overlay-bg);
    cursor: pointer;
}

/* ==========================================================================
   SHELL / BOX
   ========================================================================== */
.cldsh-box {
    position: relative;
    background: var(--cldsh-bg);
    border-radius: var(--cldsh-border-radius);
    padding: var(--cldsh-padding-y) var(--cldsh-padding-x);
    max-width: var(--cldsh-max-width);
    min-width: var(--cldsh-min-width);
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* Varianti dimensione */
.cldsh-box--large {
    max-width: 800px;
}

.cldsh-box--xlarge {
    max-width: 1100px;
}

/* ==========================================================================
   BOTTONE X (CHIUSURA)
   - Cerchio posizionato con centro nell'angolo in alto a destra
   ========================================================================== */
.cldsh-close {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(50%, -50%);
    width: var(--cldsh-close-size);
    height: var(--cldsh-close-size);
    border-radius: 50%;
    background: var(--cldsh-close-bg);
    border: var(--cldsh-close-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.cldsh-close:hover {
    transform: translate(50%, -50%) scale(1.05);
}

.cldsh-close:focus {
    outline: 2px solid var(--cldsh-close-bg);
    outline-offset: 2px;
}

.cldsh-close svg {
    width: 28px;
    height: 26px;
}

/* ==========================================================================
   KICKER / TITOLETTO
   ========================================================================== */
.cldsh-kicker {
    font-size: var(--cldsh-kicker-size);
    font-weight: var(--cldsh-kicker-weight);
    color: var(--cldsh-kicker-color);
    margin: 0 0 0.25rem 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.cldsh-kicker:empty {
    display: none;
}

/* ==========================================================================
   TITOLO
   ========================================================================== */
.cldsh-title {
    font-size: var(--cldsh-title-size);
    font-weight: var(--cldsh-title-weight);
    color: var(--cldsh-title-color);
    margin: 0 0 1rem 0;
    line-height: 1.2;
}

.cldsh-title:empty {
    display: none;
}

/* ==========================================================================
   BODY / CONTENUTO
   ========================================================================== */
.cldsh-body {
    font-size: var(--cldsh-content-size);
    color: var(--cldsh-content-color);
    line-height: 1.5;
}

.cldsh-body:empty {
    display: none;
}

.cldsh-body p {
    margin: 0 0 0.75rem 0;
}

.cldsh-body p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   ACTIONS / BOTTONI
   ========================================================================== */
.cldsh-actions {
    display: flex;
    gap: var(--cldsh-actions-gap);
    margin-top: var(--cldsh-actions-margin-top);
}
 
.cldsh-actions:empty {
    display: none;
}

/* Layout orizzontale (default) - bottoni distribuiti agli estremi */
.cldsh-actions--horizontal {
    flex-direction: row;
    justify-content: space-between;
}

/* Layout verticale */
.cldsh-actions--vertical {
    flex-direction: column;
}

.cldsh-actions--vertical .btn {
    width: 100%;
}

/* Layout centrato */
.cldsh-actions--center {
    justify-content: center;
}

/* ==========================================================================
   BOTTONE "PIÙ TARDI" / LINK SECONDARIO
   - Bottone testuale senza bordi, usato come azione secondaria
   ========================================================================== */
.btn-popup-later {
    background: none;
    border: none;
    color: var(--bs-primary, #0d6efd);
    font-size: 1.125rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    text-align: left;
}

/* In layout verticale i bottoni occupano tutta la larghezza */
.cldsh-actions--vertical .btn-popup-later {
    width: 100%;
    text-align: center;
}

.btn-popup-later:hover {
    text-decoration: underline;
}

.btn-popup-later:focus {
    outline: none;
}

/* ==========================================================================
   ANIMAZIONI
   ========================================================================== */
.cldsh-overlay {
    animation: cldshFadeIn 0.2s ease;
}

.cldsh-box {
    animation: cldshSlideIn 0.25s ease;
}

@keyframes cldshFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes cldshSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Animazione chiusura */
.cldsh-overlay.cldsh--closing {
    animation: cldshFadeOut 0.15s ease forwards;
}

.cldsh-overlay.cldsh--closing .cldsh-box {
    animation: cldshSlideOut 0.15s ease forwards;
}

@keyframes cldshFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes cldshSlideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 576px) {
    .cldsh-box {
        min-width: auto;
        max-width: calc(100% - 2rem);
        --cldsh-padding-x: 20px;
    }

    .cldsh-title {
        font-size: 1.75rem;
    }

    .cldsh-body {
        font-size: 1rem;
    }

    /* Su mobile i bottoni in verticale */
    .cldsh-actions--horizontal {
        flex-direction: column;
    }

    .cldsh-actions--horizontal .btn {
        width: 100%;
    }
}

/* ==========================================================================
   UTILITÀ
   ========================================================================== */

/* Nessun focus ring visibile dentro al popup */
.cldsh-box *:focus:not(.cldsh-close) {
    outline: none;
}

/* Body overflow hidden quando popup è aperto */
body.cldsh-open {
    overflow: hidden;
}
