/* ============================================================
   ASSISTANT.CSS — Agente del Nexo — Pixel Lab
   ============================================================ */

:root {
    --neon-cyan: #00D1FF;
    --neon-mint: #00FF94;
    --deep-obsidian: #0B0F14;
    --slate-grey: #151B23;
    --cloud-grey: #A0AEC0;
    --pure-white: #FFFFFF;
    --panel-bg: #0D1117;
    --chat-bg: #090d12;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.assistant-layout {
    display: grid;
    grid-template-columns: 310px 1fr;
    height: calc(100vh - 57px);
    overflow: hidden;
}

/* ============================================================
   PANEL IZQUIERDO
   ============================================================ */
.bot-panel {
    background: var(--panel-bg);
    border-right: 1px solid rgba(0,209,255,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Scanlines sobre toda la escena */
.bot-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 3px,
        rgba(0,0,0,0.06) 3px,
        rgba(0,0,0,0.06) 4px
    );
    pointer-events: none;
    z-index: 20;
}

/* ── ESCENA PIXEL ART ── */
.pixel-scene {
    position: relative;
    height: 240px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #060d14 0%, #0a1520 60%, #0d1d2a 100%);
    border-bottom: 2px solid rgba(0,209,255,0.12);
    overflow: hidden;
}

/* Suelo */
.scene-floor {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 38px;
    background: #0f1e2d;
    border-top: 2px solid #1a2d40;
}

/* Estrellas */
.scene-stars {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1px 1px at 12% 18%, rgba(0,209,255,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 35% 8%,  rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 60% 25%, rgba(0,255,148,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 82% 12%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 22% 45%, rgba(0,209,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 48% 55%, rgba(0,255,148,0.3) 0%, transparent 100%);
}

/* Estado de la escena */
.scene-status {
    position: absolute;
    top: 8px;
    left: 10px;
    font-size: 0.55rem;
    font-family: 'Fira Code', monospace;
    color: var(--neon-mint);
    opacity: 0.65;
    letter-spacing: 1px;
    z-index: 5;
}

.scene-status::before { content: '> '; opacity: 0.5; }

/* Computadora pixel art */
.pixel-computer {
    position: absolute;
    bottom: 38px;
    left: 20px;
    z-index: 3;
}

.pc-monitor {
    width: 64px;
    height: 48px;
    background: #001408;
    border: 3px solid #1a3a28;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 14px rgba(0,255,148,0.25), inset 0 0 8px rgba(0,0,0,0.8);
}

.pc-screen-lines {
    position: absolute;
    inset: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 1px;
}

/* Cursor parpadeante en la pantalla cuando está idle */
.pc-screen-lines::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 1px;
    width: 7px;
    height: 2px;
    background: var(--neon-mint);
    border-radius: 1px;
    box-shadow: 0 0 4px var(--neon-mint);
    animation: cursor-blink 1.1s steps(1) infinite;
}

@keyframes cursor-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.pc-screen-line {
    height: 2px;
    background: var(--neon-mint);
    border-radius: 1px;
    animation: line-blink 3.5s infinite;
}

.pc-screen-line:nth-child(1) { width: 75%; animation-delay: 0s; }
.pc-screen-line:nth-child(2) { width: 55%; animation-delay: 0.4s; }
.pc-screen-line:nth-child(3) { width: 65%; animation-delay: 0.8s; }
.pc-screen-line:nth-child(4) { width: 35%; animation-delay: 1.2s; }

@keyframes line-blink {
    0%, 80%, 100% { opacity: 0.75; }
    87% { opacity: 0.15; }
}

.pc-neck {
    width: 10px;
    height: 5px;
    background: #1a3a28;
    margin: 0 auto;
}

.pc-base {
    width: 30px;
    height: 3px;
    background: #0f2a1a;
    margin: 0 auto;
    border-radius: 1px;
}

/* Archiveros */
.pixel-files {
    position: absolute;
    bottom: 38px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 3;
}

.pixel-file {
    width: 28px;
    height: 32px;
    background: #121e30;
    border: 2px solid #1e3050;
    border-radius: 1px;
    position: relative;
    transition: all 0.3s ease;
    image-rendering: pixelated;
}

.pixel-file::before {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    background: var(--panel-bg);
    border-bottom: 2px solid #1e3050;
    border-left: 2px solid #1e3050;
}

.pixel-file::after {
    content: '';
    position: absolute;
    inset: 4px 3px;
    background: repeating-linear-gradient(
        180deg,
        rgba(0,209,255,0.15) 0px,
        rgba(0,209,255,0.15) 1px,
        transparent 1px,
        transparent 3px
    );
}

.pixel-file.active {
    background: #081828;
    border-color: var(--neon-cyan);
    animation: file-pulse 0.75s ease-in-out infinite;
}

@keyframes file-pulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(0,209,255,0.5);
        border-color: rgba(0,209,255,0.8);
    }
    50% {
        box-shadow: 0 0 20px rgba(0,209,255,0.95), 0 0 40px rgba(0,209,255,0.2);
        border-color: var(--neon-cyan);
    }
}

