/* ======================================================
   ARCHIVO CSS UNIFICADO Y MEJORADO PARA NEUROMAR AI
   ====================================================== */

:root {
    /* --- Variables Originales (Mantenidas) --- */
    --yellow-glow: #FFD700;
    --black-bg: #000000;
    --dark-card: #0c0c0c;
    --text-light: #EAEAEA;
    --text-dark: #0a0a0a;
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
    --border-color: rgba(255, 215, 0, 0.2);

    /* --- MEJORA: Variable para el efecto de vidrio --- */
    --color-surface-glass: rgba(20, 20, 22, 0.6);
}

/* --- Estilos Generales y de Cuerpo --- */
body {
    font-family: var(--font-body), sans-serif;
    background-color: var(--black-bg);
    color: var(--text-light);
    overflow: hidden;
    /* --- MEJORA: Renderizado de fuentes más suave --- */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Estilos de Fondo Animado (Mantenidos) --- */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle at center, rgba(255, 215, 0, 0.1), transparent 70%),
                url('https://www.transparenttextures.com/patterns/circuit-pattern.png');
    background-blend-mode: overlay;
    z-index: -2;
    animation: pulse-bg 6s ease-in-out infinite;
    opacity: 0.25;
}

body::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: url("https://media0.giphy.com/media/v1.Y2lkPTc5MGI3NjExYmU1bWNrbzllYTZpY3pzZzZ3ZzI1dTljYTVrbnlncjJ3ZHQxMnFqZCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/HmNw5GoyPtaZa/giphy.gif") center/cover no-repeat;
    mix-blend-mode: screen;
    opacity: 0.2;
    z-index: -1;
    animation: flicker-bg 10s infinite alternate ease-in-out;
}

/* --- Estructura Principal --- */
.main-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    grid-template-rows: 100vh;
    height: 100vh;
    gap: 1rem;
}

/* --- MEJORA: Clase de utilidad para efecto Vidrio Esmerilado --- */
.glass-effect {
    background-color: var(--color-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
}

.sidebar {
    /* La funcionalidad de .glass-effect reemplaza el fondo y borde anteriores */
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: transform 0.3s ease-in-out;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem 2rem 1.5rem 1rem;
}

.chat-header .title {
    font-family: var(--font-display);
    font-weight: 900;
    text-shadow: 0 0 10px var(--yellow-glow), 0 0 20px rgba(255, 215, 0, 0.5);
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

/* --- Componentes de la Interfaz --- */

/* Historial */
.history-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}
.history-item:hover { background-color: rgba(255, 215, 0, 0.1); }
.history-item.active { background-color: var(--yellow-glow); color: var(--text-dark); font-weight: 600; border-color: var(--yellow-glow); }
#history-search { background-color: rgba(0,0,0,0.3); border: 1px solid var(--border-color); padding: 0.5rem 1rem; border-radius: 0.5rem; margin-bottom: 1rem; }

/* Mensajes del Chat */
.message { max-width: 85%; margin-bottom: 1.5rem; display: flex; align-items: flex-start; gap: 1rem; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.ai { align-self: flex-start; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; border: 2px solid var(--border-color); }
.avatar.user { background-color: rgba(255, 255, 255, 0.1); }
.avatar.ai { background-color: rgba(255, 215, 0, 0.2); color: var(--yellow-glow); }
.message-content { background: rgba(24, 24, 24, 0.5); padding: 1rem 1.5rem; border-radius: 1rem; border: 1px solid var(--border-color); box-shadow: 0 4px 20px rgba(0,0,0,0.3); position: relative; width: 100%; }
.message.user .message-content { background: rgba(255, 215, 0, 0.1); border-color: rgba(255, 215, 0, 0.4); }

/* MEJORA: Clase para animar la aparición de nuevos mensajes */
.animate-fadeInUp {
    animation: fadeInUp 0.5s ease-out forwards;
}

/* Estilos de Contenido (Prose) */
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--yellow-glow); font-family: var(--font-display); margin: 1.5rem 0 0.5rem 0; }
.prose strong { color: var(--yellow-glow); }
.prose ul, .prose ol { margin: 1rem 0; padding-left: 1.5rem; }
.prose p { margin-bottom: 1rem; line-height: 1.7; }
.prose blockquote { border-left: 3px solid var(--yellow-glow); padding-left: 1rem; margin: 1rem 0; font-style: italic; background-color: rgba(255, 215, 0, 0.05); }
.prose pre { background-color: rgba(0,0,0,0.4); padding: 1rem; border-radius: 0.5rem; overflow-x: auto; position: relative; }

