/* Importación de la fuente moderna Poppins */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* NOTA: Se eliminó html, body { height: 100%; } para evitar conflictos */

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    /* FIX ALTURA: Asegura que el cuerpo ocupe toda la altura de la pantalla */
    height: 100vh;
    /* --- RESTAURANDO LA IMAGEN DE FONDO --- */
    background-image: url('/static/fondo1.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: #e9f5e9;
    transition: background-color 0.5s ease;
}


/* --- ENCABEZADO --- */

#app-header {
    width: 100%;
    max-width: 800px;
    text-align: center;
    padding: 30px 20px 20px 20px;
    position: relative;
    z-index: 10;
    color: #e0f7e0;
    text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.7);
}

#app-header h1 {
    font-size: 2.5em;
    font-weight: 700;
    margin: 0;
    color: #e0f7e0;
}

#app-header p {
    font-size: 1.1em;
    font-weight: 500;
    margin-top: 5px;
    color: #c8e6c9;
}


/* --- CONTENEDOR DEL CHAT (CHATBOX) --- */

#chat-container {
    width: 90%;
    max-width: 800px;
    /* Usar altura flexible */
    flex-grow: 1;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    /* --- GLASSMORPHISM MÁS OPÁCO (MENOS TRANSPARENCIA) --- */
    background-color: rgba(255, 255, 255, 0.90);
    /* Corregido: 90% opacidad */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.7);
    overflow: hidden;
    margin-bottom: 20px;
}

#message-history {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}


/* --- BUBBLE STYLES (Mensajes) --- */

@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-start;
    animation: fadeInSlideUp 0.3s ease-out;
}

.ai-message {
    justify-content: flex-start;
    margin-right: 10%;
}

.ai-message .message-content {
    background-color: #f5f5f5;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    color: #333;
}

.user-message {
    justify-content: flex-end;
    margin-left: 10%;
}

.user-message .message-content {
    background-color: #28a745;
    border-radius: 18px 18px 4px 18px;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}

.message-content {
    padding: 12px 16px;
    max-width: 100%;
    word-wrap: break-word;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    line-height: 1.6;
}


/* CLAVE: ESTO ESPACIA LOS PÁRRAFOS CREADOS POR EL JS */

.message-content p {
    margin: 0;
    padding: 0;
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}


/* --- AVATARES (Usando tus imágenes .png) --- */

.avatar {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

img.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s ease;
}

.ai-message .avatar {
    margin-right: 10px;
}

.user-message .avatar {
    margin-left: 10px;
}


/* --- ÁREA DE INPUT --- */

#input-area {
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    /* GLASSMORPHISM MÁS OPÁCO (MENOS TRANSPARENCIA) */
    background-color: rgba(255, 255, 255, 0.80);
    /* Corregido: 80% opacidad */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    align-items: flex-end;
    border-bottom-right-radius: 15px;
    border-bottom-left-radius: 15px;
}

#message-input {
    flex-grow: 1;
    min-height: 40px;
    max-height: 200px;
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 25px;
    resize: none;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.08);
}

#message-input:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 4px rgba(40, 167, 69, 0.3);
}

#send-button {
    background-color: #28a745;
    background-image: url('/static/icono3.png');
    background-size: 75%;
    background-repeat: no-repeat;
    background-position: center;
    color: transparent;
    border: none;
    margin-left: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    height: 55px;
    width: 55px;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
    flex-shrink: 0;
}

#send-button:hover {
    background-color: #218838;
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.5);
}


/* --- MEDIA QUERIES (Asegurando Responsive y Full Height) --- */

@media (max-width: 768px) {
    body {
        align-items: stretch;
        /* Estira el contenido al ancho */
    }
    #app-header {
        padding: 15px 10px 10px 10px;
    }
    #chat-container {
        width: 100%;
        /* FIX RESPONSIVE ALTURA: Usa el espacio disponible en la ventana */
        height: calc(100vh - 120px);
        border-radius: 0;
        box-shadow: none;
        margin-bottom: 0;
    }
    .ai-message,
    .user-message {
        margin-left: 3%;
        margin-right: 3%;
    }
    #input-area {
        padding: 10px;
        border-radius: 0;
    }
    #send-button {
        height: 50px;
        width: 50px;
        margin-left: 8px;
    }
    #message-input {
        min-height: 38px;
        padding: 8px 12px;
        font-size: 15px;
    }
}