.pixel-file.active::after {
    background: repeating-linear-gradient(
        180deg,
        rgba(0,209,255,0.5) 0px,
        rgba(0,209,255,0.5) 1px,
        transparent 1px,
        transparent 3px
    );
}

/* ── AGENTE PIXEL ART ── */
.pixel-agent {
    position: absolute;
    bottom: 38px;
    left: 90px;
    width: 26px;
    image-rendering: pixelated;
    z-index: 4;
    transition: left 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pixel-agent.state-idle     { left: 90px; }
.pixel-agent.state-searching { left: 210px; }
.pixel-agent.state-returning { left: 90px; }

/* Partícula que viaja del agente hacia los archivos durante state-searching */
.pixel-agent.state-searching::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 26px;
    width: 4px;
    height: 4px;
    background: var(--neon-cyan);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--neon-cyan), 0 0 12px rgba(0,209,255,0.4);
    animation: particle-travel 1.6s ease-in-out infinite;
}

@keyframes particle-travel {
    0%   { transform: translateX(0);    opacity: 0; }
    15%  { opacity: 1; }
    85%  { opacity: 0.9; }
    100% { transform: translateX(55px); opacity: 0; }
}

/* Sprite del agente en CSS */
.agent-sprite {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

/* Cabeza */
.sprite-head {
    width: 22px;
    height: 18px;
    background: #d4a876;
    border: 2px solid #a07840;
    border-radius: 2px;
    position: relative;
}

/* Ojos */
.sprite-head::before,
.sprite-head::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: #1a1a2e;
    top: 5px;
    border-radius: 0;
    animation: eye-blink 5s infinite;
}

.sprite-head::before { left: 3px; }
.sprite-head::after  { right: 3px; }

@keyframes eye-blink {
    0%, 88%, 100% { height: 3px; }
    90% { height: 1px; }
}

/* Cuerpo */
.sprite-body {
    width: 24px;
    height: 16px;
    background: #1a3a6a;
    border: 2px solid #2a5a9a;
    position: relative;
    border-radius: 1px;
}

/* Pantallita del pecho */
.sprite-body::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 7px;
    background: #001428;
    border: 1px solid rgba(0,209,255,0.6);
    box-shadow: 0 0 5px rgba(0,209,255,0.3);
}

/* Piernas */
.sprite-legs {
    display: flex;
    gap: 4px;
}

.sprite-leg {
    width: 8px;
    height: 10px;
    background: #0f2040;
    border: 1px solid #1a3060;
    border-radius: 0 0 2px 2px;
}

/* Animación de caminar */
.pixel-agent.state-searching .sprite-leg:nth-child(1),
.pixel-agent.state-returning .sprite-leg:nth-child(2) {
    animation: walk-a 0.28s steps(2) infinite;
}

.pixel-agent.state-searching .sprite-leg:nth-child(2),
.pixel-agent.state-returning .sprite-leg:nth-child(1) {
    animation: walk-b 0.28s steps(2) infinite 0.14s;
}

@keyframes walk-a {
    from { transform: translateY(0); }
    to   { transform: translateY(-3px); }
}

@keyframes walk-b {
    from { transform: translateY(-3px); }
    to   { transform: translateY(0); }
}

/* Etiqueta flotante sobre el agente */
.agent-label {
    position: absolute;
    bottom: 92px;
    left: 76px;
    font-size: 0.55rem;
    font-family: 'Fira Code', monospace;
    color: rgba(255,255,255,0.75);
    background: rgba(0,0,0,0.65);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid rgba(0,209,255,0.2);
    white-space: nowrap;
    z-index: 6;
    transition: left 1.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* La etiqueta sigue al agente */
.pixel-agent.state-searching ~ .agent-label { left: 198px; }
.pixel-agent.state-idle      ~ .agent-label { left: 76px; }
.pixel-agent.state-returning ~ .agent-label { left: 76px; }

/* ── INFO DEL AGENTE ── */
.agent-info {
    padding: 1.1rem 1.4rem 0.6rem;
    flex-shrink: 0;
}

.agent-identity {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.6rem;
}

.agent-badge {
    width: 42px;
    height: 42px;
    background: rgba(0,209,255,0.05);
    border: 1px solid rgba(0,209,255,0.18);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.agent-badge-icon { font-size: 1.3rem; }

.agent-online-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    background: var(--neon-mint);
    border-radius: 50%;
    border: 2px solid var(--panel-bg);
    box-shadow: 0 0 7px rgba(0,255,148,0.6);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 7px rgba(0,255,148,0.6); }
    50%       { box-shadow: 0 0 14px rgba(0,255,148,0.2); }
}