/* Área de Input y Botones */
.prompt-wrapper { position: relative; }
.input-area { background-color: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 215, 0, 0.4); transition: all 0.3s ease; resize: none; padding-right: 80px; }
.input-area:focus { outline: none; box-shadow: 0 0 15px rgba(255, 215, 0, 0.5); border-color: rgba(255, 215, 0, 0.8); }
textarea[readonly] { background-color: rgba(20, 20, 20, 0.5); cursor: default; opacity: 0.7; }
.input-actions { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 0.5rem; }

.input-btn {
    background-color: rgba(255, 215, 0, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--yellow-glow);
    font-size: 1.3rem;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    cursor: pointer;
}
.input-btn:hover { background-color: rgba(255, 215, 0, 0.3); box-shadow: 0 0 20px rgba(255, 215, 0, 0.6); transform: scale(1.15); }
.input-btn.is-listening { background-color: rgba(239, 68, 68, 0.2); color: #ef4444; animation: pulse-mic 1.2s infinite; box-shadow: 0 0 15px rgba(239, 68, 68, 0.5); }
.input-btn.send { background-color: rgba(255, 215, 0, 0.15); color: var(--yellow-glow); }
.input-btn.send:hover { background-color: rgba(255, 215, 0, 0.25); box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }

/* Otros Componentes */
.control-btn { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-light); padding: 0.5rem 0.75rem; border-radius: 0.5rem; font-size: 0.8rem; transition: all 0.2s ease-in-out; cursor: pointer; }
.control-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.download-btn { background-color: var(--yellow-glow); color: var(--text-dark); font-weight: 600; border-color: var(--yellow-glow); box-shadow: 0 0 15px rgba(255, 215, 0, 0.3); }
.download-btn:hover { background-color: #ffed4a; box-shadow: 0 0 25px rgba(255, 215, 0, 0.5); }
.message-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity 0.2s ease-in-out; z-index: 5; }
.message:hover .message-actions { opacity: 1; }
.action-btn { background-color: rgba(255, 255, 255, 0.1); border-radius: 5px; padding: 4px 6px; font-size: 0.75rem; color: var(--text-light); }
.action-btn:hover { background-color: rgba(255, 215, 0, 0.2); }
#stop-generation-button { background-color: #991b1b; color: white; padding: 0.5rem 1rem; border-radius: 0.5rem; }

/* --- MEJORA: Estilo para el botón de Texto a Voz --- */
.tts-btn.is-speaking i {
    color: #ef4444; /* Rojo para indicar que está hablando */
    animation: pulse-mic 1.2s infinite; /* Reutiliza la animación del micrófono */
}

#welcome-screen { text-align: center; padding: 4rem 1rem; }
.welcome-logo { font-size: 5rem; color: var(--yellow-glow); text-shadow: 0 0 20px var(--yellow-glow); margin-bottom: 1rem; }
.suggestion-card { background: rgba(24, 24, 24, 0.5); border: 1px solid var(--border-color); padding: 1rem; border-radius: 1rem; cursor: pointer; transition: all 0.2s ease; text-align: left; }
.suggestion-card:hover { transform: translateY(-5px); border-color: var(--yellow-glow); }

#language-selector { background-color: rgba(0,0,0,0.3); border: 1px solid var(--border-color); padding: 0.5rem; border-radius: 0.5rem; width: 100%; -webkit-appearance: none; appearance: none; background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFD700%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22/%3E%3C/svg%3E'); background-repeat: no-repeat; background-position: right .7rem top 50%; background-size: .65rem auto; }

/* Notificaciones Toast */
.copy-code-btn { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,0.1); border: none; color: white; padding: 4px 8px; border-radius: 4px; cursor: pointer; opacity: 0; transition: opacity 0.3s; font-size: 0.8rem; }
.prose pre:hover .copy-code-btn { opacity: 1; }
.copy-code-btn:hover { background: rgba(255,215,0,0.3); }
#toast-notification { position: fixed; bottom: 20px; left: 50%; background-color: var(--yellow-glow); color: var(--text-dark); padding: 12px 24px; border-radius: 8px; z-index: 1000; font-weight: 600; box-shadow: 0 5px 20px rgba(255, 215, 0, 0.3); transition: opacity 0.5s, transform 0.5s; opacity: 0; transform: translate(-50%, 20px); pointer-events: none; }
#toast-notification.show { opacity: 1; transform: translate(-50%, 0); }


