/* Raquel — chatbot Eternamind (estilos) */
.raquel {
    --rq-bg: #06101c;
    --rq-bg-2: #0b1a2b;
    --rq-border: rgba(255, 255, 255, 0.12);
    --rq-text: #f4f7fb;
    --rq-muted: #9ca9ba;
    --rq-cyan: #73dcff;
    --rq-green: #78efb5;
    --rq-grad: linear-gradient(135deg, #8ae8ff, #8195ff);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--rq-text);
    line-height: 1.5;
}

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

.raquel button,
.raquel textarea {
    font-family: inherit;
}

.raquel-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* AVATAR (la foto tapa la inicial; si no carga, se queda la "R") */
.raquel-avatar {
    position: relative;
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    border-radius: 50%;
    overflow: hidden;
    background: var(--rq-grad);
}

.raquel-avatar-sm {
    width: 40px;
    height: 40px;
}

.raquel-initial {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #04101a;
    font-weight: 800;
    font-size: 1.15rem;
}

.raquel-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* BOTÓN FLOTANTE (por encima del botón "volver arriba") */
.raquel-launcher {
    position: fixed;
    right: 22px;
    bottom: 84px;
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 20px 7px 7px;
    color: var(--rq-text);
    text-align: left;
    background: rgba(9, 20, 34, 0.92);
    border: 1px solid var(--rq-border);
    border-radius: 999px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.raquel-launcher:hover {
    transform: translateY(-2px);
    border-color: rgba(115, 220, 255, 0.5);
}

.raquel-launcher-text strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.2;
}

.raquel-launcher-text small {
    display: block;
    color: var(--rq-muted);
    font-size: 0.75rem;
}

.raquel.is-open .raquel-launcher {
    display: none;
}

/* PANEL */
.raquel-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 130;
    width: 380px;
    max-width: calc(100vw - 28px);
    height: min(580px, calc(100vh - 44px));
    height: min(580px, calc(100dvh - 44px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(180deg, var(--rq-bg-2), var(--rq-bg));
    border: 1px solid var(--rq-border);
    border-radius: 22px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.raquel-panel[hidden] {
    display: none !important;
}

.raquel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--rq-border);
}

.raquel-title {
    flex: 1;
    min-width: 0;
}

.raquel-title strong {
    display: block;
    font-size: 1rem;
    line-height: 1.2;
}

.raquel-title small {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--rq-muted);
    font-size: 0.76rem;
}

.raquel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--rq-green);
    box-shadow: 0 0 10px rgba(120, 239, 181, 0.6);
}

.raquel-close {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: var(--rq-text);
    font-size: 1.5rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--rq-border);
    border-radius: 50%;
    cursor: pointer;
}

.raquel-close:hover {
    background: rgba(115, 220, 255, 0.12);
}

/* MENSAJES */
.raquel-log {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.raquel-msg {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.93rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.raquel-msg.is-bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 5px;
}

.raquel-msg.is-user {
    align-self: flex-end;
    color: #04101a;
    font-weight: 600;
    background: var(--rq-grad);
    border-bottom-right-radius: 5px;
}

.raquel-msg.is-error {
    align-self: flex-start;
    color: #fecaca;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-bottom-left-radius: 5px;
}

/* "ESCRIBIENDO…" */
.raquel-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 16px;
}

.raquel-typing i {
    width: 7px;
    height: 7px;
    display: block;
    border-radius: 50%;
    background: var(--rq-cyan);
    opacity: 0.4;
    animation: raquel-bounce 1.2s infinite ease-in-out;
}

.raquel-typing i:nth-child(2) { animation-delay: 0.15s; }
.raquel-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes raquel-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* FORMULARIO */
.raquel-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--rq-border);
    background: rgba(255, 255, 255, 0.025);
}

.raquel-form textarea {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    max-height: 110px;
    padding: 11px 14px;
    color: var(--rq-text);
    font-size: 16px; /* evita el zoom automático en móvil */
    line-height: 1.4;
    resize: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--rq-border);
    border-radius: 14px;
    outline: none;
}

.raquel-form textarea::placeholder {
    color: #7f8da0;
}

.raquel-form textarea:focus {
    border-color: rgba(115, 220, 255, 0.55);
}

.raquel-send {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #04101a;
    font-size: 1.2rem;
    font-weight: 800;
    background: var(--rq-grad);
    border: 0;
    border-radius: 14px;
    cursor: pointer;
}

.raquel-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.raquel-legal {
    margin: 0;
    padding: 0 16px 12px;
    color: #6f7d8d;
    font-size: 0.7rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.025);
}

.raquel button:focus-visible,
.raquel textarea:focus-visible {
    outline: 2px solid var(--rq-cyan);
    outline-offset: 2px;
}

/* MÓVIL: el chat ocupa toda la pantalla */
@media (max-width: 560px) {
    .raquel-launcher {
        right: 16px;
        bottom: 72px;
    }

    .raquel-panel {
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .raquel-header {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .raquel-legal {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .raquel-typing i,
    .raquel-launcher {
        animation: none;
        transition: none;
    }
}