/* ═══════════════════════════════════════════════════════════════════════════
   wwwroot/css/priszus.css — Asistente virtual Priszus
   LOTE PRISZUS-1 (24/11/2026)

   Lo carga priszus.js cuando la página ya ha terminado (no bloquea nada).
   Todo cuelga de .prz-raiz para no chocar con los estilos de la web.
   Colores de la web: #008572 (verde) y #dfbb3e (dorado).
   ═══════════════════════════════════════════════════════════════════════════ */

.prz-raiz {
    --prz-verde:        #008572;
    --prz-verde-osc:    #00695a;
    --prz-verde-claro:  #e4f3ef;
    --prz-dorado:       #dfbb3e;
    --prz-dorado-osc:   #b8932a;
    --prz-tinta:        #13302b;
    --prz-gris:         #55706b;
    --prz-fondo:        #f4f7f6;
    --prz-abajo:        16px;
    --prz-derecha:      16px;

    position: fixed;
    right: calc(var(--prz-derecha) + env(safe-area-inset-right, 0px));
    bottom: calc(var(--prz-abajo) + env(safe-area-inset-bottom, 0px));
    z-index: 1055;                 /* por encima del botón «subir» (1050) y por debajo de los avisos (SweetAlert, 1060) */
    font-family: inherit;
    font-size: 15px;
    line-height: 1.45;
    color: var(--prz-tinta);
    transition: bottom .25s ease;
}

.prz-raiz *,
.prz-raiz *::before,
.prz-raiz *::after { box-sizing: border-box; }

.prz-raiz [hidden] { display: none !important; }

.prz-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── El muñeco (botón que abre el chat) ───────────────────────────────────── */
.prz-lanzador {
    position: relative;
    display: block;
    width: 78px;
    height: 88px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    filter: drop-shadow(0 6px 10px rgba(0, 60, 50, .25));
    transition: transform .2s ease;
}
.prz-lanzador:hover  { transform: translateY(-3px) scale(1.04); }
.prz-lanzador:active { transform: scale(.96); }
.prz-lanzador:focus-visible {
    outline: 3px solid var(--prz-dorado);
    outline-offset: 4px;
    border-radius: 18px;
}
.prz-lanzador svg { width: 100%; height: 100%; overflow: visible; }

.prz-discreto .prz-lanzador { width: 58px; height: 66px; }

.prz-abierto .prz-lanzador { transform: scale(.9); }

/* ── Globo de saludo ──────────────────────────────────────────────────────── */
.prz-globo {
    position: absolute;
    right: 82px;
    bottom: 46px;
    width: max-content;
    max-width: min(250px, calc(100vw - 120px));
    padding: 12px 34px 12px 14px;
    background: #fff;
    color: var(--prz-tinta);
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 10px 30px rgba(0, 50, 40, .18);
    font-size: 14px;
    animation: prz-aparece .35s ease both;
}
.prz-globo-texto {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.prz-globo-cerrar {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--prz-gris);
    cursor: pointer;
    font-size: 13px;
}
.prz-globo-cerrar:hover { background: var(--prz-fondo); }

/* ── La ventana ───────────────────────────────────────────────────────────── */
.prz-panel {
    position: absolute;
    right: 0;
    bottom: 96px;
    width: 372px;
    /* Nunca más alta que el hueco que queda por encima del muñeco */
    height: min(600px, calc(100vh - 120px - var(--prz-abajo)));
    height: min(600px, calc(100dvh - 120px - var(--prz-abajo)));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 45, 38, .28);
    overflow: hidden;
    animation: prz-aparece .25s ease both;
}
.prz-discreto .prz-panel { bottom: 76px; }

