/* =========================================================
   ASISTENTE IP — HOJA DE ESTILOS
   Espacio de nombres: .ipa-*
========================================================= */

.ipa-widget {
    --ipa-azul: #153faf;
    --ipa-azul-oscuro: #0c2a73;
    --ipa-azul-noche: #08194a;
    --ipa-cian: #00c8e6;
    --ipa-dorado: #d29b4c;
    --ipa-fondo: #f4f7fd;
    --ipa-texto: #16233a;
    --ipa-suave: #6b7a90;
    --ipa-borde: #e2e8f3;

    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9999;

    font-family: inherit;
    line-height: 1.5;
}

.ipa-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}


/* =========================================================
   GLOBO DE INVITACIÓN
========================================================= */

.ipa-teaser {
    position: absolute;
    right: 0;
    bottom: 78px;

    width: 232px;
    padding: 14px 16px 15px;

    background: #fff;
    border: 1px solid var(--ipa-borde);
    border-radius: 16px 16px 4px 16px;

    box-shadow: 0 16px 38px rgba(12, 42, 115, .18);

    animation: ipaTeaser .5s cubic-bezier(.2, .9, .3, 1.3);
}

.ipa-teaser[hidden] { display: none; }

.ipa-teaser strong {
    display: block;
    margin-bottom: 3px;
    color: var(--ipa-texto);
    font-size: .93rem;
}

.ipa-teaser span {
    color: var(--ipa-suave);
    font-size: .8rem;
}

.ipa-teaser-cerrar {
    position: absolute;
    top: 6px;
    right: 6px;

    width: 22px;
    height: 22px;

    display: grid;
    place-items: center;

    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #9aa7ba;

    font-size: .75rem;
    cursor: pointer;
}

.ipa-teaser-cerrar:hover { background: #eef2f9; color: var(--ipa-texto); }

@keyframes ipaTeaser {
    from { opacity: 0; transform: translateY(12px) scale(.94); }
    to   { opacity: 1; transform: none; }
}


/* =========================================================
   BOTÓN FLOTANTE
========================================================= */

.ipa-lanzador {
    position: relative;
    isolation: isolate;

    display: flex;
    align-items: center;
    gap: 10px;

    min-width: 182px;
    height: 72px;
    padding: 0 22px 0 10px;

    border: 1px solid rgba(126, 240, 255, .72);
    border-radius: 28px;

    background: linear-gradient(145deg, #1f62e8 0%, var(--ipa-azul) 48%, var(--ipa-azul-noche) 100%);
    color: #fff;

    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .2px;

    cursor: pointer;

    box-shadow:
        0 10px 26px rgba(8, 25, 74, .42),
        0 0 24px rgba(0, 200, 230, .34);

    transition: transform .25s ease, box-shadow .25s ease, filter .25s ease;
}

.ipa-lanzador:hover {
    transform: translateY(-3px) scale(1.02);
    filter: brightness(1.1);
    box-shadow:
        0 16px 34px rgba(8, 25, 74, .48),
        0 0 32px rgba(0, 200, 230, .5);
}

.ipa-lanzador:focus,
.ipa-lanzador:focus-visible {
    outline: none !important;
    outline-offset: 0;
    -webkit-tap-highlight-color: transparent;
}

.ipa-lanzador-icono {
    position: relative;
    z-index: 1;

    width: 46px;
    height: 46px;

    display: grid;
    place-items: center;

    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 15px;
    background: linear-gradient(145deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, .1));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 0 14px rgba(126, 240, 255, .24);

    color: #fff;
    font-size: 1.15rem;
}

.ipa-lanzador-icono i {
    grid-area: 1 / 1;
    transition: opacity .2s ease, transform .3s ease;
}

.ipa-icono-cerrar { opacity: 0; transform: rotate(-90deg); }

.ipa-lanzador-texto {
    position: relative;
    z-index: 1;
    color: #fff;
    white-space: nowrap;
}

.ipa-lanzador-pulso {
    position: absolute;
    inset: 0;

    z-index: -1;
    border-radius: 28px;
    background: transparent;
    opacity: 0;
}

@keyframes ipaPulso {
    0%   { transform: scale(1);    opacity: .45; }
    70%  { transform: scale(1.18); opacity: 0; }
    100% { transform: scale(1.18); opacity: 0; }
}

.ipa-widget.ipa-abierto .ipa-icono-abrir  { opacity: 0; transform: rotate(90deg); }
.ipa-widget.ipa-abierto .ipa-icono-cerrar { opacity: 1; transform: none; }
.ipa-widget.ipa-abierto .ipa-lanzador-texto { display: block; }
.ipa-widget.ipa-abierto .ipa-lanzador { padding: 0 22px 0 10px; }
.ipa-widget.ipa-abierto .ipa-lanzador-pulso { opacity: 0; }


/* =========================================================
   PANEL
========================================================= */

.ipa-panel {
    position: absolute;
    right: 0;
    bottom: 74px;

    width: 396px;
    max-width: calc(100vw - 30px);

    height: 640px;
    max-height: calc(100vh - 130px);

    display: flex;
    flex-direction: column;
    overflow: hidden;

    background: var(--ipa-fondo);
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 24px;

    box-shadow: 0 30px 70px rgba(8, 25, 74, .28);

    animation: ipaPanel .28s cubic-bezier(.2, .9, .3, 1.15);
}

.ipa-panel[hidden] { display: none; }

@keyframes ipaPanel {
    from { opacity: 0; transform: translateY(18px) scale(.97); }
    to   { opacity: 1; transform: none; }
}


/* =========================================================
   CABECERA
========================================================= */

.ipa-cabecera {
    position: relative;

    display: flex;
    align-items: center;
    gap: 12px;

    padding: 17px 16px 19px;

    background:
        radial-gradient(circle at 88% 0%, rgba(0, 200, 230, .35) 0%, transparent 52%),
        linear-gradient(135deg, var(--ipa-azul) 0%, var(--ipa-azul-noche) 100%);
    color: #fff;
}

.ipa-avatar {
    position: relative;

    width: 44px;
    height: 44px;

    display: grid;
    place-items: center;

    border-radius: 14px;
    background: rgba(255, 255, 255, .15);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);

    font-size: 1.15rem;
}