.agent-name-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    font-family: 'Fira Code', monospace;
    line-height: 1;
}

.agent-version {
    font-size: 0.6rem;
    color: var(--neon-mint);
    font-family: 'Fira Code', monospace;
    opacity: 0.75;
}

.agent-status-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online  { background: var(--neon-mint); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: #FF6B6B; }

.status-label {
    font-size: 0.65rem;
    color: rgba(160,174,192,0.65);
    font-family: 'Fira Code', monospace;
}

.agent-tagline {
    font-size: 0.76rem;
    color: rgba(160,174,192,0.7);
    line-height: 1.55;
    font-family: 'Inter', sans-serif;
    margin-bottom: 0.8rem;
}

/* Divisor */
.panel-divider {
    height: 1px;
    background: rgba(255,255,255,0.05);
    margin: 0 1.4rem 0.8rem;
    flex-shrink: 0;
}

/* Capacidades */
.capabilities-block {
    padding: 0 1.4rem;
    margin-bottom: 0.8rem;
    flex-shrink: 0;
}

.cap-label {
    display: block;
    font-size: 0.58rem;
    font-family: 'Fira Code', monospace;
    color: var(--neon-cyan);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
    opacity: 0.65;
}

.cap-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cap-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.76rem;
    color: rgba(160,174,192,0.75);
    padding: 0.28rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    font-family: 'Inter', sans-serif;
}

.cap-list li:hover {
    background: rgba(0,209,255,0.04);
    color: #fff;
}

.cap-icon {
    font-size: 0.8rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

/* Preguntas rápidas */
.quick-questions {
    padding: 0 1.4rem;
    margin-bottom: 0.8rem;
    flex-shrink: 0;
}

.quick-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: rgba(0,209,255,0.03);
    border: 1px solid rgba(0,209,255,0.07);
    color: rgba(160,174,192,0.75);
    font-size: 0.72rem;
    font-family: 'Fira Code', monospace;
    padding: 0.45rem 0.65rem;
    border-radius: 7px;
    cursor: pointer;
    margin-bottom: 0.35rem;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.quick-btn::before {
    content: '> ';
    color: var(--neon-cyan);
    opacity: 0.45;
}

.quick-btn:hover {
    background: rgba(0,209,255,0.07);
    border-color: rgba(0,209,255,0.22);
    color: #fff;
    transform: translateX(3px);
}

/* Footer */
.panel-footer {
    margin-top: auto;
    padding: 0.875rem 1.4rem 1.1rem;
    flex-shrink: 0;
}

.clear-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: transparent;
    border: 1px solid rgba(255,107,107,0.13);
    color: rgba(255,107,107,0.45);
    font-size: 0.7rem;
    font-family: 'Fira Code', monospace;
    padding: 0.5rem 0.875rem;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
}

.clear-chat-btn:hover {
    background: rgba(255,107,107,0.05);
    border-color: rgba(255,107,107,0.35);
    color: #FF6B6B;
}

/* ============================================================
   PANEL DERECHO — CHAT
   ============================================================ */
.chat-panel {
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    overflow: hidden;
    position: relative;
}

/* Grid sutil de fondo */
.chat-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0,209,255,0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,209,255,0.012) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    z-index: 0;
}