/* --- MEJORA: Scrollbars personalizados y temáticos --- */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: var(--yellow-glow);
    border-radius: 20px;
    border: 2px solid var(--black-bg);
    opacity: 0.6;
}
::-webkit-scrollbar-thumb:hover {
    opacity: 0.9;
}


/* --- Media Queries (Responsividad) --- */
@media (max-width: 1024px) {
    .chat-container { padding: 1rem 1.5rem 1.5rem 1rem; }
}

@media (max-width: 768px) {
    .main-grid { grid-template-columns: 1fr; }
    .sidebar { 
        position: fixed; 
        top: 0; 
        left: 0; 
        bottom: 0; 
        transform: translateX(-100%); 
        z-index: 30; 
        width: min(300px, 80vw); 
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
        transition: transform 0.3s ease; 
    }
    .sidebar.open { transform: translateX(0); }
    .chat-container { 
        padding: 1rem; 
        height: 100vh; /* Asegura altura completa */
        overflow: hidden; /* Evita scroll innecesario */
    }
    .message { 
        max-width: calc(100% - 1rem); 
        word-wrap: break-word; 
    }
    .menu-toggle { display: block; }
}

@media (max-width: 480px) {
    .chat-header .title { 
        font-size: clamp(1.25rem, 4vw, 1.5rem); 
        line-height: 1.2;
    }
    .message { 
        max-width: calc(100vw - 2rem); 
        margin: 0.5rem auto;
    }
    .message-content { 
        padding: 0.75rem 1rem;
        font-size: clamp(0.875rem, 3.5vw, 1rem); 
        line-height: 1.4;
        word-break: break-word;
    }
    .avatar { 
        width: clamp(28px, 8vw, 32px); 
        height: clamp(28px, 8vw, 32px); 
        font-size: clamp(1rem, 3vw, 1.2rem);
        flex-shrink: 0; 
    }
    .input-area { 
        padding-right: min(90px, 20vw); /* Aumentado para mejor separación */
        padding: 0.75rem;
        min-height: 60px;
        font-size: 16px; /* Evita zoom automático en iOS */
    }
    .input-actions { 
        gap: 0.25rem;
        flex-shrink: 0;
        right: 8px; /* Mejor posicionamiento */
        bottom: 8px;
    }
    .input-btn { 
        width: clamp(36px, 10vw, 44px); /* Tamaño adaptativo */
        height: clamp(36px, 10vw, 44px);
        font-size: clamp(1rem, 3.5vw, 1.25rem);
    }
    .control-btn { 
        padding: 0.4rem 0.6rem; 
        font-size: clamp(0.65rem, 3vw, 0.7rem);
        min-height: 36px; 
        white-space: nowrap; 
    }
    .sidebar {
        width: min(280px, 75vw); 
    }
    
    /* Ajuste específico para el contenedor de chat en móviles */
    .chat-messages {
        padding: 0.5rem; /* Reduce padding en móviles */
        margin-bottom: 1rem; /* Espacio para el input */
    }
    
    /* Previene desbordamiento horizontal */
    body, html {
        overflow-x: hidden;
        max-width: 100vw;
    }
}