.ipa-avatar-estado {
    position: absolute;
    right: -2px;
    bottom: -2px;

    width: 13px;
    height: 13px;

    border: 2.5px solid #123a9c;
    border-radius: 50%;
    background: #3ddc97;
}

.ipa-identidad { flex: 1; min-width: 0; }

.ipa-identidad strong {
    display: block;
    font-size: 1rem;
    letter-spacing: .2px;
}

.ipa-estado-texto {
    display: flex;
    align-items: center;
    gap: 6px;

    color: rgba(255, 255, 255, .78);
    font-size: .74rem;
}

.ipa-estado-texto i { color: #3ddc97; font-size: .45rem; }

.ipa-cabecera-acciones { display: flex; gap: 4px; }

.ipa-icono-btn {
    width: 32px;
    height: 32px;

    display: grid;
    place-items: center;

    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .12);
    color: #fff;

    font-size: .82rem;
    cursor: pointer;

    transition: background .2s ease;
}

.ipa-icono-btn:hover { background: rgba(255, 255, 255, .26); }

.ipa-progreso {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;

    height: 3px;
    background: rgba(255, 255, 255, .16);
}

.ipa-progreso span {
    display: block;
    width: 0;
    height: 100%;

    background: linear-gradient(90deg, var(--ipa-cian), #7ef0ff);
    border-radius: 0 3px 3px 0;

    transition: width .5s cubic-bezier(.4, 0, .2, 1);
}


/* =========================================================
   CONVERSACIÓN
========================================================= */

.ipa-chat {
    flex: 1;
    min-height: 0;

    padding: 18px 16px 6px;

    overflow-y: auto;
    scroll-behavior: smooth;

    background-image: radial-gradient(rgba(21, 63, 175, .055) 1px, transparent 1px);
    background-size: 22px 22px;
}

.ipa-chat::-webkit-scrollbar { width: 6px; }
.ipa-chat::-webkit-scrollbar-thumb { background: #cfd9ea; border-radius: 6px; }

.ipa-dia {
    margin: 2px 0 14px;
    color: var(--ipa-suave);
    font-size: .7rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .6px;
}

.ipa-linea {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;

    animation: ipaBurbuja .32s cubic-bezier(.2, .9, .3, 1.2);
}

.ipa-linea.ipa-de-usuario { flex-direction: row-reverse; }

@keyframes ipaBurbuja {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

.ipa-mini-avatar {
    flex: 0 0 auto;

    width: 26px;
    height: 26px;

    display: grid;
    place-items: center;

    border-radius: 50%;
    background: linear-gradient(135deg, var(--ipa-azul), var(--ipa-azul-noche));
    color: #fff;

    font-size: .65rem;
}

.ipa-linea.ipa-seguida .ipa-mini-avatar { visibility: hidden; }

.ipa-burbuja {
    max-width: 82%;
    padding: 11px 14px;

    background: #fff;
    border: 1px solid var(--ipa-borde);
    border-radius: 16px 16px 16px 5px;

    color: var(--ipa-texto);
    font-size: .89rem;

    box-shadow: 0 4px 14px rgba(16, 35, 74, .06);
}

.ipa-de-bot .ipa-burbuja strong { color: var(--ipa-azul-oscuro); }
.ipa-de-bot .ipa-burbuja a { color: var(--ipa-azul); }

.ipa-burbuja p { margin: 0 0 6px; }
.ipa-burbuja p:last-child { margin-bottom: 0; }

.ipa-de-usuario .ipa-burbuja {
    background: linear-gradient(135deg, var(--ipa-azul) 0%, var(--ipa-azul-oscuro) 100%);
    border-color: transparent;
    border-radius: 16px 16px 5px 16px;
    color: #fff;

    box-shadow: 0 6px 18px rgba(12, 42, 115, .26);
}

.ipa-de-usuario .ipa-burbuja strong,
.ipa-de-usuario .ipa-burbuja a { color: #fff; }

.ipa-hora {
    display: block;
    margin-top: 5px;

    color: var(--ipa-suave);
    font-size: .66rem;
    text-align: right;
}

.ipa-de-usuario .ipa-hora { color: rgba(255, 255, 255, .78); }

.ipa-escribiendo .ipa-burbuja {
    display: flex;
    gap: 4px;
    padding: 14px;
}

.ipa-escribiendo i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b6c2d6;
    animation: ipaPunto 1.2s infinite ease-in-out;
}

.ipa-escribiendo i:nth-child(2) { animation-delay: .16s; }
.ipa-escribiendo i:nth-child(3) { animation-delay: .32s; }

@keyframes ipaPunto {
    0%, 60%, 100% { transform: translateY(0);    opacity: .45; }
    30%           { transform: translateY(-5px); opacity: 1; }
}


/* =========================================================
   TARJETAS DENTRO DEL CHAT
========================================================= */

.ipa-tarjeta {
    width: 100%;
    margin: 2px 0 12px;
    overflow: hidden;

    background: #fff;
    border: 1px solid var(--ipa-borde);
    border-radius: 18px;

    box-shadow: 0 10px 28px rgba(16, 35, 74, .09);

    animation: ipaBurbuja .35s ease;
}

.ipa-tarjeta-cabecera {
    padding: 14px 16px;

    background: linear-gradient(135deg, var(--ipa-azul-oscuro), var(--ipa-azul-noche));
    color: #fff;
}

.ipa-tarjeta-cabecera span {
    display: block;
    color: rgba(255, 255, 255, .82);
    font-size: .68rem;
    letter-spacing: 1.1px;
    text-transform: uppercase;
}

.ipa-tarjeta-cabecera strong {
    display: block;
    margin-top: 2px;
    font-size: 1.32rem;
    color: #fff;
}

.ipa-tarjeta-cabecera small {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, .7);
    font-size: .72rem;
}

.ipa-tarjeta-cabecera,
.ipa-tarjeta-cabecera span,
.ipa-tarjeta-cabecera strong,
.ipa-tarjeta-cabecera small {
    color: #fff !important;
}

.ipa-tarjeta-cabecera span { color: rgba(255, 255, 255, .82); }
.ipa-tarjeta-cabecera small { color: rgba(255, 255, 255, .78); }

.ipa-detalle { padding: 6px 16px 4px; }

.ipa-grupo-titulo {
    margin: 10px 0 4px;
    color: var(--ipa-suave);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .9px;
    text-transform: uppercase;
}

.ipa-fila {
    display: flex;
    justify-content: space-between;
    gap: 10px;

    padding: 5px 0;
    border-bottom: 1px dashed #edf1f8;

    font-size: .8rem;
}

.ipa-fila:last-child { border-bottom: 0; }
.ipa-fila span { color: #44526b; }
.ipa-fila em { color: #93a1b6; font-style: normal; }
.ipa-fila b { color: var(--ipa-texto); font-weight: 700; white-space: nowrap; }

.ipa-totales {
    padding: 12px 16px 14px;
    background: #f7f9fd;
    border-top: 1px solid var(--ipa-borde);
}

.ipa-totales .ipa-fila { border: 0; padding: 3px 0; }

.ipa-total-final {
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid #dfe6f2;

    font-size: .95rem;
}

.ipa-total-final b { color: var(--ipa-azul); font-size: 1.05rem; }

.ipa-nota {
    display: flex;
    gap: 8px;

    padding: 10px 16px;
    background: #fff8ec;
    border-top: 1px solid #f3e4c9;

    color: #7a5a22;
    font-size: .76rem;
}

.ipa-nota i { margin-top: 2px; color: var(--ipa-dorado); }

.ipa-resumen { padding: 12px 16px 14px; }

.ipa-resumen-fila {
    display: flex;
    justify-content: space-between;
    gap: 12px;

    padding: 7px 0;
    border-bottom: 1px solid #f1f4fa;

    font-size: .82rem;
}

.ipa-resumen-fila:last-child { border-bottom: 0; }
.ipa-resumen-fila span { color: var(--ipa-suave); }
.ipa-resumen-fila b { color: var(--ipa-texto); text-align: right; font-weight: 600; }

.ipa-codigo {
    display: block;
    margin: 4px 0 2px;
    padding: 12px;

    background: #f0f5ff;
    border: 1px dashed var(--ipa-azul);
    border-radius: 12px;

    color: var(--ipa-azul-oscuro);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-align: center;
}


/* =========================================================
   ACCIONES RÁPIDAS
========================================================= */

.ipa-acciones {
    max-height: 30%;
    padding: 0 16px;
    overflow-y: auto;
}

.ipa-acciones:not(:empty) { padding: 8px 16px 4px; }

.ipa-acciones::-webkit-scrollbar { width: 6px; }
.ipa-acciones::-webkit-scrollbar-thumb { background: #cfd9ea; border-radius: 6px; }

.ipa-chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.ipa-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    width: 100%;
    min-height: 38px;
    justify-content: center;
    padding: 7px 9px;

    background: #fff;
    border: 1.5px solid #d7e0ef;
    border-radius: 30px;

    color: var(--ipa-azul-oscuro);
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.2;

    cursor: pointer;

    transition: transform .15s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.ipa-chip:hover {
    transform: translateY(-2px);
    border-color: var(--ipa-azul);
    background: #f2f6ff;
    box-shadow: 0 6px 16px rgba(21, 63, 175, .14);
}

.ipa-chip i { color: var(--ipa-azul); font-size: .85rem; }

.ipa-chip.ipa-chip-principal {
    background: linear-gradient(135deg, var(--ipa-azul), var(--ipa-azul-oscuro));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px rgba(12, 42, 115, .26);
}

.ipa-chip.ipa-chip-principal i { color: #fff; }

.ipa-chip.ipa-chip-principal span { color: #fff; }

.ipa-chip.ipa-chip-ancho { grid-column: 1 / -1; }

.ipa-contador {
    display: flex;
    align-items: center;
    gap: 14px;

    padding: 10px 12px;
    margin-bottom: 10px;

    background: #fff;
    border: 1.5px solid #d7e0ef;
    border-radius: 16px;
}

.ipa-contador button {
    width: 38px;
    height: 38px;

    display: grid;
    place-items: center;

    border: 0;
    border-radius: 12px;
    background: #eef3fd;
    color: var(--ipa-azul);

    font-size: 1rem;
    cursor: pointer;

    transition: background .2s ease, color .2s ease;
}

.ipa-contador button:hover { background: var(--ipa-azul); color: #fff; }

.ipa-contador-valor { flex: 1; text-align: center; }

.ipa-contador-valor strong {
    display: block;
    color: var(--ipa-azul-oscuro);
    font-size: 1.6rem;
    line-height: 1.1;
}

.ipa-contador-valor span {
    color: var(--ipa-suave);
    font-size: .74rem;
}


/* =========================================================
   FORMULARIO
========================================================= */

.ipa-form {
    display: grid;
    gap: 10px;

    padding: 14px;
    margin-bottom: 8px;

    background: #fff;
    border: 1px solid var(--ipa-borde);
    border-radius: 18px;

    box-shadow: 0 10px 26px rgba(16, 35, 74, .08);
}

.ipa-form-fila {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ipa-campo { display: grid; gap: 5px; }

.ipa-campo label {
    color: #48566d;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .2px;
}

.ipa-campo input,
.ipa-campo select,
.ipa-campo textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;

    border: 1.5px solid #dde4f0;
    border-radius: 11px;
    background: #fbfcfe;

    color: var(--ipa-texto);
    font: inherit;
    font-size: .85rem;

    transition: border-color .2s ease, box-shadow .2s ease;
}

.ipa-campo textarea { min-height: 70px; resize: vertical; }

.ipa-campo input:focus,
.ipa-campo select:focus,
.ipa-campo textarea:focus {
    outline: 0;
    border-color: var(--ipa-azul);
    box-shadow: 0 0 0 3px rgba(21, 63, 175, .12);
}

.ipa-campo.ipa-error input,
.ipa-campo.ipa-error select { border-color: #e2574c; background: #fff6f5; }

.ipa-campo small { color: #e2574c; font-size: .72rem; }

.ipa-check {
    display: flex;
    align-items: flex-start;
    gap: 9px;

    color: #55637a;
    font-size: .76rem;
    cursor: pointer;
}

.ipa-check input { margin-top: 2px; accent-color: var(--ipa-azul); }

.ipa-form .ipa-chip-principal { justify-content: center; width: 100%; }


.ipa-pie {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    margin: 0;
    padding: 8px 14px 10px;
    border-top: 1px solid var(--ipa-borde);

    background: #fff;
    color: #9aa7ba;
    font-size: .68rem;
}


/* =========================================================
   MÓVIL
========================================================= */

@media (max-width: 560px) {

    .ipa-widget {
        right: 14px;
        bottom: 14px;
    }

    .ipa-panel {
        position: fixed;
        inset: 0;

        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;

        border-radius: 0;
    }

    .ipa-teaser { width: 210px; }

    .ipa-lanzador {
        min-width: 166px;
        width: auto;
        height: 64px;
        padding: 0 18px 0 8px;
    }

    .ipa-widget.ipa-abierto .ipa-lanzador {
        padding: 0 18px 0 8px;
    }

    .ipa-lanzador-icono { width: 46px; height: 46px; }

    .ipa-acciones { max-height: 30%; }

    .ipa-form-fila { grid-template-columns: 1fr; }
}


/* El botón de WhatsApp del sitio sube para no tapar el asistente */
@media (min-width: 561px) {
    body .whatsapp { bottom: 96px; }
}


@media (prefers-reduced-motion: reduce) {
    .ipa-widget *,
    .ipa-widget *::before,
    .ipa-widget *::after {
        animation: none !important;
        transition: none !important;
    }
}


/* =========================================================
   OCULTAR BOTÓN FLOTANTE INFERIOR Y GLOBOS (SOLO USAR MENÚ)
========================================================= */
.ipa-lanzador,
.ipa-teaser {
    display: none !important;
}

/* Evitar que el contenedor vacío tape el botón de WhatsApp al estar cerrado */
.ipa-widget:not(.ipa-abierto) {
    pointer-events: none !important;
}

.ipa-widget.ipa-abierto {
    pointer-events: auto !important;
}

/* Apoyar la ventana del chat abajo limpiamente al no haber botón flotante */
.ipa-panel {
    bottom: 0 !important;
}