/* Header móvil */
.chat-mobile-header {
    display: none;
    padding: 0.7rem 1rem;
    background: rgba(13,17,23,0.95);
    border-bottom: 1px solid rgba(0,209,255,0.08);
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.mob-bot-info { display: flex; align-items: center; gap: 0.55rem; }
.mob-avatar { font-size: 1.1rem; }

.mob-name {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: #fff;
    font-family: 'Fira Code', monospace;
    line-height: 1.2;
}

.mob-status {
    display: block;
    font-size: 0.62rem;
    color: var(--neon-mint);
    font-family: 'Fira Code', monospace;
}

.mob-clear {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    color: rgba(160,174,192,0.5);
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.mob-clear:hover {
    background: rgba(255,107,107,0.07);
    border-color: rgba(255,107,107,0.25);
    color: #FF6B6B;
}

/* Ventana de mensajes */
.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 1;
}

.chat-window::-webkit-scrollbar { width: 4px; }
.chat-window::-webkit-scrollbar-track { background: transparent; }
.chat-window::-webkit-scrollbar-thumb {
    background: rgba(0,209,255,0.12);
    border-radius: 4px;
}

/* ============================================================
   MENSAJES
   ============================================================ */
.message {
    display: flex;
    gap: 9px;
    max-width: 80%;
    animation: msgIn 0.22s ease-out;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(0,209,255,0.05);
    border: 1px solid rgba(0,209,255,0.13);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 2px;
    image-rendering: pixelated;
}

.msg-bubble {
    padding: 0.75rem 0.95rem;
    border-radius: 13px;
    font-size: 0.875rem;
    line-height: 1.65;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-family: 'Inter', sans-serif;
}

.msg-bubble strong { font-weight: 600; }

.msg-bubble code {
    background: rgba(0,0,0,0.4);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8em;
    color: var(--neon-cyan);
    border: 1px solid rgba(0,209,255,0.15);
}

.msg-bubble a {
    color: var(--neon-cyan);
    text-decoration: none;
    border-bottom: 1px solid rgba(0,209,255,0.3);
    transition: border-color 0.2s;
}
.msg-bubble a:hover { border-bottom-color: var(--neon-cyan); }

.ai-msg { align-self: flex-start; }

.ai-msg .msg-bubble {
    background: rgba(0,209,255,0.05);
    border: 1px solid rgba(0,209,255,0.11);
    color: #dde4ef;
    border-bottom-left-radius: 3px;
}

.user-msg {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.user-msg .msg-bubble {
    background: rgba(0,255,148,0.06);
    border: 1px solid rgba(0,255,148,0.16);
    color: #dde4ef;
    border-bottom-right-radius: 3px;
}

.welcome-msg .msg-bubble {
    background: rgba(0,209,255,0.07);
    border-color: rgba(0,209,255,0.18);
}

/* Typing dots */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 44px;
    padding: 0.6rem 0.85rem;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--neon-cyan);
    border-radius: 50%;
    opacity: 0.35;
    animation: typingBounce 1.2s infinite both;
}

.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
    0%, 100% { transform: translateY(0); opacity: 0.35; }
    50%       { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================
   INPUT
   ============================================================ */
.chat-input-area {
    padding: 0.9rem 1.6rem 1.1rem;
    background: rgba(9,13,18,0.92);
    border-top: 1px solid rgba(0,209,255,0.06);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.input-box {
    background: #0f1720;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 13px;
    padding: 0.75rem 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
    border-color: rgba(0,209,255,0.38);
    box-shadow: 0 0 0 3px rgba(0,209,255,0.05);
}

#user-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #dde4ef;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 22px;
    max-height: 130px;
    overflow-y: auto;
    padding: 0;
    display: block;
}

#user-input::placeholder {
    color: rgba(160,174,192,0.3);
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
}

.input-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.45rem;
}

.char-count {
    font-size: 0.6rem;
    color: rgba(160,174,192,0.3);
    font-family: 'Fira Code', monospace;
}

.send-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--neon-cyan), #0099bb);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0,209,255,0.2);
    padding: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0,209,255,0.4);
}

