/* ==========================================================
   CHAT ARISA — IA local del Núcleo (abierto a todos desde el 14 nov 2026)
   Usa el sistema de diseño público (base.css :root)
   ========================================================== */

.arisa-chat {
    --ac-radius: 18px;
    position: fixed;
    right: clamp(14px, 3vw, 28px);
    bottom: clamp(14px, 3vw, 28px);
    z-index: 1200;
    font-family: 'Rajdhani', sans-serif;
}

/* ---------- Botón flotante (FAB) ---------- */
.arisa-chat__fab {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: 2px solid var(--neon-green);
    background: var(--dark-card);
    padding: 0;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 0 18px var(--neon-green-dim), 0 8px 24px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: visible;
}
.arisa-chat__fab:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 0 28px var(--neon-green-glow), 0 10px 28px rgba(0, 0, 0, 0.55);
}
.arisa-chat__fab img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
}
/* Anillo pulsante */
.arisa-chat__fab::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--neon-green);
    opacity: 0.7;
    animation: arisaPulse 2.4s ease-out infinite;
    pointer-events: none;
}
@keyframes arisaPulse {
    0%   { transform: scale(1);    opacity: 0.6; }
    70%  { transform: scale(1.45); opacity: 0;   }
    100% { transform: scale(1.45); opacity: 0;   }
}
/* Punto de estado "en línea" */
.arisa-chat__status-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--neon-green);
    border: 2px solid var(--dark-card);
    box-shadow: 0 0 8px var(--neon-green-glow);
}
/* Globo "Habla con Arisa" al pasar el ratón */
.arisa-chat__hint {
    position: absolute;
    right: 74px;
    bottom: 14px;
    white-space: nowrap;
    background: var(--dark-elevated);
    color: var(--text-primary);
    border: 1px solid var(--cyber-purple);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    opacity: 0;
    transform: translateX(8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.arisa-chat__fab:hover + .arisa-chat__hint {
    opacity: 1;
    transform: translateX(0);
}

/* ---------- Ventana de chat ---------- */
.arisa-chat__panel {
    position: absolute;
    right: 0;
    bottom: 78px;
    width: min(370px, calc(100vw - 28px));
    height: min(560px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    background: var(--dark-surface);
    border: 1px solid var(--dark-border);
    border-radius: var(--ac-radius);
    box-shadow: 0 0 0 1px rgba(157, 78, 221, 0.25),
                0 18px 50px rgba(0, 0, 0, 0.65),
                0 0 40px rgba(157, 78, 221, 0.15);
    overflow: hidden;
    transform-origin: bottom right;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}
.arisa-chat.is-open .arisa-chat__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.arisa-chat.is-open .arisa-chat__hint { display: none; }

/* Cabecera */
.arisa-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(157, 78, 221, 0.18), rgba(57, 255, 20, 0.08));
    border-bottom: 1px solid var(--dark-border);
}
.arisa-chat__header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--neon-green);
    flex-shrink: 0;
}
.arisa-chat__header-info { flex: 1; min-width: 0; line-height: 1.2; }
.arisa-chat__header-name {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text-primary);
    letter-spacing: 1px;
}
.arisa-chat__header-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    color: var(--neon-green);
    font-family: 'Share Tech Mono', monospace;
    margin-top: 2px;
}
.arisa-chat__header-sub::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--neon-green);
    box-shadow: 0 0 6px var(--neon-green-glow);
    animation: arisaBlink 1.8s ease-in-out infinite;
}
@keyframes arisaBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.arisa-chat__close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
}
.arisa-chat__close:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.06); }

.arisa-chat__wipe {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    margin-right: 2px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    transition: color 0.2s ease, background 0.2s ease;
}
.arisa-chat__wipe svg { width: 17px; height: 17px; }
.arisa-chat__wipe:hover { color: var(--cyber-pink); background: rgba(255, 0, 255, 0.08); }

/* Zona de mensajes */
.arisa-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--cyber-purple) transparent;
}
.arisa-chat__messages::-webkit-scrollbar { width: 7px; }
.arisa-chat__messages::-webkit-scrollbar-thumb {
    background: var(--cyber-purple-dim);
    border-radius: 4px;
}

.arisa-msg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: arisaMsgIn 0.25s ease;
}
@keyframes arisaMsgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.arisa-msg--bot {
    align-self: flex-start;
    background: var(--dark-card);
    border: 1px solid var(--dark-border);
    border-left: 3px solid var(--neon-green);
    border-bottom-left-radius: 4px;
}
.arisa-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(157, 78, 221, 0.28), rgba(157, 78, 221, 0.14));
    border: 1px solid var(--cyber-purple);
    border-bottom-right-radius: 4px;
}

/* Indicador "escribiendo" */
.arisa-typing { align-self: flex-start; display: flex; gap: 5px; padding: 12px 14px; }
.arisa-typing span {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--neon-green);
    opacity: 0.4;
    animation: arisaTyping 1.2s infinite;
}
.arisa-typing span:nth-child(2) { animation-delay: 0.2s; }
.arisa-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes arisaTyping { 0%,60%,100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* Barra de entrada */
.arisa-chat__input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--dark-border);
    background: var(--dark-card);
}
.arisa-chat__textarea {
    flex: 1;
    resize: none;
    max-height: 110px;
    min-height: 24px;
    background: var(--dark-bg);
    border: 1px solid var(--dark-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    padding: 9px 12px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.arisa-chat__textarea:focus {
    border-color: var(--neon-green);
    box-shadow: 0 0 0 2px var(--neon-green-dim);
}
.arisa-chat__textarea::placeholder { color: var(--text-muted); }
.arisa-chat__send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: var(--neon-green);
    color: #05050a;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.arisa-chat__send:hover:not(:disabled) { box-shadow: 0 0 16px var(--neon-green-glow); transform: scale(1.05); }
.arisa-chat__send:disabled { opacity: 0.45; cursor: not-allowed; }
.arisa-chat__send svg { width: 20px; height: 20px; }

.arisa-chat__footer-note {
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: 'Share Tech Mono', monospace;
    padding: 0 12px 8px;
    background: var(--dark-card);
}

/* Móvil: ocupa casi toda la pantalla */
@media (max-width: 480px) {
    .arisa-chat__panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 74px;
    }
}

/* Enlaces a páginas de Arkaia dentro de las respuestas (14 nov 2026) */
.arisa-msg__link {
    color: var(--neon-green);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
.arisa-chat__footer-note {
    line-height: 1.35;
}
.arisa-chat__footer-note a {
    color: var(--text-secondary);
    text-decoration: underline;
}
