/* Estilos personalizados para emular el diseño de la imagen */
body {
    font-family: 'Inter', sans-serif;
    background-image: url('../assets/images/image_a8b927.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: #0a0c1f;
    color: #e0e0e0;
    overflow: hidden;
}

/* Contenedor principal con el borde de neón */
.main-container {
    position: relative;
    background: rgba(16, 20, 41, 0.85);
    border-radius: 1rem;
    border: 1px solid rgba(51, 246, 246, 0.2);
    box-shadow:
        0 0 25px rgba(51, 246, 246, 0.6),
        0 0 50px rgba(168, 85, 247, 0.4),
        inset 0 0 10px rgba(51, 246, 246, 0.7),
        inset 0 0 25px rgba(168, 85, 247, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Simulación de las esquinas cortadas del diseño */
.main-container::before,
.main-container::after {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    border-style: solid;
}

.main-container::before {
    top: 8px;
    left: 8px;
    border-width: 4px 0 0 4px;
    border-color: #33f6f6;
}

.main-container::after {
    bottom: 8px;
    right: 8px;
    border-width: 0 4px 4px 0;
    border-color: #ec4899;
}

/* Estilo de la barra de scroll */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #1e293b;
}

::-webkit-scrollbar-thumb {
    background: #a855f7;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9333ea;
}

/* Contenedor del chat */
#chat-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: #a855f7 #1e293b;
}

/* Asegurar que el chat no desborde */
#chat-container::-webkit-scrollbar {
    width: 6px;
}

#chat-container::-webkit-scrollbar-track {
    background: #1e293b;
    border-radius: 3px;
}

#chat-container::-webkit-scrollbar-thumb {
    background: #a855f7;
    border-radius: 3px;
}

#chat-container::-webkit-scrollbar-thumb:hover {
    background: #9333ea;
}

/* Mensajes del chat */
.chat-bubble {
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
    animation: slide-in 0.5s forwards;
    max-width: 80%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-bubble.user {
    background-color: #4a044e;
    align-self: flex-end;
    margin-left: auto;
}

.chat-bubble.ai {
    background-color: #0c4a6e;
    align-self: flex-start;
    margin-right: auto;
}

@keyframes slide-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Contenedor de la animación de pensamiento (ahora fondo del chat) */
#chat-animation-bg {
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative; /* Necesario para el pseudo-elemento */
}

/* ✅ NUEVO: Degradado sobre la animación para atenuar el brillo */
#chat-animation-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(16, 20, 41, 0.1) 0%, rgba(16, 20, 41, 0.95) 100%);
    z-index: 1; /* Se coloca sobre el canvas pero debajo del chat */
}


#chat-animation-bg canvas {
    display: block;
}

/* Botón de envío con gradiente y efecto hover */
.send-button {
    background: linear-gradient(90deg, #a855f7, #6d28d9);
    transition: all 0.3s ease;
}

.send-button:hover {
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.8);
    transform: translateY(-2px);
}

/* Efecto de cursor para el texto de pensamiento */
.thinking-cursor::after {
    content: '_';
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* Estilos para el GIF del cerebro */
#brain-gif {
    animation: subtle-pulse 4s ease-in-out infinite;
    transition: all 0.3s ease;
}

@keyframes subtle-pulse {
    0%, 100% {
        opacity: 0.85;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}

/* Efecto de brillo cuando está procesando */
.brain-processing {
    animation: brain-active 1.5s ease-in-out infinite;
}

@keyframes brain-active {
    0%, 100% {
        filter: brightness(1.1) contrast(1.1);
        opacity: 0.9;
        transform: scale(1);
    }
    50% {
        filter: brightness(1.4) contrast(1.2) saturate(1.3);
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Loading Screen */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(42, 26, 63, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-logo {
    max-width: 200px;
    margin-bottom: 30px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #fff;
}

.loading-subtext {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
}

.loading-progress {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin: 20px auto 0;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #06b6d4);
    width: 0%;
    transition: width 0.5s ease;
    animation: progressBar 3s ease-in-out infinite;
}

@keyframes progressBar {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.loading-steps {
    margin-top: 30px;
    text-align: left;
    max-width: 400px;
}

.loading-step {
    display: flex;
    align-items: center;
    padding: 8px 0;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    transition: color 0.3s ease;
}

.loading-step.active {
    color: #10b981;
    font-weight: 600;
}

.loading-step.completed {
    color: rgba(255, 255, 255, 0.8);
}

.loading-step-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    border: 2px solid currentColor;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.loading-step.completed .loading-step-icon {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* ✅ NUEVO: Estilos para el botón del micrófono */
#mic-btn.is-listening {
    background-color: #ef4444; /* Color rojo para indicar que está grabando */
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.7);
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 10px 15px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/*
 ==========================================================================
  ✅ INICIO: Mejoras Responsivas Estructurales (Tema Oscuro)
 ==========================================================================
*/

/* Por defecto (móvil < 768px) - Estructura Full-Screen */

body {
    padding: 0 !important; /* Full-screen en móvil */
}

/* main-container ocupa toda la pantalla, sin bordes ni efectos */
.main-container {
    border-radius: 0;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    height: 100vh;
    padding: 0;
}

/* Ocultar las esquinas decorativas en móvil */
.main-container::before,
.main-container::after {
    display: none;
}

/* Ocultar la animación 3D de fondo en móvil (mejora rendimiento) */
#chat-animation-bg {
    display: none;
}

/* Ajustar contenedores de chat e input para que no tengan bordes redondeados */
#chat-container {
    border-radius: 0;
    margin-bottom: 0;
    /* Mantiene el fondo oscuro original (bg-black/30) */
}

/* ID 'input-area' debe estar en el <div> que rodea el <textarea> y botones en index.html */
#input-area {
    border-radius: 0;
    /* Mantiene el fondo oscuro original (bg-black/30) */
}

/* Las burbujas, textos e inputs ya tienen el estilo oscuro correcto por defecto */


/* Media Query para Tablet y Escritorio (>= 768px) */
@media (min-width: 768px) {
    
    /* Devolver padding al body */
    body {
        padding: 1rem !important;
    }
    
    @media (min-width: 1024px) { /* lg */
         body {
            padding: 2rem !important;
         }
    }

    /* Devolver todos los estilos de "consola" al main-container */
    .main-container {
        height: 85vh;
        border-radius: 1rem;
        border: 1px solid rgba(51, 246, 246, 0.2);
        box-shadow:
            0 0 25px rgba(51, 246, 246, 0.6),
            0 0 50px rgba(168, 85, 247, 0.4),
            inset 0 0 10px rgba(51, 246, 246, 0.7),
            inset 0 0 25px rgba(168, 85, 247, 0.5);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 1.5rem;
    }

    /* Devolver esquinas decorativas */
    .main-container::before,
    .main-container::after {
        display: block;
    }

    /* Mostrar animación 3D de nuevo */
    #chat-animation-bg {
        display: block;
    }

    /* Devolver bordes redondeados al chat e input */
    #chat-container {
        border-radius: 0.5rem;
        margin-bottom: 1rem;
    }

    #input-area {
        border-radius: 0.5rem;
    }
}

/* ✅ FIN: Mejoras Responsivas */