/* ============================================================================
   Robi, el asistente de la esquina
   ----------------------------------------------------------------------------
   Un botón redondo abajo a la derecha y, al abrirlo, una ventana de charla:
   cabecera con la mascota, los mensajes, las preguntas frecuentes como fichas
   y un campo para escribir. En el teléfono la ventana ocupa la pantalla.
   Colores y radios de cm-base.css.
   ============================================================================ */

.cm-robi {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1040;
    font-family: inherit;
}

/* ------------------------------------------------------------- el botón */

/* Disimulado en reposo —se nota que está, no tapa lo de debajo— y entero al
   pasar el ratón o al tocarlo (Nelson, 17 de septiembre de 2026). */
.cm-robi__button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 6px;
    border: 1px solid var(--cm-rule);
    border-radius: 999px;
    background: var(--cm-white);
    color: var(--cm-ink);
    box-shadow: var(--cm-shadow-high);
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    opacity: .72;
    transition: transform .15s ease, box-shadow .15s ease, opacity .2s ease;
}

.cm-robi__button:hover,
.cm-robi__button:focus-visible,
.cm-robi:has(.cm-robi__nudge) .cm-robi__button {
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(39, 43, 65, .18);
    outline: none;
}

.cm-robi__button:focus-visible { box-shadow: 0 0 0 3px rgba(32, 192, 243, .35), var(--cm-shadow-high); }

.cm-robi__face {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex: none;
    display: block;
}

.cm-robi__face img,
.cm-robi__face svg {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.cm-robi--open .cm-robi__button { display: none; }

/* El empujoncito: una burbuja junto al botón, que entra deslizándose y se va sola. */
.cm-robi__nudge {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: 260px;
    max-width: calc(100vw - 36px);
    padding: 10px 14px;
    border: 1px solid var(--cm-rule);
    border-radius: 14px 14px 4px 14px;
    background: var(--cm-white);
    color: var(--cm-ink);
    box-shadow: var(--cm-shadow-high);
    font-size: .88rem;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s ease, transform .25s ease;
}

.cm-robi__nudge--visible { opacity: 1; transform: none; }

.cm-robi__nudge:hover { border-color: var(--cm-cyan); }

/* ------------------------------------------------------------ la ventana */

.cm-robi__dashboard {
    width: min(380px, calc(100vw - 36px));
    height: min(560px, calc(100vh - 36px));
    display: flex;
    flex-direction: column;
    border: 1px solid var(--cm-rule);
    border-radius: var(--cm-radius-lg);
    background: var(--cm-white);
    box-shadow: 0 18px 50px rgba(39, 43, 65, .22);
    overflow: hidden;
}

.cm-robi__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #15558d, #0f9fce);
    color: #fff;
}

.cm-robi__face--header {
    width: 44px;
    height: 44px;
    border: 2px solid rgba(255, 255, 255, .6);
}

.cm-robi__who {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.cm-robi__who strong { font-size: 1.02rem; }

.cm-robi__who span { font-size: .8rem; opacity: .85; }

.cm-robi__close {
    margin-left: auto;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    cursor: pointer;
}

.cm-robi__close:hover { background: rgba(255, 255, 255, .28); }

/* ---------------------------------------------------------- la charla */

.cm-robi__chat {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--cm-bg);
    overscroll-behavior: contain;
}

.cm-robi__message { display: flex; }

.cm-robi__message--me { justify-content: flex-end; }

.cm-robi__bubble {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.45;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.cm-robi__message--robi .cm-robi__bubble {
    background: var(--cm-white);
    color: var(--cm-ink);
    border: 1px solid var(--cm-rule);
    border-bottom-left-radius: 4px;
}

.cm-robi__message--me .cm-robi__bubble {
    background: #147fbd;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* «Está escribiendo»: tres puntos que laten. */
.cm-robi__points {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    min-height: 38px;
}

.cm-robi__points span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cm-gray-light);
    animation: cm-robi-late 1.2s infinite ease-in-out;
}

.cm-robi__points span:nth-child(2) { animation-delay: .15s; }
.cm-robi__points span:nth-child(3) { animation-delay: .3s; }

@keyframes cm-robi-late {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .cm-robi__points span { animation: none; opacity: .7; }
    .cm-robi__nudge { transition: none; }
}

.cm-robi__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.cm-robi__action {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--cm-cyan-dark);
    color: var(--cm-cyan-dark);
    background: var(--cm-white);
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: normal;
}

.cm-robi__action:hover { background: var(--cm-cyan-soft); color: var(--cm-cyan-dark); }

.cm-robi__action--main {
    background: var(--cm-cyan-dark);
    color: #fff;
}

.cm-robi__action--main:hover { background: #0c86ae; color: #fff; }

/* ------------------------------------------------- las preguntas rápidas */

/* Con tope de alto y su propio desplazamiento: diez fichas se comían la
   ventana entera y la charla quedaba en dos líneas. */
.cm-robi__records {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 118px;
    overflow-y: auto;
    flex: none;
    padding: 8px 14px 10px;
    background: var(--cm-bg);
    border-top: 1px solid var(--cm-rule);
    overscroll-behavior: contain;
}

/* Después de la primera pregunta las fichas se recogen a una fila; con el
   desplazamiento siguen todas ahí. */
.cm-robi--chatting .cm-robi__records { max-height: 46px; }

.cm-robi__records:empty { display: none; }

.cm-robi__record {
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid #cfd7e3;
    background: var(--cm-white);
    color: var(--cm-ink);
    font-size: .8rem;
    cursor: pointer;
    text-align: left;
}

.cm-robi__record:hover { border-color: var(--cm-cyan); background: var(--cm-cyan-soft); }

.cm-robi__record--person { border-style: dashed; color: var(--cm-gray); }

/* ------------------------------------------------------------- escribir */

.cm-robi__footer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--cm-rule);
    background: var(--cm-white);
}

.cm-robi__entry {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #cfd7e3;
    border-radius: 999px;
    font-size: 16px; /* por debajo, Safari hace zoom al enfocar */
}

.cm-robi__entry:focus {
    outline: none;
    border-color: var(--cm-cyan);
    box-shadow: 0 0 0 3px rgba(32, 192, 243, .18);
}

.cm-robi__send {
    width: 40px;
    height: 40px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: var(--cm-cyan-dark);
    color: #fff;
    cursor: pointer;
}

.cm-robi__send:hover { background: #0c86ae; }

/* ------------------------------------------------------------- teléfono */

@media (max-width: 575.98px) {
    .cm-robi { right: 12px; bottom: 12px; }

    .cm-robi__button-text { display: none; }

    .cm-robi__button { padding: 6px; }

    .cm-robi--open {
        inset: 0;
        right: 0;
        bottom: 0;
    }

    .cm-robi__dashboard {
        width: 100vw;
        height: 100%;
        border-radius: 0;
        border: 0;
    }
}

@media print {
    .cm-robi { display: none; }
}
