/* Estilos para el botón de burbuja */
.chat-bubble {
    position: fixed;
    bottom: 30px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: var(--color-primary);
    color: white;
    border-radius: 50%;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease-in-out, right 0.3s ease-in-out;
    z-index: 9998;
}

.chat-bubble img {
    width: 28px;
    height: 28px;
}

.chat-bubble.moved {
    right: 90px; /* Ajustado para no superponerse */
}

.chat-bubble:hover {
    transform: scale(1.1);
}

/* Contenedor principal del widget de chat */
.chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    max-width: 90vw;
    height: 60vh;
    max-height: 70vh;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.2s ease-out, opacity 0.2s ease-out, visibility 0.2s;
    z-index: 9999;
}

/* Estado abierto del widget */
.chat-widget.open {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

/* Modo inmersivo */
.chat-widget.immersive {
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    max-height: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
}

/* Barra superior del chat */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.header-title {
    font-weight: bold;
    font-size: 1rem;
}

.chat-header-buttons button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    margin-left: 5px;
    color: #555;
}

.chat-header-buttons button:hover {
    color: #000;
}

/* Zona de mensajes */
.chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    align-items: flex-start;
    max-width: 80%;
    line-height: 1.4;
}

.message-content {
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
}

/* Mensajes del bot */
.message.bot {
    align-self: flex-start;
}

.message.bot .message-content {
    background-color: #e9e9eb;
    color: #000;
    border-top-left-radius: 0;
}

.bot-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #007bff;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 10px;
    flex-shrink: 0;
}

/* Mensajes del usuario */
.message.user {
    align-self: flex-end;
}

.message.user .message-content {
    background-color: #007bff;
    color: white;
    border-top-right-radius: 0;
}

/* Zona de entrada de texto */
.chat-input-area {
    border-top: 1px solid #e0e0e0;
    padding: 10px;
    background-color: #f5f5f5;
}

.chat-input-form {
    display: flex;
    align-items: center;
}

#chat-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 8px 12px;
    resize: none;
    min-height: 40px; /* Anula el min-height global y previene el scroll */
    max-height: 120px;
    overflow: hidden; /* Oculta el scroll inicialmente */
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.4;
    box-sizing: border-box; /* Asegura que el padding se incluya en la altura */
}

#chat-input:focus {
    outline: none;
    border-color: #007bff;
}

#chat-send {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #007bff;
    margin-left: 10px;
}

#chat-send:hover {
    opacity: 0.7;
}

#chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.char-counter-container {
    text-align: right;
    font-size: 0.75rem;
    color: #888;
    padding-right: 15px;
    margin-top: 4px;
}

/* Indicador de escritura del bot */
.message.typing-indicator {
    align-self: flex-start;
}

.typing-indicator .message-content {
    background-color: #e9e9eb;
    color: #000;
    border-top-left-radius: 0;
    display: flex;
    align-items: center;
    padding: 12px 15px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #8e8e93;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing-bounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1.0);
    }
}
