@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap');

body {
    font-family: 'Roboto', sans-serif;
    background-color: #e5ddd5; /* Fondo similar a WhatsApp */
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #333;
    overflow: hidden; /* Evita barras de desplazamiento en el body */
}

.chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px; /* Ancho típico de un chat */
    height: 95vh; /* Altura para simular app móvil */
    max-height: 800px; /* Altura máxima para pantallas grandes */
    background-color: #f0f0f0; /* Fondo del chat */
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.chat-header {
    background-color: #075e54; /* Color de la barra superior de WhatsApp */
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #fff; /* Placeholder para el avatar */
    object-fit: cover;
}

.chat-header-info h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 700;
}

.chat-header-info p {
    margin: 0;
    font-size: 0.85em;
    opacity: 0.8;
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto; /* Permite desplazamiento en los mensajes */
    background-color: #e5ddd5; /* Fondo de los mensajes */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 12px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word; /* Rompe palabras largas */
}

.message p {
    margin: 0;
    line-height: 1.4;
}

.message .timestamp {
    font-size: 0.7em;
    color: #667781;
    text-align: right;
    margin-top: 5px;
    display: block;
}

.user-message {
    align-self: flex-end; /* Mensajes del usuario a la derecha */
    background-color: #dcf8c6; /* Color de burbuja de usuario de WhatsApp */
    color: #1a1a1a;
    border-bottom-right-radius: 2px; /* Esquina de la burbuja */
}

.bot-message {
    align-self: flex-start; /* Mensajes del bot a la izquierda */
    background-color: #ffffff; /* Color de burbuja del bot de WhatsApp */
    color: #1a1a1a;
    border-bottom-left-radius: 2px; /* Esquina de la burbuja */
}

.initial-message {
    background-color: #ffffff;
    align-self: center; /* Centra el mensaje inicial */
    text-align: center;
    max-width: 90%;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chat-input-area {
    background-color: #f0f0f0; /* Fondo del área de entrada */
    padding: 10px 15px;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
}

.chat-form {
    display: flex;
    align-items: flex-end; /* Alinea el textarea y el botón en la parte inferior */
    gap: 10px;
}

textarea {
    flex-grow: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 20px; /* Bordes redondeados para el input */
    background-color: #ffffff;
    font-size: 1em;
    resize: none; /* Evita que el usuario redimensione */
    overflow-y: hidden; /* Oculta la barra de desplazamiento */
    min-height: 40px; /* Altura mínima */
    max-height: 120px; /* Altura máxima antes de scroll */
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
    line-height: 1.4;
}

textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(7, 94, 84, 0.3); /* Sombra al enfocar */
}

button {
    background-color: #128c7e; /* Color del botón de enviar de WhatsApp */
    color: white;
    border: none;
    border-radius: 50%; /* Botón redondo */
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    flex-shrink: 0; /* Evita que el botón se encoja */
}

button:hover {
    background-color: #075e54;
    transform: scale(1.05);
}

button:active {
    transform: scale(0.95);
}

button svg {
    fill: currentColor; /* Usa el color del texto para el SVG */
    width: 24px;
    height: 24px;
}

/* Scrollbar personalizado */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Estilos para tablas generadas por el modelo */
/* Estos estilos se aplicarán a las tablas dentro de los mensajes del bot */
.bot-message .response-content table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px; /* Ajusta el margen superior para que no esté pegado al borde de la burbuja */
    margin-bottom: 5px; /* Ajusta el margen inferior */
    background-color: #fcfcfc;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-radius: 6px;
    overflow: hidden; /* Asegura que los bordes redondeados se vean bien */
    word-break: break-all; /* Rompe palabras para evitar desbordamiento en celdas pequeñas */
}

.bot-message .response-content th,
.bot-message .response-content td {
    border: 1px solid #ececec;
    padding: 8px 12px;
    text-align: left;
    vertical-align: top; /* Alinea el contenido en la parte superior de la celda */
}

.bot-message .response-content th {
    background-color: #f5f5f5;
    font-weight: bold;
    color: #444;
    text-transform: uppercase;
    font-size: 0.85em;
}

.bot-message .response-content tr:nth-child(even) {
    background-color: #f9f9f9;
}

.bot-message .response-content tr:hover {
    background-color: #eef;
}

/* Estilos adicionales para HTML dentro de las burbujas (listas, etc.) */
.bot-message .response-content ul,
.bot-message .response-content ol {
    margin-top: 8px;
    margin-bottom: 8px;
    padding-left: 20px;
}

.bot-message .response-content li {
    margin-bottom: 4px;
    line-height: 1.5;
}

.bot-message .response-content strong {
    font-weight: bold;
}

/* Ajustes para párrafos dentro de response-content para un mejor espaciado */
.bot-message .response-content p:not(:last-child) {
    margin-bottom: 0.8em;
}


/* Responsive adjustments */
@media (max-width: 650px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }
    body {
        padding: 0;
    }
}
