/* Cubi, the floating help assistant of cumbrix.com (public/js/cubi.js). Same design as CodeRoot's
   Codi, in Cumbrix colors. It sits right above the WhatsApp button when that one is shown. */
.cubi {
    --cubi-principal: #0071e3;
    --cubi-principal-2: #5e5ce6;
    --cubi-fondo: #ffffff;
    --cubi-texto: #1d1d1f;
    --cubi-suave: #f5f5f7;
    --cubi-borde: #e5e5ea;
    --cubi-chip: #eaf3ff;
    --cubi-chip-texto: #0058b0;
    --cubi-tam: 62px;
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 75;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-size: 14px;
    line-height: 1.45;
    font-family: inherit;
}
body:has(.wa-float) .cubi { bottom: calc(90px + env(safe-area-inset-bottom)); }

.cubi-cara { display: block; width: 100%; height: 100%; object-fit: contain; }

.cubi-boton {
    position: relative;
    width: var(--cubi-tam);
    height: var(--cubi-tam);
    padding: 7px 8px 9px 6px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    background: #fff;
    box-shadow: 0 0 0 3px var(--cubi-principal), 0 12px 26px -6px rgba(0, 113, 227, .55);
    transition: transform .15s ease, box-shadow .15s ease;
    animation: cubi-flotar 3.2s ease-in-out infinite;
}
.cubi-boton:hover { transform: translateY(-2px) scale(1.05); }
.cubi-boton:active { transform: scale(.96); }
.cubi-boton--saluda { animation: cubi-saludo .9s ease-in-out 2, cubi-flotar 3.2s ease-in-out 1.8s infinite; }
.cubi--abierto .cubi-boton { animation: none; }

.cubi-punto { display: none; }
.cubi--nuevo .cubi-punto {
    display: block;
    position: absolute;
    top: 1px;
    right: 1px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ff375f;
    border: 2px solid #fff;
    animation: cubi-latido 1.6s ease-in-out infinite;
}

/* Greeting: Cubi peeks out from the bottom-left of a big bubble. */
.cubi-saludo { display: flex; align-items: flex-end; max-width: calc(100vw - 32px); cursor: pointer; animation: cubi-aparecer .3s ease-out; }
.cubi-saludo[hidden] { display: none; }
.cubi-mascota {
    flex: none;
    width: 70px;
    height: 70px;
    padding: 8px 9px 10px 7px;
    position: relative;
    z-index: 1;
    margin-right: -16px;
    margin-bottom: -4px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--cubi-principal);
    box-shadow: 0 10px 22px rgba(0, 113, 227, .3);
}
.cubi-globo {
    max-width: 230px;
    padding: 14px 18px 14px 26px;
    border-radius: 20px 20px 20px 6px;
    background: var(--cubi-fondo);
    color: var(--cubi-texto);
    border: 1px solid var(--cubi-borde);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .16);
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}
.cubi-globo-hola { font-size: 19px; font-weight: 800; color: var(--cubi-principal); }
.cubi-globo-nombre { font-size: 27px; font-weight: 800; color: var(--cubi-principal-2); }