.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.send-btn svg { stroke: #0B0F14; }

.input-hint {
    font-size: 0.58rem;
    color: rgba(160,174,192,0.2);
    margin-top: 0.4rem;
    text-align: center;
    font-family: 'Fira Code', monospace;
    letter-spacing: 0.5px;
}

/* ============================================================
   RESPONSIVE — TABLET (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
    .assistant-layout { grid-template-columns: 250px 1fr; }
    .pixel-scene { height: 200px; }
    .pixel-agent.state-searching { left: 175px; }
    .pixel-agent.state-searching ~ .agent-label { left: 163px; }
    .agent-label { bottom: 92px; left: 76px; }
    .chat-window { padding: 1.1rem 1.25rem; }
    .chat-input-area { padding: 0.75rem 1.25rem 1rem; }
}

/* ============================================================
   RESPONSIVE — MÓVIL (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
    .assistant-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - 57px);
    }

    .bot-panel { display: none; }
    .chat-mobile-header { display: flex; }
    .chat-panel { height: 100%; }

    .chat-window { padding: 0.875rem 0.9rem; gap: 0.7rem; }

    .message { max-width: 90%; gap: 7px; }

    .msg-avatar { width: 25px; height: 25px; font-size: 0.78rem; border-radius: 6px; }

    .msg-bubble {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
        border-radius: 11px;
    }

    .chat-input-area { padding: 0.6rem 0.85rem 0.85rem; }
    .input-box { padding: 0.6rem 0.85rem; border-radius: 11px; }
    #user-input { font-size: 16px; }
    .input-hint { display: none; }
    .send-btn { width: 30px; height: 30px; border-radius: 7px; }
}

/* ============================================================
   ACCESIBILIDAD
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    .chat-window { scroll-behavior: auto; }
    .pixel-agent { transition: none !important; }
}

/* ============================================================
   ESCENA PIXEL ART MÓVIL
   Visible solo en móvil y tablet, dentro del chat-panel
   ============================================================ */
.pixel-scene-mobile {
    display: none; /* oculta en desktop, se activa en tablet/móvil */
    position: relative;
    height: 160px;
    background: linear-gradient(180deg, #060d14 0%, #0a1520 60%, #0d1d2a 100%);
    border-bottom: 1px solid rgba(0,209,255,0.1);
    overflow: hidden;
    flex-shrink: 0;
}

/* Scanlines */
.pixel-scene-mobile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg, transparent 0px, transparent 3px,
        rgba(0,0,0,0.06) 3px, rgba(0,0,0,0.06) 4px
    );
    pointer-events: none;
    z-index: 10;
}

.pixel-scene-mobile .scene-stars {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1px 1px at 12% 18%, rgba(0,209,255,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 35% 8%,  rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 60% 25%, rgba(0,255,148,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 82% 12%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 48% 50%, rgba(0,255,148,0.3) 0%, transparent 100%);
}

.pixel-scene-mobile .scene-floor {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: #0f1e2d;
    border-top: 2px solid #1a2d40;
}

.scene-status-mob {
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 0.52rem;
    font-family: 'Fira Code', monospace;
    color: var(--neon-mint, #00FF94);
    opacity: 0.65;
    letter-spacing: 1px;
    z-index: 5;
}

.scene-status-mob::before { content: '> '; opacity: 0.5; }

/* En la escena móvil el agente viaja menos distancia */
.pixel-scene-mobile .pixel-agent { bottom: 28px; }
.pixel-scene-mobile .pixel-agent.state-idle      { left: 70px; }
.pixel-scene-mobile .pixel-agent.state-searching { left: 78vw; }
.pixel-scene-mobile .pixel-agent.state-returning { left: 70px; }

.pixel-scene-mobile .agent-label {
    bottom: 76px;
    left: 56px;
    transition: left 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pixel-scene-mobile .pixel-agent.state-searching ~ .agent-label { left: calc(78vw - 12px); }
.pixel-scene-mobile .pixel-agent.state-idle      ~ .agent-label { left: 56px; }
.pixel-scene-mobile .pixel-agent.state-returning ~ .agent-label { left: 56px; }

/* Archivos más a la derecha en móvil */
.pixel-scene-mobile .pixel-files {
    right: 12px;
    bottom: 28px;
}

/* Computadora */
.pixel-scene-mobile .pixel-computer { bottom: 28px; left: 14px; }

/* ── MOSTRAR EN TABLET Y MÓVIL ── */
@media (max-width: 900px) {
    .pixel-scene-mobile {
        display: block;
    }
}

/* ============================================================
   INPUT BLOQUEADO MIENTRAS EL AGENTE RESPONDE
   ============================================================ */
.input-locked {
    opacity: 0.55;
    border-color: rgba(0, 209, 255, 0.06) !important;
    box-shadow: none !important;
    cursor: not-allowed;
}

.input-locked #user-input {
    cursor: not-allowed;
}

.input-locked #user-input::placeholder {
    color: rgba(0, 209, 255, 0.4);
    font-style: italic;
}

/* Animación sutil en el borde mientras espera */
.input-locked {
    animation: waiting-pulse 2s ease-in-out infinite;
}

@keyframes waiting-pulse {
    0%, 100% { border-color: rgba(0, 209, 255, 0.06); }
    50%       { border-color: rgba(0, 209, 255, 0.18); }
}

/* readOnly en lugar de disabled — más compatible */
#user-input[readonly] {
    cursor: default;
    color: rgba(221, 228, 239, 0.5);
}