/* STORE_CRM_SHARED_POPUP_V3 */

.crm-home-popup{
    position:fixed;
    inset:0;
    z-index:99999;

    display:flex;
    align-items:center;
    justify-content:center;

    padding:20px;

    background:rgba(15,23,42,.68);
    backdrop-filter:blur(5px);

    opacity:0;
    visibility:hidden;
    pointer-events:none;

    transition:
        opacity .22s ease,
        visibility .22s ease;

    /* V3: permite desplazamiento cuando el popup supera la pantalla */
    overflow-y:auto;
    overflow-x:hidden;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior:contain;
}

.crm-home-popup.is-open{
    opacity:1;
    visibility:visible;
    pointer-events:auto;
}

.crm-home-popup-card{
    position:relative;

    width:min(470px,100%);
    padding:30px;

    border:1px solid rgba(148,163,184,.25);
    border-radius:24px;

    background:#fff;
    color:#172033;

    box-shadow:0 30px 90px rgba(15,23,42,.35);

    transform:translateY(14px) scale(.98);

    transition:transform .22s ease;

    /* V3 */
    flex:0 0 auto;
    max-height:calc(100dvh - 40px);
    overflow-y:auto;
    overflow-x:hidden;
    -webkit-overflow-scrolling:touch;
}

.crm-home-popup.is-open .crm-home-popup-card{
    transform:none;
}

.crm-home-popup-close{
    position:absolute;
    top:14px;
    right:14px;

    z-index:20;

    width:36px;
    height:36px;

    border:0;
    border-radius:999px;

    background:#f1f5f9;
    color:#475569;

    font-size:22px;
    line-height:1;

    cursor:pointer;
}

.crm-home-popup-badge{
    display:inline-flex;
    align-items:center;

    margin-bottom:12px;
    padding:6px 11px;

    border-radius:999px;

    background:color-mix(
        in srgb,
        var(--crm-popup-brand) 10%,
        #fff
    );

    color:var(--crm-popup-brand);

    font-size:12px;
    font-weight:900;
}

.crm-home-popup-card h2{
    margin:0 42px 8px 0;

    font-size:26px;
    line-height:1.15;
}

.crm-home-popup-card>p{
    margin:0 0 22px;

    color:#64748b;

    line-height:1.55;
}

.crm-home-popup-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px;
}

.crm-home-popup-field{
    display:flex;
    flex-direction:column;
    gap:6px;
}

.crm-home-popup-full{
    grid-column:1/-1;
}

.crm-home-popup-field label{
    color:#334155;

    font-size:12px;
    font-weight:800;
}

.crm-home-popup-field input{
    width:100%;
    min-height:46px;

    padding:10px 12px;

    border:1px solid #cbd5e1;
    border-radius:12px;

    background:#fff;
    color:#172033;

    font:inherit;

    outline:none;
}

.crm-home-popup-field input:focus{
    border-color:var(--crm-popup-brand);

    box-shadow:
        0 0 0 3px
        color-mix(
            in srgb,
            var(--crm-popup-brand) 18%,
            transparent
        );
}

.crm-home-popup-submit{
    width:100%;
    min-height:48px;

    margin-top:16px;

    border:0;
    border-radius:12px;

    background:var(--crm-popup-brand);
    color:#fff;

    font:inherit;
    font-weight:900;

    cursor:pointer;
}

.crm-home-popup-submit:disabled{
    opacity:.65;
    cursor:not-allowed;
}

.crm-home-popup-status{
    min-height:20px;

    margin-top:10px;

    font-size:12px;
    line-height:1.4;

    text-align:center;
}

.crm-home-popup-status.is-error{
    color:#b91c1c;
}

.crm-home-popup-status.is-ok{
    color:#15803d;
}

.crm-home-popup-privacy{
    margin:12px 0 0;

    color:#94a3b8;

    font-size:11px;
    line-height:1.45;

    text-align:center;
}

body.crm-popup-open{
    overflow:hidden;
}


/* =========================================================
   MÓVIL
   ========================================================= */

@media(max-width:600px){

    .crm-home-popup{
        /*
         * IMPORTANTE:
         * antes estaba flex-end y podía esconder la parte
         * superior del popup.
         */
        align-items:flex-start;
        justify-content:center;

        padding:10px;

        overflow-y:auto;
        overflow-x:hidden;

        -webkit-overflow-scrolling:touch;
    }

    .crm-home-popup-card{
        width:100%;

        padding:26px 20px 22px;

        border-radius:22px;

        /*
         * El popup nunca supera físicamente
         * la altura visible del celular.
         */
        max-height:calc(100dvh - 20px);

        overflow-y:auto;
        overflow-x:hidden;

        -webkit-overflow-scrolling:touch;
        overscroll-behavior:contain;
    }

    /*
     * En móvil la X permanece visible
     * aunque el usuario deslice el contenido.
     */
    .crm-home-popup-close{
        position:sticky;

        top:0;

        display:flex;
        align-items:center;
        justify-content:center;

        margin-left:auto;
        margin-bottom:-36px;

        z-index:30;

        flex:0 0 36px;
    }

    .crm-home-popup-grid{
        grid-template-columns:1fr;
    }

    .crm-home-popup-full{
        grid-column:auto;
    }

    .crm-home-popup-card h2{
        font-size:23px;
    }
}


/* =========================================================
   PANTALLAS MUY BAJAS
   ========================================================= */

@media(max-height:650px){

    .crm-home-popup{
        align-items:flex-start;

        padding-top:10px;
        padding-bottom:10px;
    }

    .crm-home-popup-card{
        max-height:calc(100dvh - 20px);

        overflow-y:auto;

        -webkit-overflow-scrolling:touch;
    }
}


/* =========================================================
   ACCESIBILIDAD
   ========================================================= */

@media(prefers-reduced-motion:reduce){

    .crm-home-popup,
    .crm-home-popup-card{
        transition:none;
    }
}