/* --- Animaciones (Keyframes) --- */
.typing-cursor { display: inline-block; width: 10px; height: 1.2rem; background-color: var(--yellow-glow); animation: blink 1s infinite; vertical-align: middle; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse-mic { 0%, 100% { opacity: 0.7; transform: scale(1); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes pulse-bg { 0%, 100% { opacity: 0.25; transform: scale(1); } 50% { opacity: 0.35; transform: scale(1.03); } }
@keyframes flicker-bg { 0% { opacity: 0.1; } 50% { opacity: 0.25; } 100% { opacity: 0.2; } }

/* MEJORA: Keyframe para la animación de mensajes */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* MEJORA: Animación para el visualizador de audio SVG */
.audio-visualizer .bar { transition: height 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.audio-visualizer.playing .bar:nth-child(1) { animation: wave 1.2s infinite ease-in-out -0.4s; }
.audio-visualizer.playing .bar:nth-child(2) { animation: wave 1.2s infinite ease-in-out -0.2s; }
.audio-visualizer.playing .bar:nth-child(3) { animation: wave 1.2s infinite ease-in-out 0s; }
@keyframes wave { 0%, 100% { height: 4px; } 50% { height: 24px; } }

/* ===============================================
   == INICIO: ESTILOS PARA HERRAMIENTAS V17.2 ==
   =============================================== */

/* --- Estilos para la herramienta INTERACTIVE_MODEL --- */
.interactive-model-container { 
    position: relative; 
    width: 100%; 
    height: 450px; 
    background-color: rgba(0,0,0,0.2); 
    border: 1px solid var(--border-color);
    border-radius: 8px; 
    overflow: hidden; 
    margin-top: 1rem;
}
.interactive-model-nodes { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
}
.interactive-model-svg { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    top: 0; 
    left: 0; 
    pointer-events: none; 
}
.im-node { 
    position: absolute; 
    background-color: #2d3748; 
    color: var(--text-light); 
    border: 1px solid #63b3ed; 
    border-radius: 8px; 
    padding: 5px 10px; 
    font-size: 13px; 
    cursor: grab; 
    transition: transform 0.2s, box-shadow 0.2s; 
    user-select: none; 
    z-index: 10;
}
.im-node.central { 
    background-color: var(--yellow-glow);
    color: var(--text-dark); 
    border-color: #f6ad55; 
    font-weight: bold; 
    z-index: 11;
}
.im-node.dragging { 
    cursor: grabbing; 
    box-shadow: 0 0 20px rgba(144, 205, 244, 0.7); 
    transform: scale(1.05); 
    z-index: 1000; 
}
.im-edge { 
    stroke: rgba(74, 85, 104, 0.7); 
    stroke-width: 2px; 
}
.im-edge-label { 
    fill: #a0aec0; 
    font-size: 11px; 
    text-anchor: middle; 
    pointer-events: none; 
    paint-order: stroke;
    stroke: var(--dark-card);
    stroke-width: 3px;
    stroke-linecap: butt;
    stroke-linejoin: miter;
}
.interactive-model-tooltip { 
    display: none; 
    position: fixed; 
    background-color: #1a202c; 
    color: var(--text-light);
    border: 1px solid var(--yellow-glow);
    padding: 10px; 
    border-radius: 5px; 
    max-width: 300px; 
    font-size: 12px; 
    z-index: 1001; 
    pointer-events: none; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
            
/* --- Estilos para la herramienta CAUSAL_SIMULATION --- */
.causal-simulation-container { 
    padding: 10px; 
    background-color: rgba(0,0,0,0.2); 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    margin-top: 1rem;
}
.cs-node { 
    margin-left: 20px; 
    padding-left: 20px; 
    border-left: 2px solid #2d3748; 
    position: relative; 
}
.cs-node::before { 
    content: ''; 
    position: absolute; 
    left: 0; 
    top: 18px; /* Ajustado para alinear mejor */
    width: 18px; 
    height: 2px; 
    background-color: #2d3748; 
}
.cs-content { 
    background-color: #2d3748; 
    border-radius: 5px; 
    padding: 8px 12px; 
    margin: 5px 0; 
    display: flex; 
    align-items: center; 
    flex-wrap: wrap; 
}
.cs-toggle { 
    cursor: pointer; 
    font-family: monospace; 
    font-size: 16px; 
    margin-right: 10px; 
    width: 18px; 
    text-align: center;
    color: var(--yellow-glow);
    user-select: none;
}
.cs-event { 
    flex-grow: 1; 
    color: var(--text-light);
}
.cs-prob { 
    font-weight: bold; 
    margin-left: 15px; 
}
.cs-explanation { 
    font-size: 11px; 
    color: #a0aec0; 
    width: 100%; 
    margin-top: 5px; 
    padding-left: 28px; 
    border-top: 1px solid rgba(74, 85, 104, 0.5);
    padding-top: 5px;
}
.cs-outcomes { 
    display: none; 
}
.cs-outcomes.visible { 
    display: block; 
}

/* ===============================================
   == FIN: ESTILOS PARA HERRAMIENTAS V17.2 ==
   =============================================== */