﻿/* === Chat.css === */

/* Reset básico */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* background: #f8f9fa; */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.d-none {
    display: none !important;
}

/* Contenedor principal del chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* fallback */
    height: 100dvh; /* mejor soporte en móviles modernos */
}

/* Título */
.chat-title {
    margin: 0;
    padding: 0.5rem;
    background: #fff;
    border-bottom: 1px solid #ddd;
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
}

/* Historial */
.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    /*background: #f8f9fa;*/
}

/* Burbuja del usuario */
.user-message {
    align-self: flex-end;
    max-width: 75%;
    /*background: #007bff;*/
    background: rgba(0, 123, 255, 0.9);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 15px;
    border-bottom-right-radius: 0;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

/* Burbuja de la IA */
.ai-message {
    align-self: flex-start;
    max-width: 75%;
    /*background: #e9ecef;*/
    background: rgba(233, 236, 239, 0.9);
    color: #000;
    padding: 0.5rem 0.75rem;
    border-radius: 15px;
    border-bottom-left-radius: 0;
    word-wrap: break-word;
    /*white-space:  pre-wrap;*/
    font-size: 0.95rem;
}

/* Entrada */
.chat-input {
    display: flex;
    /*align-items: flex-end;*/
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #fff;
    border-top: 1px solid #ddd;
}

    .chat-input textarea {
        flex-grow: 1;
        resize: none;
        min-height: 28px;
        max-height: 120px;
        border: 2px solid #ccc;
        border-radius: 10px;
        padding: 0.5rem;
        /*font-size: 0.95rem;*/
        font-size: 16px;
        border-color: #007bff;
        transition: border-color 0.2s, box-shadow 0.2s;
    }
    /* Cuando el textarea está enfocado */
    .chat-input textarea:focus {
        outline: none;
        border-color: #007bff; /* azul del botón enviar */
        box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.25); /* efecto glow */
    }

/* Imágenes dentro de los mensajes del chat */
.chat-img {
    max-width: 100%; /* nunca desbordar la burbuja */
    height: auto; /* mantiene proporción */
    border-radius: 8px; /* esquinas redondeadas */
    margin-top: 4px; /* pequeño espacio respecto al texto */
    display: block; /* asegura que ocupe su propia línea */
}

/* Botones */
.btn-icon {
    background: #e9ecef;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
}

    .btn-icon.primary {
                background: #007bff;
        color: #fff;
/*        background: #fff; 
        border: 2px solid #007bff;  
        color: #007bff; */  
    }

    .btn-icon:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* Tokens */
.chat-tokens {
    font-size: 0.8rem;
    padding: 0.5rem;
    background: #fff;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
}


/* Burbuja especial para animación escribiendo */
.ai-message.typing {
    display: inline-flex; /* burbuja como flex */
    align-items: center; /* centra verticalmente */
    justify-content: center;
    background: #e9ecef;
    color: #000;
    border-radius: 15px;
    border-bottom-left-radius: 0;
    max-width: fit-content;
    padding: 6px 10px; /* algo de aire */
    min-height: 32px; /* evita recortes */
    line-height: 0;
}

    /* Wrapper para el lottie; así controlamos la altura real visible */
    .ai-message.typing .typing-dots {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 24px; /* altura “visible” del loader */
    }


    /* El propio lottie: tamaño consistente y sin márgenes raros */
    .ai-message.typing lottie-player {
        width: 44px;
        height: 24px;
        display: block;
        margin: 0;
    }

#imageButton {
    display: none;
}

    #imageButton:not(.d-none) {
        display: flex; /* o inline-flex */
    }


.chat-title {
    display: flex;
    align-items: center;
    justify-content: center; /* 👈 centra el contenido */
    gap: 0.5rem;
    position: relative; /* necesario para el botón back */
}

.btn-back {
    position: absolute;
    left: 0.5rem;
    background: none;
    border: none;
    color: #007bff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
}

    .btn-back:focus {
        outline: none;
    }