.prz-cabecera {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px 12px 14px;
    background: linear-gradient(135deg, var(--prz-verde) 0%, var(--prz-verde-osc) 100%);
    color: #fff;
}
.prz-cabecera-avatar {
    flex: 0 0 44px;
    width: 44px;
    height: 50px;
}
.prz-cabecera-avatar svg { width: 100%; height: 100%; overflow: visible; }
.prz-cabecera-txt { flex: 1 1 auto; min-width: 0; }
.prz-nombre {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
}
.prz-subtitulo {
    margin: 2px 0 0;
    font-size: 12.5px;
    line-height: 1.25;
    opacity: .92;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.prz-cab-btn {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}
.prz-cab-btn:hover          { background: rgba(255, 255, 255, .16); }
.prz-cab-btn:focus-visible  { outline: 2px solid var(--prz-dorado); outline-offset: 1px; }
.prz-cab-btn[aria-pressed="true"] { background: rgba(255, 255, 255, .22); }

/* ── Mensajes ─────────────────────────────────────────────────────────────── */
.prz-mensajes {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 8px;
    background: var(--prz-fondo);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prz-msj {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 16px;
    white-space: pre-line;
    overflow-wrap: anywhere;
    animation: prz-aparece .2s ease both;
}
.prz-msj-bot {
    align-self: flex-start;
    background: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 40, 30, .08);
}
.prz-msj-cliente {
    align-self: flex-end;
    background: var(--prz-verde);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.prz-msj-aviso {
    align-self: center;
    max-width: 92%;
    background: #fff7e0;
    color: #5c4a10;
    font-size: 13.5px;
    text-align: center;
}

.prz-botones {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-start;
    max-width: 100%;
}

.prz-chip {
    min-height: 36px;
    padding: 7px 12px;
    border: 1.5px solid var(--prz-verde);
    border-radius: 18px;
    background: #fff;
    color: var(--prz-verde-osc);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.prz-chip:hover,
.prz-chip:focus-visible { background: var(--prz-verde); color: #fff; outline: none; }

.prz-enlace {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 7px 13px;
    border-radius: 18px;
    background: var(--prz-dorado);
    color: #2b2208;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s ease;
}
.prz-enlace:hover,
.prz-enlace:focus-visible { background: #e9c95a; color: #2b2208; outline: 2px solid var(--prz-dorado-osc); outline-offset: 1px; }
.prz-enlace-wa   { background: #e4f3ef; color: var(--prz-verde-osc); }
.prz-enlace-wa:hover,
.prz-enlace-wa:focus-visible { background: #cfe9e2; color: var(--prz-verde-osc); }

/* Escribiendo… */
.prz-escribiendo {
    align-self: flex-start;
    display: inline-flex;
    gap: 5px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}
.prz-escribiendo span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--prz-verde);
    opacity: .4;
    animation: prz-punto 1.2s infinite ease-in-out;
}
.prz-escribiendo span:nth-child(2) { animation-delay: .15s; }
.prz-escribiendo span:nth-child(3) { animation-delay: .3s; }

/* ── Escribir ─────────────────────────────────────────────────────────────── */
.prz-form {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 10px 10px 8px;
    border-top: 1px solid #e3ece9;
    background: #fff;
}
.prz-entrada {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 42px;
    max-height: 110px;
    padding: 10px 12px;
    border: 1.5px solid #cfdcd8;
    border-radius: 14px;
    resize: none;
    font: inherit;
    font-size: 16px;               /* 16px: el iPhone no hace zoom al escribir */
    line-height: 1.35;
    color: var(--prz-tinta);
    background: #fff;
}
.prz-entrada:focus { outline: none; border-color: var(--prz-verde); box-shadow: 0 0 0 3px rgba(0, 133, 114, .15); }

.prz-btn-icono {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}
.prz-btn-icono:active { transform: scale(.94); }
.prz-btn-icono:focus-visible { outline: 3px solid var(--prz-dorado); outline-offset: 2px; }
.prz-btn-micro          { background: var(--prz-verde-claro); color: var(--prz-verde-osc); }
.prz-btn-micro:hover    { background: #cfe9e2; }
.prz-btn-micro.prz-escuchando {
    background: #c0392b;
    color: #fff;
    animation: prz-latido 1.1s infinite ease-in-out;
}
.prz-btn-enviar         { background: var(--prz-dorado); color: #2b2208; }
.prz-btn-enviar:hover   { background: #e9c95a; }
.prz-btn-enviar:disabled { opacity: .5; cursor: default; }

.prz-pie {
    margin: 0;
    padding: 0 12px 10px;
    background: #fff;
    font-size: 11.5px;
    line-height: 1.35;
    color: #5d6f6b;
}
.prz-pie a { color: var(--prz-verde-osc); text-decoration: underline; }

/* ── Animaciones del muñeco ───────────────────────────────────────────────── */
.prz-flota    { animation: prz-flota 3s ease-in-out infinite; }
.prz-sombra   { animation: prz-sombra 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.prz-parpadea { animation: prz-parpadeo 4.2s infinite; transform-box: fill-box; transform-origin: center; }
.prz-saluda   { animation: prz-saludo 1.5s ease-in-out 3; transform-box: fill-box; transform-origin: 0% 100%; }
.prz-balancea { animation: prz-balanceo 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0%; }
.prz-boca     { transform-box: fill-box; transform-origin: 50% 0%; }

/* Saluda otra vez al pasar el ratón */
.prz-lanzador:hover .prz-brazo { animation: prz-saludo 1.2s ease-in-out infinite; }

/* Pensando: flota más deprisa y la etiqueta gira */
.prz-pensando .prz-flota    { animation-duration: 1.1s; }
.prz-pensando .prz-balancea { animation: prz-giro 1s linear infinite; }

/* Hablando: mueve la boca */
.prz-habla .prz-boca { animation: prz-boca .28s ease-in-out infinite alternate; }

@keyframes prz-flota    { 0%, 100% { transform: translateY(0); }      50% { transform: translateY(-7px); } }
@keyframes prz-sombra   { 0%, 100% { transform: scaleX(1); opacity: .22; } 50% { transform: scaleX(.8); opacity: .12; } }
@keyframes prz-parpadeo { 0%, 90%, 100% { transform: scaleY(1); }    94% { transform: scaleY(.08); } }
@keyframes prz-saludo   { 0%, 100% { transform: rotate(8deg); }      50% { transform: rotate(-24deg); } }
@keyframes prz-balanceo { 0%, 100% { transform: rotate(-10deg); }    50% { transform: rotate(10deg); } }
@keyframes prz-giro     { 0% { transform: rotate(-25deg); }          50% { transform: rotate(25deg); } 100% { transform: rotate(-25deg); } }
@keyframes prz-boca     { from { transform: scaleY(.35); }           to { transform: scaleY(1.15); } }
@keyframes prz-aparece  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes prz-punto    { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
@keyframes prz-latido   { 0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .5); } 50% { box-shadow: 0 0 0 8px rgba(192, 57, 43, 0); } }

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

/* ── Móvil ────────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
    .prz-raiz { --prz-derecha: 10px; --prz-abajo: 10px; }

    .prz-lanzador             { width: 64px; height: 72px; }
    .prz-discreto .prz-lanzador { width: 52px; height: 58px; }

    .prz-globo { right: 66px; bottom: 36px; }

    /* La ventana ocupa casi toda la pantalla y el muñeco se esconde */
    .prz-panel {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        top: auto;
        width: auto;
        height: calc(100vh - 24px);
        height: calc(100dvh - 24px - env(safe-area-inset-top, 0px));
        max-height: 720px;
        border-radius: 18px;
    }
    .prz-abierto .prz-lanzador,
    .prz-abierto .prz-globo { display: none; }
}

/* El botón «subir» de algunas páginas, por encima del muñeco, y escondido
   mientras la ventana del chat está abierta (si no, se le pondría encima) */
body.prz-activo .btn-scroll-top { bottom: calc(var(--prz-subir, 16px) + 104px); }
body.prz-chat-abierto .btn-scroll-top { opacity: 0 !important; visibility: hidden !important; }
