/* Lanzador del chat de la Guía Médica — FIATC
   Icono fijo + burbuja de aviso. Autónomo: no depende de los estilos de la página. */

.fx-launcher {
    --fx-blue: #2F5595;
    --fx-blue-dark: #002A5C;
    --fx-blue-light: #CEE1F2;
    --fx-red: #ED1C24;
    --fx-white: #FFFFFF;
    --fx-black: #333333;
    --fx-grey: #7C878E;
    --fx-grey-light: #C5CBD2;
    --fx-size: 60px;

    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* BOTÓN */

.fx-launcher__btn {
    position: relative;
    flex: 0 0 auto;
    width: var(--fx-size);
    height: var(--fx-size);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, #3A66AC 0%, var(--fx-blue) 45%, var(--fx-blue-dark) 100%);
    box-shadow: 0 6px 18px rgba(0, 42, 92, .28), 0 2px 4px rgba(0, 42, 92, .18);
    cursor: pointer;
    transform: scale(0);
    transition: transform .25s ease, box-shadow .25s ease;
}

.fx-launcher.is-ready .fx-launcher__btn {
    animation: fx-entrada .7s cubic-bezier(.34, 1.56, .64, 1) forwards;
}

.fx-launcher__btn:hover,
.fx-launcher__btn:focus-visible {
    box-shadow: 0 10px 26px rgba(0, 42, 92, .36), 0 3px 6px rgba(0, 42, 92, .2);
    outline: none;
}

.fx-launcher__btn:focus-visible {
    outline: 3px solid var(--fx-blue-light);
    outline-offset: 3px;
}

.fx-launcher__btn:active {
    transform: scale(.94);
}

.fx-launcher__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--fx-white);
}

.fx-launcher__icon svg {
    width: 28px;
    height: 28px;
    display: block;
}

/* El icono respira cada pocos segundos para llamar la atención sin molestar */
.fx-launcher.is-ready .fx-launcher__icon {
    animation: fx-respira 6s ease-in-out 3s infinite;
}

.fx-launcher__btn:hover .fx-launcher__icon {
    animation: none;
    transform: scale(1.08);
    transition: transform .25s ease;
}

/* Halo: dos ondas al aparecer */
.fx-launcher__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--fx-blue);
    opacity: 0;
    pointer-events: none;
}

.fx-launcher.is-ready .fx-launcher__ring {
    animation: fx-onda 2.4s ease-out 1s 2;
}

/* Punto rojo de aviso, desaparece al abrir el chat */
.fx-launcher__dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--fx-red);
    border: 2px solid var(--fx-white);
    opacity: 0;
    transform: scale(0);
    transition: opacity .2s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.fx-launcher.has-aviso .fx-launcher__dot {
    opacity: 1;
    transform: scale(1);
}

/* BURBUJA */

.fx-launcher__bubble {
    position: relative;
    max-width: 260px;
    padding: 14px 38px 14px 18px;
    border-radius: 18px 18px 4px 18px;
    background: var(--fx-white);
    box-shadow: 0 8px 24px rgba(0, 42, 92, .16);
    color: var(--fx-black);
    font-size: 15px;
    line-height: 22px;
    font-weight: 600;
    text-align: left;
    opacity: 0;
    transform: translateY(8px) scale(.9);
    transform-origin: 100% 100%;
    pointer-events: none;
    cursor: pointer;
    transition: opacity .2s ease, transform .2s ease;
}

.fx-launcher.is-abierta .fx-launcher__bubble {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    animation: fx-burbuja .5s cubic-bezier(.34, 1.56, .64, 1);
}

/* Primero escribe, luego aparece el texto */
.fx-launcher__puntos {
    display: flex;
    gap: 5px;
    height: 22px;
    align-items: center;
}

.fx-launcher__puntos i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--fx-grey-light);
    animation: fx-escribe 1.2s ease-in-out infinite;
}

.fx-launcher__puntos i:nth-child(2) { animation-delay: .15s; }
.fx-launcher__puntos i:nth-child(3) { animation-delay: .3s; }

.fx-launcher__texto {
    display: none;
}

.fx-launcher.is-escrito .fx-launcher__puntos { display: none; }

.fx-launcher.is-escrito .fx-launcher__texto {
    display: block;
    animation: fx-texto .35s ease both;
}

.fx-launcher__cerrar {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--fx-grey);
    cursor: pointer;
    line-height: 0;
    transition: background .2s ease, color .2s ease;
}

.fx-launcher__cerrar:hover {
    background: #F1F4F8;
    color: var(--fx-black);
}

.fx-launcher__cerrar:focus-visible {
    outline: 2px solid var(--fx-blue);
    outline-offset: 1px;
}

.fx-launcher__cerrar svg {
    width: 12px;
    height: 12px;
}

/* ANIMACIONES */

@keyframes fx-entrada {
    0%   { transform: scale(0) rotate(-25deg); }
    100% { transform: scale(1) rotate(0); }
}

@keyframes fx-onda {
    0%   { opacity: .5; transform: scale(1); }
    70%  { opacity: 0; transform: scale(1.7); }
    100% { opacity: 0; transform: scale(1.7); }
}

@keyframes fx-respira {
    0%, 88%, 100% { transform: scale(1); }
    92%           { transform: scale(1.12); }
    96%           { transform: scale(.98); }
}

@keyframes fx-burbuja {
    0%   { transform: translateY(10px) scale(.86); }
    60%  { transform: translateY(0) scale(1.03); }
    100% { transform: none; }
}

@keyframes fx-escribe {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

@keyframes fx-texto {
    0%   { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: none; }
}

/* MÓVIL */

@media (max-width: 600px) {
    .fx-launcher {
        --fx-size: 56px;
        right: 16px;
        bottom: 16px;
        left: 16px;
    }

    .fx-launcher__bubble {
        max-width: none;
        flex: 1;
    }
}

/* Sin animaciones si el usuario las ha desactivado en su sistema */

@media (prefers-reduced-motion: reduce) {
    .fx-launcher *,
    .fx-launcher *::after {
        animation: none !important;
        transition: none !important;
    }

    .fx-launcher .fx-launcher__btn {
        transform: none;
    }
}
