/* ======================================
1. ESTILOS BASE Y POSICIONAMIENTO
======================================
*/
/* Quitar el centrado fijo del cuerpo */
body { 
    font-family: 'Segoe UI', sans-serif; 
    margin: 0; 
    /* Aseguramos que el posicionamiento fijo sea relativo al body */
    height: 100vh;
    width: 100vw;
}

/* Contenedor del widget flotante (la ventana de chat) */
.chat-widget-container {
    /* Fija la posición en la ventana */
    position: fixed; 
    bottom: 100px; /* Separación de la burbuja y el borde inferior */
    right: 20px;
    /* Estilos de la ventana de chat */
    width: 400px;
    height: 600px;
    z-index: 1000; /* Asegura que esté por encima de otros elementos */
    transition: all 0.3s ease-in-out;
    
    /* Inicialmente, ocultamos el widget de chat */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.98);
    transform-origin: bottom right;
}

/* Clase para mostrar el chat */
.chat-widget-container.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* El botón/burbuja flotante */
#chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #4285F4;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    cursor: pointer;
    z-index: 1001; /* Asegura que esté por encima del widget de chat */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* ======================================
2. ESTILOS DE TU CHAT EXISTENTE
======================================
*/

.chat-container {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: #4285F4;
    color: white;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    border-radius: 15px 15px 0 0;
}

.chat-box {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: #4285F4;
    color: white;
    border-bottom-right-radius: 5px;
}

.message.bot {
    align-self: flex-start;
    background: white;
    color: #333;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.typing {
    display: none;
    font-style: italic;
    color: #666;
    padding: 10px 15px;
    align-self: flex-start;
}

.input-area {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

.input-area input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
}

.input-area input:focus {
    border-color: #4285F4;
}

.input-area button {
    padding: 10px 20px;
    background: #4285F4;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.input-area button:hover {
    background: #3367d6;
}

/* ======================================
3. RESPONSIVIDAD PARA DISPOSITIVOS MÓVILES
======================================
*/

/* Media query para pantallas menores a 768px (tablets y móviles) */
@media (max-width: 768px) {
    /* Ajustar el contenedor del widget de chat */
    .chat-widget-container {
        width: 90vw; /* Ancho del 90% de la ventana */
        height: 80vh; /* Altura del 80% de la ventana */
        bottom: 80px; /* Ajustar separación del borde inferior */
        right: 5vw; /* Centrar horizontalmente con margen derecho */
        left: 5vw; /* Centrar horizontalmente con margen izquierdo */
        max-width: 400px; /* Máximo ancho para evitar que sea demasiado grande */
        max-height: 600px; /* Máximo alto para evitar que sea demasiado grande */
    }

    /* Ajustar el botón de burbuja */
    #chat-bubble {
        width: 50px; /* Tamaño más pequeño */
        height: 50px;
        font-size: 24px; /* Icono más pequeño */
        bottom: 20px;
        right: 20px;
    }

    /* Ajustar el tamaño de fuente en mensajes para móviles */
    .message {
        font-size: 13px; /* Texto un poco más pequeño */
        max-width: 85%; /* Permitir más ancho en móviles */
    }

    /* Ajustar el área de entrada */
    .input-area input {
        font-size: 13px; /* Texto más pequeño */
    }

    .input-area button {
        font-size: 13px; /* Botón más pequeño */
        padding: 8px 16px; /* Padding reducido */
    }
}

/* Media query adicional para pantallas muy pequeñas (< 480px) */
@media (max-width: 480px) {
    .chat-widget-container {
        width: 95vw; /* Casi toda la pantalla */
        height: 85vh; /* Mayor altura para aprovechar el espacio */
        bottom: 70px; /* Más cerca del borde inferior */
        right: 2.5vw;
        left: 2.5vw;
    }

    #chat-bubble {
        width: 45px; /* Aún más pequeño */
        height: 45px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }

    .chat-header {
        font-size: 16px; /* Título más pequeño */
        padding: 12px; /* Padding reducido */
    }

    .chat-box {
        padding: 12px; /* Padding reducido */
    }

    .input-area {
        padding: 12px; /* Padding reducido */
    }
}