.cubi-panel {
    width: 370px;
    max-width: calc(100vw - 28px);
    height: 540px;
    max-height: calc(100vh - var(--cubi-tam) - 130px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px;
    background: var(--cubi-fondo);
    color: var(--cubi-texto);
    border: 1px solid var(--cubi-borde);
    box-shadow: 0 24px 50px rgba(0, 0, 0, .22);
    animation: cubi-aparecer .2s ease-out;
}
.cubi-panel[hidden] { display: none; }

.cubi-cabecera { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: #fff; background: linear-gradient(135deg, var(--cubi-principal), var(--cubi-principal-2)); }
.cubi-avatar { flex: none; width: 42px; height: 42px; padding: 5px 6px 6px 4px; border-radius: 50%; background: #fff; }
.cubi-hablando { animation: cubi-hablar .5s ease-in-out infinite alternate; }
.cubi-titulos { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.cubi-titulos strong { font-size: 16px; }
.cubi-titulos span { font-size: 12px; opacity: .88; }
.cubi-cerrar { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.cubi-cerrar:hover { background: rgba(255, 255, 255, .2); }

.cubi-mensajes { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--cubi-suave); }
.cubi-burbuja { max-width: 85%; padding: 9px 12px; border-radius: 16px; overflow-wrap: anywhere; animation: cubi-aparecer .25s ease-out; }
.cubi-burbuja--cubi { align-self: flex-start; background: var(--cubi-fondo); border: 1px solid var(--cubi-borde); border-bottom-left-radius: 4px; }
.cubi-burbuja--usuario { align-self: flex-end; color: #fff; background: var(--cubi-principal); border-bottom-right-radius: 4px; }
.cubi-burbuja a { color: var(--cubi-principal); text-decoration: underline; font-weight: 600; }
.cubi-burbuja code { font-size: 12px; padding: 1px 4px; border-radius: 4px; background: var(--cubi-suave); }

.cubi-chips, .cubi-acciones { display: flex; flex-wrap: wrap; gap: 6px; animation: cubi-aparecer .25s ease-out; }
.cubi-chip { padding: 6px 11px; border-radius: 999px; border: 1px solid transparent; background: var(--cubi-chip); color: var(--cubi-chip-texto); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.cubi-chip:hover { border-color: var(--cubi-principal); }
.cubi-accion { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--cubi-borde); background: var(--cubi-fondo); color: var(--cubi-texto); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.cubi-accion--principal { border-color: transparent; color: #fff; background: var(--cubi-principal); }

.cubi-temas { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.cubi-temas li::before { content: '🔗 '; }
.cubi-temas span { display: block; padding-left: 22px; font-size: 12px; opacity: .7; }

.cubi-valorar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12px; opacity: .85; animation: cubi-aparecer .25s ease-out; }
.cubi-valorar button { padding: 2px 8px; border-radius: 999px; border: 1px solid var(--cubi-borde); background: var(--cubi-fondo); font-size: 14px; cursor: pointer; }
.cubi-valorar button:hover { border-color: var(--cubi-principal); }
.cubi-valorar a { color: var(--cubi-principal); font-weight: 600; text-decoration: underline; }

.cubi-puntos { display: inline-flex; gap: 4px; padding: 3px 0; }
.cubi-puntos i { width: 7px; height: 7px; border-radius: 50%; background: #8e8e93; animation: cubi-punto 1s ease-in-out infinite; }
.cubi-puntos i:nth-child(2) { animation-delay: .15s; }
.cubi-puntos i:nth-child(3) { animation-delay: .3s; }

.cubi-formulario { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--cubi-borde); background: var(--cubi-fondo); }
.cubi-texto { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 999px; border: 1px solid var(--cubi-borde); background: var(--cubi-suave); color: var(--cubi-texto); font: inherit; font-size: 14px; outline: none; }
.cubi-texto:focus { border-color: var(--cubi-principal); box-shadow: 0 0 0 3px rgba(0, 113, 227, .15); }
.cubi-enviar { padding: 9px 16px; border: 0; border-radius: 999px; color: #fff; background: var(--cubi-principal); font: inherit; font-weight: 600; cursor: pointer; }
.cubi-oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes cubi-flotar { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes cubi-saludo { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }
@keyframes cubi-aparecer { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes cubi-hablar { from { transform: scale(1); } to { transform: scale(1.1); } }
@keyframes cubi-punto { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes cubi-latido { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }

@media (max-width: 640px) {
    .cubi { --cubi-tam: 56px; right: 14px; }
    body:has(.wa-float) .cubi { bottom: calc(86px + env(safe-area-inset-bottom)); }
    /* On phones the open chat fills the visible screen and follows the keyboard (--cubi-vv-*). */
    .cubi-panel {
        position: fixed;
        left: 8px;
        right: 8px;
        top: calc(var(--cubi-vv-top, 0px) + max(8px, env(safe-area-inset-top)));
        width: auto;
        max-width: none;
        height: calc(var(--cubi-vv-alto, 100dvh) - max(8px, env(safe-area-inset-top)) - 8px);
        max-height: none;
        z-index: 80;
    }
    .cubi--abierto .cubi-boton { display: none; }
    html.cubi-bloqueo, html.cubi-bloqueo body { overflow: hidden; overscroll-behavior: none; }
}
@media (pointer: coarse) { .cubi-texto { font-size: 16px; } }
@media (prefers-reduced-motion: reduce) { .cubi *, .cubi { animation: none !important; transition: none !important; } }
@media print { .cubi { display: none !important; } }
