feat(ai): redesign mobile chat widget with Mercado Libre bottom-sheet UX and keyboard docking (v3.8.36)
This commit is contained in:
@@ -11,6 +11,22 @@ El formato está basado en [Keep a Changelog](https://keepachangelog.com/es-ES/1
|
|||||||
- **Sincronización Continua Moodle (Fase 6):** Automatización de workers persistentes en background para el procesamiento continuo de la cola de Web Services Moodle 4.1.
|
- **Sincronización Continua Moodle (Fase 6):** Automatización de workers persistentes en background para el procesamiento continuo de la cola de Web Services Moodle 4.1.
|
||||||
- **Pruebas de Carga y Hardening (Fase 6):** Pruebas de estrés de concurrencia y validación final de producción.
|
- **Pruebas de Carga y Hardening (Fase 6):** Pruebas de estrés de concurrencia y validación final de producción.
|
||||||
|
|
||||||
|
## [3.8.36] - 2026-10-27
|
||||||
|
### Added & Enhanced (Rediseño Móvil del Chatbot UdeCi estilo Mercado Libre / Mago)
|
||||||
|
- **Bottom Sheet Nativo en Móvil (< 768px)**:
|
||||||
|
- Se transformó la interfaz del chatbot en móvil a un **Bottom Sheet modal nativo** inspirado en la experiencia de Mercado Libre ("Mago"), cubriendo el 92% de la pantalla (`height: 92dvh; border-top-left-radius: 28px; border-top-right-radius: 28px;`).
|
||||||
|
- Incorporación de **Backdrop sombreado con desenfoque (`#aiChatBackdrop`)** que bloquea la interacción con la página web de fondo y evita desbordes visuales.
|
||||||
|
- **Drag Handle Superior Interactiva**: Barra de deslizamiento táctil con soporte de gestos (`touchmove` / `touchend`) para cerrar el panel deslizando hacia abajo.
|
||||||
|
- **Cabecera Flotante y Limpia**: Botón de retroceso `<` tipo píldora, ícono Sparkle animado de UdeCi y botones superiores de nuevo chat y atajos rápidos.
|
||||||
|
- **Disclaimer Institucional**: Frase *"UdeCi usa inteligencia artificial para responderte."* con tipografía limpia.
|
||||||
|
- **Dock de Entrada y Manejo Dinámico del Teclado Virtual (`visualViewport`)**:
|
||||||
|
- Cápsula de entrada redondeada (`border-radius: 28px`) con botón circular `+` para desplegar atajos temáticos, textarea expandible con placeholder *"Pregúntame"* y botón de envío circular.
|
||||||
|
- Integración de la API `window.visualViewport`: al desplegarse el teclado táctil en smartphones Android/iOS, el contenedor del chat se recalcula dinámicamente y el input se ancla **directamente encima del teclado**, eliminando cualquier espacio o transparencia no deseada.
|
||||||
|
- **Burbujas de Conversación y Acciones de Feedback**:
|
||||||
|
- Mensaje de usuario en píldora suave a la derecha con marca horaria (`HH:mm`) en pie de burbuja.
|
||||||
|
- Mensaje de UdeCi en texto limpio y aireado con barra de utilidades (copiado al portapapeles con confirmación visual, lectura con síntesis de voz `SpeechSynthesisUtterance` y pulgares de valoración).
|
||||||
|
- Explicitación en System Prompt de las capacidades accesibles del tutor virtual (datos académicos, ocupación, reservas, clima en tiempo real de Sede Central y rutas Google Maps).
|
||||||
|
|
||||||
## [3.8.35] - 2026-10-27
|
## [3.8.35] - 2026-10-27
|
||||||
### Fixed & Enhanced (Comportamiento de Acordeón Único y Legibilidad de Alto Contraste en Menú Lateral)
|
### Fixed & Enhanced (Comportamiento de Acordeón Único y Legibilidad de Alto Contraste en Menú Lateral)
|
||||||
- **Acordeón Estricto de Menú Lateral (Un Solo Menú Desplegado)**:
|
- **Acordeón Estricto de Menú Lateral (Un Solo Menú Desplegado)**:
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ Memoria del proyecto entre sesiones para la rama `dev`.
|
|||||||
- Libro de Calificaciones (*Gradebook*) con actas de regularidad inmutables.
|
- Libro de Calificaciones (*Gradebook*) con actas de regularidad inmutables.
|
||||||
- Autenticación híbrida (Google OAuth 2.0, Moodle SSO, Local) y Modo Impersonación.
|
- Autenticación híbrida (Google OAuth 2.0, Moodle SSO, Local) y Modo Impersonación.
|
||||||
- Reinicialización segura del sistema con contraseña de Administrador.
|
- Reinicialización segura del sistema con contraseña de Administrador.
|
||||||
- **Sprint Activo: Menú Lateral con Acordeón Estricto y Legibilidad de Alto Contraste — SDD-011 (v3.8.35)**:
|
- **Sprint Activo: Rediseño Móvil del Chatbot UdeCi estilo Mercado Libre — SDD-011 (v3.8.36)**:
|
||||||
- **Acordeón Estricto (Un Solo Menú Desplegado)**: Se configuró `data-bs-parent="#sidebarNav"` en los 13 submenús colapsables y se depuró el script JS para asegurar que sólo el submenú activo o en uso permanezca abierto, cerrando inmediatamente cualquier otro. En Dashboard e inicio, todos los submenús quedan replegados.
|
- **Experiencia Bottom Sheet Nativa**: Panel de chat transformado a bottom sheet modal en móviles (< 768px) ocupando el 92% de la pantalla (`92dvh`), con esquinas redondeadas (`28px`), drag handle superior con gestos de deslizamiento táctil para cerrar, botón de retroceso `<`, header con ícono de destellos (sparkle) y disclaimer institucional.
|
||||||
- **Legibilidad Nítida y Alto Contraste (WCAG AAA)**: Se corrigió la falta de contraste en enlaces con clases utilitarias (`.text-info`, `.text-success`, `.text-warning`, `.text-primary`), asignando paletas adaptativas legibles. Se fijó tipografía seminegrita (`font-weight: 600`) y colores Slate-900 / Slate-50 en submenús, y Slate-700 / Slate-300 con `font-weight: 800` en encabezados de sección. Se amplió el ancho a `275px`.
|
- **Backdrop y Aislamiento Total**: Fondo desenfocado `#aiChatBackdrop` que bloquea la interacción con la pantalla subyacente y previene desbordes.
|
||||||
- **Versión Consolidada**: `v3.8.35`.
|
- **Dock de Entrada y Teclado Virtual con `visualViewport`**: Contenedor en cápsula con botón `+`, placeholder *"Pregúntame"*, y anclaje automático e impecable directamente encima del teclado móvil táctil.
|
||||||
|
- **Burbujas y Acciones Meli**: Mensajes de usuario con timestamp (`HH:mm`), respuestas limpias con barra de utilidades (copiar, síntesis de voz, feedback), y precisión en el System Prompt para informar acceso a clima y geolocalización.
|
||||||
|
- **Versión Consolidada**: `v3.8.36`.
|
||||||
|
|
||||||
## Decisiones (y por qué)
|
## Decisiones (y por qué)
|
||||||
- **Flujo Secuencial de Bedelía (9 Pasos)**: Estandarizar la carga operativa en: 1) Sede -> 2) Aula -> 3) Ciclo Lectivo -> 4) Carrera -> 5) Materia (vinculada a Carrera) -> 6) Comisión (asociada a Materia, Carrera y Ciclo) -> 7) Profesores -> 8) Alumnos -> 9) Reserva de Espacio. Esto asegura consistencia e integridad relacional.
|
- **Flujo Secuencial de Bedelía (9 Pasos)**: Estandarizar la carga operativa en: 1) Sede -> 2) Aula -> 3) Ciclo Lectivo -> 4) Carrera -> 5) Materia (vinculada a Carrera) -> 6) Comisión (asociada a Materia, Carrera y Ciclo) -> 7) Profesores -> 8) Alumnos -> 9) Reserva de Espacio. Esto asegura consistencia e integridad relacional.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from typing import Any
|
|||||||
from database import db, get_db, engine, SessionLocal, session
|
from database import db, get_db, engine, SessionLocal, session
|
||||||
from config.config import Config
|
from config.config import Config
|
||||||
|
|
||||||
__version__ = "3.8.35"
|
__version__ = "3.8.36"
|
||||||
|
|
||||||
class DummyContext:
|
class DummyContext:
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
|
|||||||
@@ -121,6 +121,13 @@ def generate_system_prompt_for_role(
|
|||||||
"5. PRIVACIDAD ESTRICTA: Los alumnos NUNCA deben ser remitidos al 'Gradebook' ni a la 'Sábana de Calificaciones', ya que ese panel contiene datos de todos los compañeros. Para consultar notas, un alumno debe dirigirse a 'Mis Calificaciones e Hitos' en 'Mi Trayectoria'.\n"
|
"5. PRIVACIDAD ESTRICTA: Los alumnos NUNCA deben ser remitidos al 'Gradebook' ni a la 'Sábana de Calificaciones', ya que ese panel contiene datos de todos los compañeros. Para consultar notas, un alumno debe dirigirse a 'Mis Calificaciones e Hitos' en 'Mi Trayectoria'.\n"
|
||||||
"6. BREVEDAD Y PRECISIÓN: Responde en máximo 2 a 3 oraciones concisas o pasos directos sin rodeos ni introducciones vacías.\n"
|
"6. BREVEDAD Y PRECISIÓN: Responde en máximo 2 a 3 oraciones concisas o pasos directos sin rodeos ni introducciones vacías.\n"
|
||||||
"7. DATOS REALES EN VIVO, CALIFICACIONES E HITOS: Utiliza la sección 'ESTADO EN VIVO DEL SISTEMA' para responder con total fidelidad:\n"
|
"7. DATOS REALES EN VIVO, CALIFICACIONES E HITOS: Utiliza la sección 'ESTADO EN VIVO DEL SISTEMA' para responder con total fidelidad:\n"
|
||||||
|
" - Si preguntan a qué información tienes acceso o qué puedes responder, aclara con amabilidad que tienes acceso a:\n"
|
||||||
|
" * Datos académicos y de cursada del usuario según su rol (materias, comisiones, notas, regularidad y próximas clases presenciales).\n"
|
||||||
|
" * Estado de ocupación de sedes y aulas (presenciales y virtuales) y cartelera del día.\n"
|
||||||
|
" * Gestión y estado de reservas de espacios áulicos.\n"
|
||||||
|
" * Clima y temperatura en tiempo real en UniCABA Sede Central (vía integración meteorológica).\n"
|
||||||
|
" * Rutas y cómo llegar a la universidad con Google Maps y medios de transporte público.\n"
|
||||||
|
" * Flujo operativo de 9 pasos para Bedelía, optimizador genético y soporte en Moodle.\n"
|
||||||
" - Si un alumno pregunta por sus notas o regularidad, responde con las notas y condición académica según 'ESTADO EN VIVO DEL SISTEMA'.\n"
|
" - Si un alumno pregunta por sus notas o regularidad, responde con las notas y condición académica según 'ESTADO EN VIVO DEL SISTEMA'.\n"
|
||||||
" - Si preguntan cuántas comisiones hay sin asignar o cuál es la comisión que más alumnos tiene, responde con los datos operativos del estado en vivo.\n"
|
" - Si preguntan cuántas comisiones hay sin asignar o cuál es la comisión que más alumnos tiene, responde con los datos operativos del estado en vivo.\n"
|
||||||
" - Si preguntan por profesores registrados o si alguno se llama de cierta forma (ej. Sergio), responde en base a la nómina de docentes del estado en vivo.\n"
|
" - Si preguntan por profesores registrados o si alguno se llama de cierta forma (ej. Sergio), responde en base a la nómina de docentes del estado en vivo.\n"
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="edu-space-admin",
|
name="edu-space-admin",
|
||||||
version="3.8.35",
|
version="3.8.36",
|
||||||
description="Administrative interface for Edu-Space Classroom Management System (FastAPI ASGI Core)",
|
description="Administrative interface for Edu-Space Classroom Management System (FastAPI ASGI Core)",
|
||||||
author="Edu-Space Development Team",
|
author="Edu-Space Development Team",
|
||||||
author_email="admin@edu-space.com",
|
author_email="admin@edu-space.com",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"version": "3.8.35",
|
"version": "3.8.36",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* ai-chat-widget.js - Lógica interactiva de UdeCi (SDD-010)
|
* ai-chat-widget.js - Tutor Virtual UdeCi (UniCABA)
|
||||||
* Asistente y Tutor Virtual de UniCABA con soporte RAG,
|
* Experiencia de usuario y diseño tipo Bottom Sheet móvil estilo Mercado Libre.
|
||||||
* respuestas concisas y botones de opciones interactivas.
|
* Incluye soporte RAG, input dock inteligente, manejo de teclado virtual,
|
||||||
|
* chips de rol, copia de mensajes y síntesis de voz en español.
|
||||||
*/
|
*/
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let isProcessing = false;
|
let isProcessing = false;
|
||||||
|
let touchStartY = 0;
|
||||||
|
let touchDeltaY = 0;
|
||||||
|
|
||||||
// Limpiar clave histórica compartida para evitar contaminación entre perfiles
|
// Limpiar claves obsoletas
|
||||||
try {
|
try {
|
||||||
sessionStorage.removeItem('edu_space_udeci_chat_history_v2');
|
sessionStorage.removeItem('edu_space_udeci_chat_history_v2');
|
||||||
localStorage.removeItem('edu_space_udeci_chat_history_v2');
|
localStorage.removeItem('edu_space_udeci_chat_history_v2');
|
||||||
@@ -24,7 +27,6 @@
|
|||||||
if (rawId && rawId.toString().trim()) {
|
if (rawId && rawId.toString().trim()) {
|
||||||
return 'usr_' + rawId.toString().trim().replace(/[^a-zA-Z0-9_-]/g, '_');
|
return 'usr_' + rawId.toString().trim().replace(/[^a-zA-Z0-9_-]/g, '_');
|
||||||
}
|
}
|
||||||
// Identificador único de sesión por pestaña si no está logueado
|
|
||||||
let anonId = sessionStorage.getItem('edu_space_anon_chat_session');
|
let anonId = sessionStorage.getItem('edu_space_anon_chat_session');
|
||||||
if (!anonId) {
|
if (!anonId) {
|
||||||
anonId = 'anon_' + Math.random().toString(36).substring(2, 10) + '_' + Date.now();
|
anonId = 'anon_' + Math.random().toString(36).substring(2, 10) + '_' + Date.now();
|
||||||
@@ -38,17 +40,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ROLE_CHIPS = {
|
const ROLE_CHIPS = {
|
||||||
docente: [
|
admin: [
|
||||||
{ label: "📝 Notas de Alumnos", query: "¿Cuáles son las notas y calificaciones de mis alumnos?" },
|
{ label: "📊 Métricas del Sistema", query: "¿Cuáles son las estadísticas y métricas generales del sistema?" },
|
||||||
{ label: "📅 Hitos y Exámenes", query: "¿Cuáles son los hitos evaluativos y fechas de examen programadas?" },
|
{ label: "⚙️ Configuración Global", query: "¿Cómo configuro el servidor LLM y los parámetros de IA?" },
|
||||||
{ label: "📍 Mis Comisiones", query: "¿Cuáles son mis comisiones a cargo y aulas asignadas?" }
|
{ label: "🛡️ Roles y Usuarios", query: "¿Cómo administro los usuarios y roles RBAC?" },
|
||||||
|
{ label: "📍 Ocupación de Sedes", query: "¿Cuál es el estado de ocupación de las sedes y aulas?" }
|
||||||
],
|
],
|
||||||
bedelia: [
|
bedelia: [
|
||||||
{ label: "🔄 Flujo 9 Pasos", query: "¿Cuáles son los 9 pasos del flujo de Bedelía?" },
|
{ label: "🔄 Flujo 9 Pasos", query: "¿Cuáles son los 9 pasos del flujo de Bedelía?" },
|
||||||
{ label: "⚠️ Conflictos Áulicos", query: "¿Cómo funciona la matriz de conflictos y aforo?" },
|
{ label: "⚠️ Conflictos Áulicos", query: "¿Cómo funciona la matriz de conflictos y aforo?" },
|
||||||
{ label: "🧬 Optimizador IA", query: "¿Cómo uso el optimizador de aulas?" },
|
{ label: "🧬 Optimizador IA", query: "¿Cómo uso el optimizador genético de aulas?" },
|
||||||
{ label: "📑 Importar Sheets", query: "¿Cómo uso el importador de Google Sheets?" }
|
{ label: "📑 Importar Sheets", query: "¿Cómo uso el importador de Google Sheets?" }
|
||||||
],
|
],
|
||||||
|
docente: [
|
||||||
|
{ label: "📝 Notas de Alumnos", query: "¿Cuáles son las notas y calificaciones de mis alumnos?" },
|
||||||
|
{ label: "📅 Hitos y Exámenes", query: "¿Cuáles son los hitos evaluativos y fechas de examen programadas?" },
|
||||||
|
{ label: "📍 Mis Comisiones", query: "¿Cuáles son mis comisiones a cargo y aulas asignadas?" }
|
||||||
|
],
|
||||||
alumno: [
|
alumno: [
|
||||||
{ label: "📍 Próxima Presencial", query: "¿Cuándo y dónde es mi próxima clase presencial?" },
|
{ label: "📍 Próxima Presencial", query: "¿Cuándo y dónde es mi próxima clase presencial?" },
|
||||||
{ label: "📊 Mis Notas", query: "¿Cuáles son mis notas, calificaciones y regularidad en mis materias?" },
|
{ label: "📊 Mis Notas", query: "¿Cuáles son mis notas, calificaciones y regularidad en mis materias?" },
|
||||||
@@ -82,15 +90,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getWelcomeMessage(role, name) {
|
function getWelcomeMessage(role, name) {
|
||||||
const greeting = name ? `¡Hola, **${name}**! 👋` : '¡Hola! 👋';
|
const greeting = name ? `¡Hola, ${name}!` : '¡Hola!';
|
||||||
if (role === 'admin') {
|
if (role === 'admin') {
|
||||||
return `${greeting} Soy **UdeCi**, tu tutor de Edu-Space para Administración y Gobierno del Sistema. ¿Qué deseas gestionar o configurar hoy?`;
|
return `${greeting} Soy **UdeCi**, tu tutor de Edu-Space para Administración y Gobierno del Sistema. ¿En qué te puedo ayudar hoy?`;
|
||||||
} else if (role === 'bedelia') {
|
} else if (role === 'bedelia') {
|
||||||
return `${greeting} Soy **UdeCi**, tu asistente de soporte técnico para Bedelía. Puedo guiarte en el circuito de 9 pasos, resolución de conflictos y Moodle.`;
|
return `${greeting} Soy **UdeCi**, tu asistente de soporte para Bedelía. Puedo orientarte en el circuito de 9 pasos, resolución de conflictos y reservas.`;
|
||||||
} else if (role === 'docente') {
|
} else if (role === 'docente') {
|
||||||
return `${greeting} Soy **UdeCi**, tu tutor de Edu-Space para docentes. Puedo orientarte sobre asignaciones de aulas, el Gradebook y tus clases asignadas.`;
|
return `${greeting} Soy **UdeCi**, tu tutor docente. Puedo orientarte sobre asignaciones de aulas, comisiones y el Libro de Calificaciones.`;
|
||||||
} else {
|
} else {
|
||||||
return `${greeting} Soy **UdeCi**, tu tutor virtual de cursada. Puedo orientarte sobre en qué aula cursas hoy, horarios y notas.`;
|
return `${greeting} Soy **UdeCi**, tu tutor virtual de cursada. Puedo orientarte sobre aulas, horarios y notas. ¿En qué te puedo ayudar?`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +120,7 @@
|
|||||||
function renderMarkdown(text) {
|
function renderMarkdown(text) {
|
||||||
if (!text) return '';
|
if (!text) return '';
|
||||||
|
|
||||||
// 1. Proteger enlaces Markdown [texto](url) antes del escape HTML
|
// Proteger enlaces Markdown [texto](url)
|
||||||
const links = [];
|
const links = [];
|
||||||
let processed = text.replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, (match, label, url) => {
|
let processed = text.replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, (match, label, url) => {
|
||||||
const idx = links.length;
|
const idx = links.length;
|
||||||
@@ -120,7 +128,7 @@
|
|||||||
return `__MD_LINK_${idx}__`;
|
return `__MD_LINK_${idx}__`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2. Proteger URLs directas https://...
|
// Proteger URLs directas https://...
|
||||||
const rawUrls = [];
|
const rawUrls = [];
|
||||||
processed = processed.replace(/(https?:\/\/[^\s<"'>)]+)/g, (match, url) => {
|
processed = processed.replace(/(https?:\/\/[^\s<"'>)]+)/g, (match, url) => {
|
||||||
const idx = rawUrls.length;
|
const idx = rawUrls.length;
|
||||||
@@ -128,40 +136,45 @@
|
|||||||
return `__RAW_URL_${idx}__`;
|
return `__RAW_URL_${idx}__`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3. Escaping HTML seguro
|
// Escaping seguro de HTML
|
||||||
let escaped = processed
|
let escaped = processed
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
.replace(/>/g, '>');
|
.replace(/>/g, '>');
|
||||||
|
|
||||||
// 4. Negrita **texto**
|
// Negrita **texto**
|
||||||
escaped = escaped.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
|
escaped = escaped.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
|
||||||
// 5. Cursiva *texto*
|
// Cursiva *texto*
|
||||||
escaped = escaped.replace(/\*(.*?)\*/g, '<em>$1</em>');
|
escaped = escaped.replace(/\*(.*?)\*/g, '<em>$1</em>');
|
||||||
// 6. Código inline `codigo`
|
// Código inline `codigo`
|
||||||
escaped = escaped.replace(/`([^`]+)`/g, '<code>$1</code>');
|
escaped = escaped.replace(/`([^`]+)`/g, '<code>$1</code>');
|
||||||
// 7. Saltos de línea
|
// Saltos de línea
|
||||||
escaped = escaped.replace(/\n/g, '<br>');
|
escaped = escaped.replace(/\n/g, '<br>');
|
||||||
|
|
||||||
// 8. Restaurar enlaces Markdown como botones/hipervínculos atractivos
|
// Restaurar enlaces Markdown como botones atractivos
|
||||||
escaped = escaped.replace(/__MD_LINK_(\d+)__/g, (match, idx) => {
|
escaped = escaped.replace(/__MD_LINK_(\d+)__/g, (match, idx) => {
|
||||||
const item = links[parseInt(idx, 10)];
|
const item = links[parseInt(idx, 10)];
|
||||||
if (!item) return '';
|
if (!item) return '';
|
||||||
return `<a href="${item.url}" target="_blank" rel="noopener noreferrer" class="ai-chat-link"><i class="bi bi-box-arrow-up-right me-1"></i>${item.label}</a>`;
|
return `<a href="${item.url}" target="_blank" rel="noopener noreferrer" class="ai-chat-link"><i class="bi bi-box-arrow-up-right me-1"></i>${item.label}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 9. Restaurar URLs directas como enlaces clickeables
|
// Restaurar URLs directas como enlaces clickeables
|
||||||
escaped = escaped.replace(/__RAW_URL_(\d+)__/g, (match, idx) => {
|
escaped = escaped.replace(/__RAW_URL_(\d+)__/g, (match, idx) => {
|
||||||
const url = rawUrls[parseInt(idx, 10)];
|
const url = rawUrls[parseInt(idx, 10)];
|
||||||
if (!url) return '';
|
if (!url) return '';
|
||||||
const displayUrl = url.length > 48 ? url.substring(0, 45) + '...' : url;
|
const displayUrl = url.length > 46 ? url.substring(0, 43) + '...' : url;
|
||||||
return `<a href="${url}" target="_blank" rel="noopener noreferrer" class="ai-chat-link"><i class="bi bi-link-45deg me-1"></i>${displayUrl}</a>`;
|
return `<a href="${url}" target="_blank" rel="noopener noreferrer" class="ai-chat-link"><i class="bi bi-link-45deg me-1"></i>${displayUrl}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendMessage(role, content, options = [], save = true) {
|
function formatCurrentTime() {
|
||||||
|
const now = new Date();
|
||||||
|
return now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function appendMessage(role, content, options = [], save = true, timeStr = null) {
|
||||||
const messagesContainer = document.getElementById('aiChatMessages');
|
const messagesContainer = document.getElementById('aiChatMessages');
|
||||||
if (!messagesContainer) return;
|
if (!messagesContainer) return;
|
||||||
|
|
||||||
@@ -169,23 +182,99 @@
|
|||||||
const msgDiv = document.createElement('div');
|
const msgDiv = document.createElement('div');
|
||||||
msgDiv.className = `ai-msg ${isUser ? 'ai-msg-user' : 'ai-msg-assistant'}`;
|
msgDiv.className = `ai-msg ${isUser ? 'ai-msg-user' : 'ai-msg-assistant'}`;
|
||||||
|
|
||||||
let html = renderMarkdown(content);
|
const formattedHtml = renderMarkdown(content);
|
||||||
|
const timestamp = timeStr || formatCurrentTime();
|
||||||
|
|
||||||
// Si es mensaje del asistente y tiene opciones, renderizar botones interactivos
|
if (isUser) {
|
||||||
if (!isUser && options && options.length > 0) {
|
msgDiv.innerHTML = `
|
||||||
html += '<div class="ai-msg-options">';
|
<div class="ai-msg-text">${formattedHtml}</div>
|
||||||
|
<span class="ai-msg-time">${timestamp}</span>
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
|
let optionsHtml = '';
|
||||||
|
if (options && options.length > 0) {
|
||||||
|
optionsHtml = '<div class="ai-msg-options">';
|
||||||
options.forEach(opt => {
|
options.forEach(opt => {
|
||||||
const cleanOpt = opt.replace(/^[📍📝👥🔄⚠️🧬📑📚📊❓]\s*/, '').trim();
|
optionsHtml += `<button type="button" class="ai-option-btn" data-query="${opt}">${opt}</button>`;
|
||||||
html += `<button type="button" class="ai-option-btn" data-query="${opt}">${opt}</button>`;
|
|
||||||
});
|
});
|
||||||
html += '</div>';
|
optionsHtml += '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
msgDiv.innerHTML = `
|
||||||
|
<div class="ai-msg-body">${formattedHtml}</div>
|
||||||
|
${optionsHtml}
|
||||||
|
<div class="ai-msg-actions">
|
||||||
|
<button type="button" class="ai-action-icon-btn copy-btn" title="Copiar respuesta" aria-label="Copiar">
|
||||||
|
<i class="bi bi-copy"></i>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="ai-action-icon-btn speak-btn" title="Escuchar en voz alta" aria-label="Escuchar">
|
||||||
|
<i class="bi bi-volume-up"></i>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="ai-action-icon-btn thumbs-up-btn" title="Respuesta útil" aria-label="Útil">
|
||||||
|
<i class="bi bi-hand-thumbs-up"></i>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="ai-action-icon-btn thumbs-down-btn" title="No me sirvió" aria-label="No útil">
|
||||||
|
<i class="bi bi-hand-thumbs-down"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Configurar botones de acción interactivos estilo Mercado Libre
|
||||||
|
const copyBtn = msgDiv.querySelector('.copy-btn');
|
||||||
|
if (copyBtn) {
|
||||||
|
copyBtn.addEventListener('click', () => {
|
||||||
|
const temp = document.createElement('div');
|
||||||
|
temp.innerHTML = formattedHtml;
|
||||||
|
const plain = temp.textContent || temp.innerText || '';
|
||||||
|
if (navigator.clipboard) {
|
||||||
|
navigator.clipboard.writeText(plain).then(() => {
|
||||||
|
copyBtn.innerHTML = '<i class="bi bi-check-lg text-success"></i>';
|
||||||
|
setTimeout(() => { copyBtn.innerHTML = '<i class="bi bi-copy"></i>'; }, 2000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const speakBtn = msgDiv.querySelector('.speak-btn');
|
||||||
|
if (speakBtn) {
|
||||||
|
speakBtn.addEventListener('click', () => {
|
||||||
|
if ('speechSynthesis' in window) {
|
||||||
|
if (window.speechSynthesis.speaking) {
|
||||||
|
window.speechSynthesis.cancel();
|
||||||
|
speakBtn.classList.remove('active');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const temp = document.createElement('div');
|
||||||
|
temp.innerHTML = formattedHtml;
|
||||||
|
const plain = temp.textContent || temp.innerText || '';
|
||||||
|
const utter = new SpeechSynthesisUtterance(plain);
|
||||||
|
utter.lang = 'es-AR';
|
||||||
|
speakBtn.classList.add('active');
|
||||||
|
utter.onend = () => speakBtn.classList.remove('active');
|
||||||
|
utter.onerror = () => speakBtn.classList.remove('active');
|
||||||
|
window.speechSynthesis.speak(utter);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const thumbsUp = msgDiv.querySelector('.thumbs-up-btn');
|
||||||
|
const thumbsDown = msgDiv.querySelector('.thumbs-down-btn');
|
||||||
|
if (thumbsUp && thumbsDown) {
|
||||||
|
thumbsUp.addEventListener('click', () => {
|
||||||
|
thumbsUp.classList.toggle('active');
|
||||||
|
thumbsDown.classList.remove('active');
|
||||||
|
});
|
||||||
|
thumbsDown.addEventListener('click', () => {
|
||||||
|
thumbsDown.classList.toggle('active');
|
||||||
|
thumbsUp.classList.remove('active');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msgDiv.innerHTML = html;
|
|
||||||
messagesContainer.appendChild(msgDiv);
|
messagesContainer.appendChild(msgDiv);
|
||||||
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
||||||
|
|
||||||
// Asignar listeners a los botones de opciones dentro de la burbuja
|
// Asignar listeners a los chips de opciones
|
||||||
msgDiv.querySelectorAll('.ai-option-btn').forEach(btn => {
|
msgDiv.querySelectorAll('.ai-option-btn').forEach(btn => {
|
||||||
btn.addEventListener('click', function (e) {
|
btn.addEventListener('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -196,7 +285,7 @@
|
|||||||
|
|
||||||
if (save) {
|
if (save) {
|
||||||
const history = loadHistory();
|
const history = loadHistory();
|
||||||
history.push({ role, content, options });
|
history.push({ role, content, options, timeStr: timestamp });
|
||||||
saveHistory(history);
|
saveHistory(history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,8 +296,11 @@
|
|||||||
const textarea = document.getElementById('aiChatInput');
|
const textarea = document.getElementById('aiChatInput');
|
||||||
const typing = document.getElementById('aiChatTyping');
|
const typing = document.getElementById('aiChatTyping');
|
||||||
const sendBtn = document.getElementById('aiChatSendBtn');
|
const sendBtn = document.getElementById('aiChatSendBtn');
|
||||||
|
const chipsDrawer = document.getElementById('aiChatQuickChips');
|
||||||
|
|
||||||
if (textarea) textarea.value = '';
|
if (textarea) textarea.value = '';
|
||||||
|
if (chipsDrawer) chipsDrawer.classList.add('d-none');
|
||||||
|
|
||||||
appendMessage('user', queryText, [], true);
|
appendMessage('user', queryText, [], true);
|
||||||
|
|
||||||
isProcessing = true;
|
isProcessing = true;
|
||||||
@@ -240,45 +332,58 @@
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await res.json();
|
if (!res.ok) {
|
||||||
if (res.ok && data.response) {
|
throw new Error(`Error HTTP ${res.status}`);
|
||||||
appendMessage('assistant', data.response, data.quick_options || [], true);
|
}
|
||||||
|
|
||||||
// Si UdeCi emite una directiva de guía interactiva, activar el Spotlight
|
const data = await res.json();
|
||||||
if (data.guide_step && window.WalkthroughEngine) {
|
const reply = data.reply || "Disculpa, no pude procesar tu solicitud en este momento.";
|
||||||
const panel = document.getElementById('aiChatPanel');
|
const options = Array.isArray(data.options) ? data.options : [];
|
||||||
const launcher = document.getElementById('aiChatLauncher');
|
appendMessage('assistant', reply, options, true);
|
||||||
if (panel && launcher) {
|
|
||||||
panel.classList.add('d-none');
|
|
||||||
launcher.style.transform = '';
|
|
||||||
launcher.classList.remove('chat-open');
|
|
||||||
document.body.classList.remove('ai-chat-mobile-open');
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
window.WalkthroughEngine.startStep(data.guide_step);
|
|
||||||
}, 250);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const errorMsg = data.detail || data.message || 'UdeCi no pudo procesar la respuesta en este momento.';
|
|
||||||
appendMessage('assistant', `⚠️ ${errorMsg}`, [], false);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
appendMessage('assistant', `⚠️ Error de comunicación: ${err.message}`, [], false);
|
console.error("[UdeCi Widget] Error al consultar API:", err);
|
||||||
|
appendMessage('assistant', "Hubo una interrupción en la conexión con el tutor inteligente. Por favor, verifica tu conexión o intenta nuevamente en unos instantes.", [], true);
|
||||||
} finally {
|
} finally {
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
if (typing) typing.classList.add('d-none');
|
if (typing) typing.classList.add('d-none');
|
||||||
if (sendBtn) sendBtn.disabled = false;
|
if (sendBtn) sendBtn.disabled = false;
|
||||||
if (textarea) textarea.focus();
|
if (textarea && window.innerWidth > 768) textarea.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function populateRoleChips() {
|
||||||
|
const chipsContainer = document.getElementById('aiRoleChipsContainer');
|
||||||
|
if (!chipsContainer || chipsContainer.children.length > 0) return;
|
||||||
|
|
||||||
|
const role = getUserRole();
|
||||||
|
const chips = ROLE_CHIPS[role] || ROLE_CHIPS.alumno;
|
||||||
|
|
||||||
|
chips.forEach(c => {
|
||||||
|
const btn = document.createElement('button');
|
||||||
|
btn.type = 'button';
|
||||||
|
btn.className = 'ai-chip-pill';
|
||||||
|
btn.textContent = c.label;
|
||||||
|
btn.setAttribute('data-query', c.query);
|
||||||
|
btn.addEventListener('click', () => {
|
||||||
|
sendQuery(c.query);
|
||||||
|
});
|
||||||
|
chipsContainer.appendChild(btn);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function initChat() {
|
function initChat() {
|
||||||
const launcher = document.getElementById('aiChatLauncher');
|
const launcher = document.getElementById('aiChatLauncher');
|
||||||
const panel = document.getElementById('aiChatPanel');
|
const panel = document.getElementById('aiChatPanel');
|
||||||
|
const backdrop = document.getElementById('aiChatBackdrop');
|
||||||
|
const backBtn = document.getElementById('aiChatBackBtn');
|
||||||
const closeBtn = document.getElementById('aiChatCloseBtn');
|
const closeBtn = document.getElementById('aiChatCloseBtn');
|
||||||
const clearBtn = document.getElementById('aiChatClearBtn');
|
const clearBtn = document.getElementById('aiChatClearBtn');
|
||||||
|
const chipsToggleBtn = document.getElementById('aiChatChipsToggleBtn');
|
||||||
|
const plusBtn = document.getElementById('aiChatPlusBtn');
|
||||||
|
const chipsDrawer = document.getElementById('aiChatQuickChips');
|
||||||
|
const closeChipsBtn = document.getElementById('aiChatCloseChipsBtn');
|
||||||
const textarea = document.getElementById('aiChatInput');
|
const textarea = document.getElementById('aiChatInput');
|
||||||
const form = document.getElementById('aiChatForm');
|
const handleBar = document.getElementById('aiSheetHandleBar');
|
||||||
|
|
||||||
if (!launcher || !panel) return;
|
if (!launcher || !panel) return;
|
||||||
|
|
||||||
@@ -287,44 +392,118 @@
|
|||||||
|
|
||||||
function openChat() {
|
function openChat() {
|
||||||
panel.classList.remove('d-none');
|
panel.classList.remove('d-none');
|
||||||
launcher.style.transform = 'scale(0.9)';
|
if (backdrop) backdrop.classList.remove('d-none');
|
||||||
launcher.classList.add('chat-open');
|
launcher.classList.add('chat-open');
|
||||||
|
|
||||||
if (window.innerWidth <= 768) {
|
if (window.innerWidth <= 768) {
|
||||||
document.body.classList.add('ai-chat-mobile-open');
|
document.body.classList.add('ai-chat-mobile-open');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
populateRoleChips();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (textarea) textarea.focus();
|
const messagesContainer = document.getElementById('aiChatMessages');
|
||||||
|
if (messagesContainer) messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
||||||
|
if (textarea && window.innerWidth > 768) textarea.focus();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeChat() {
|
function closeChat() {
|
||||||
panel.classList.add('d-none');
|
panel.classList.add('d-none');
|
||||||
launcher.style.transform = '';
|
if (backdrop) backdrop.classList.add('d-none');
|
||||||
launcher.classList.remove('chat-open');
|
launcher.classList.remove('chat-open');
|
||||||
document.body.classList.remove('ai-chat-mobile-open');
|
document.body.classList.remove('ai-chat-mobile-open');
|
||||||
|
|
||||||
|
if (chipsDrawer) chipsDrawer.classList.add('d-none');
|
||||||
|
if ('speechSynthesis' in window && window.speechSynthesis.speaking) {
|
||||||
|
window.speechSynthesis.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restaurar transform o estilos modificados por gestos
|
||||||
|
panel.style.transform = '';
|
||||||
|
panel.style.height = '';
|
||||||
|
panel.style.bottom = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle panel
|
// Toggle panel
|
||||||
launcher.addEventListener('click', () => {
|
launcher.addEventListener('click', () => {
|
||||||
const isHidden = panel.classList.contains('d-none');
|
const isHidden = panel.classList.contains('d-none');
|
||||||
if (isHidden) {
|
if (isHidden) openChat(); else closeChat();
|
||||||
openChat();
|
|
||||||
} else {
|
|
||||||
closeChat();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (closeBtn) {
|
if (backBtn) backBtn.addEventListener('click', closeChat);
|
||||||
closeBtn.addEventListener('click', closeChat);
|
if (closeBtn) closeBtn.addEventListener('click', closeChat);
|
||||||
|
if (backdrop) backdrop.addEventListener('click', closeChat);
|
||||||
|
|
||||||
|
// Deslizar hacia abajo en la drag handle bar para cerrar (Touch Gesture)
|
||||||
|
if (handleBar) {
|
||||||
|
handleBar.addEventListener('touchstart', (e) => {
|
||||||
|
touchStartY = e.touches[0].clientY;
|
||||||
|
touchDeltaY = 0;
|
||||||
|
}, { passive: true });
|
||||||
|
|
||||||
|
handleBar.addEventListener('touchmove', (e) => {
|
||||||
|
touchDeltaY = e.touches[0].clientY - touchStartY;
|
||||||
|
if (touchDeltaY > 0) {
|
||||||
|
panel.style.transform = `translateY(${touchDeltaY}px)`;
|
||||||
|
}
|
||||||
|
}, { passive: true });
|
||||||
|
|
||||||
|
handleBar.addEventListener('touchend', () => {
|
||||||
|
if (touchDeltaY > 65) {
|
||||||
|
closeChat();
|
||||||
|
} else {
|
||||||
|
panel.style.transform = '';
|
||||||
|
}
|
||||||
|
touchDeltaY = 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Drawer de consultas rápidas (+)
|
||||||
|
function toggleChips() {
|
||||||
|
if (!chipsDrawer) return;
|
||||||
|
populateRoleChips();
|
||||||
|
chipsDrawer.classList.toggle('d-none');
|
||||||
|
}
|
||||||
|
if (plusBtn) plusBtn.addEventListener('click', toggleChips);
|
||||||
|
if (chipsToggleBtn) chipsToggleBtn.addEventListener('click', toggleChips);
|
||||||
|
if (closeChipsBtn) closeChipsBtn.addEventListener('click', () => {
|
||||||
|
chipsDrawer.classList.add('d-none');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Manejo del Teclado Virtual en Dispositivos Móviles (visualViewport)
|
||||||
|
if (window.visualViewport) {
|
||||||
|
window.visualViewport.addEventListener('resize', () => {
|
||||||
|
if (window.innerWidth <= 768 && !panel.classList.contains('d-none')) {
|
||||||
|
const currentViewHeight = window.visualViewport.height;
|
||||||
|
const screenHeight = window.innerHeight;
|
||||||
|
|
||||||
|
// Si la altura del viewport se reduce significativamente (teclado abierto)
|
||||||
|
if (currentViewHeight < screenHeight * 0.88) {
|
||||||
|
panel.style.height = `${currentViewHeight}px`;
|
||||||
|
panel.style.bottom = `${Math.max(0, screenHeight - currentViewHeight - (window.visualViewport.offsetTop || 0))}px`;
|
||||||
|
} else {
|
||||||
|
// Teclado cerrado
|
||||||
|
panel.style.height = '';
|
||||||
|
panel.style.bottom = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const messagesContainer = document.getElementById('aiChatMessages');
|
||||||
|
if (messagesContainer) {
|
||||||
|
messagesContainer.scrollTop = messagesContainer.scrollHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escape para cerrar
|
||||||
document.addEventListener('keydown', (e) => {
|
document.addEventListener('keydown', (e) => {
|
||||||
if (e.key === 'Escape' && panel && !panel.classList.contains('d-none')) {
|
if (e.key === 'Escape' && panel && !panel.classList.contains('d-none')) {
|
||||||
closeChat();
|
closeChat();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reiniciar conversación del usuario actual
|
// Reiniciar conversación
|
||||||
if (clearBtn) {
|
if (clearBtn) {
|
||||||
clearBtn.addEventListener('click', () => {
|
clearBtn.addEventListener('click', () => {
|
||||||
sessionStorage.removeItem(getStorageKey());
|
sessionStorage.removeItem(getStorageKey());
|
||||||
@@ -334,20 +513,20 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cargar historial previo o mensaje de bienvenida
|
// Cargar historial previo o bienvenida
|
||||||
const history = loadHistory();
|
const history = loadHistory();
|
||||||
if (history.length > 0) {
|
if (history.length > 0) {
|
||||||
history.forEach(msg => appendMessage(msg.role, msg.content, msg.options || [], false));
|
history.forEach(msg => appendMessage(msg.role, msg.content, msg.options || [], false, msg.timeStr));
|
||||||
} else {
|
} else {
|
||||||
appendMessage('assistant', getWelcomeMessage(role, name), [], false);
|
appendMessage('assistant', getWelcomeMessage(role, name), [], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Atajo Enter para enviar
|
// Atajo Enter en desktop
|
||||||
if (textarea) {
|
if (textarea) {
|
||||||
textarea.addEventListener('keydown', (e) => {
|
textarea.addEventListener('keydown', (e) => {
|
||||||
if (e.key === 'Enter' && !e.shiftKey) {
|
if (e.key === 'Enter' && !e.shiftKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (form) form.dispatchEvent(new Event('submit', { cancelable: true }));
|
window.handleAiChatSubmit(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -86,9 +86,9 @@ const env = nunjucks.configure(path.join(__dirname, '../views'), {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Versiones institucionales del sistema
|
// Versiones institucionales del sistema
|
||||||
const APP_VERSION = '3.8.35';
|
const APP_VERSION = '3.8.36';
|
||||||
const FRONTEND_VERSION = '3.8.35';
|
const FRONTEND_VERSION = '3.8.36';
|
||||||
const BACKEND_VERSION = '3.8.35';
|
const BACKEND_VERSION = '3.8.36';
|
||||||
|
|
||||||
env.addGlobal('app_version', APP_VERSION);
|
env.addGlobal('app_version', APP_VERSION);
|
||||||
env.addGlobal('frontend_version', FRONTEND_VERSION);
|
env.addGlobal('frontend_version', FRONTEND_VERSION);
|
||||||
|
|||||||
@@ -4,53 +4,84 @@
|
|||||||
{% set current_user_name = active_auth_user.first_name if (active_auth_user and active_auth_user.first_name) else (active_auth_user.name if active_auth_user else '') %}
|
{% set current_user_name = active_auth_user.first_name if (active_auth_user and active_auth_user.first_name) else (active_auth_user.name if active_auth_user else '') %}
|
||||||
{% set current_role_name = (active_auth_user.role if active_auth_user and active_auth_user.role else 'alumno') | lower %}
|
{% set current_role_name = (active_auth_user.role if active_auth_user and active_auth_user.role else 'alumno') | lower %}
|
||||||
<!-- ===================================================== -->
|
<!-- ===================================================== -->
|
||||||
<!-- WIDGET FLOTANTE: UdeCi - TUTOR VIRTUAL UNICABA -->
|
<!-- WIDGET UdeCi: TUTOR VIRTUAL UNICABA (UX ESTILO MELI) -->
|
||||||
<!-- SDD-010: Arquitectura RAG y Asistencia Contextual -->
|
<!-- Bottom Sheet Nativo en Móvil + Input Dock Inteligente -->
|
||||||
<!-- ===================================================== -->
|
<!-- ===================================================== -->
|
||||||
|
|
||||||
|
<!-- Backdrop de Bloqueo en Móvil -->
|
||||||
|
<div id="aiChatBackdrop" class="ai-chat-backdrop d-none" aria-hidden="true"></div>
|
||||||
|
|
||||||
<div id="aiChatContainer" class="ai-chat-container"
|
<div id="aiChatContainer" class="ai-chat-container"
|
||||||
data-user-id="{{ current_user_id }}"
|
data-user-id="{{ current_user_id }}"
|
||||||
data-user-email="{{ current_user_email }}"
|
data-user-email="{{ current_user_email }}"
|
||||||
data-user-name="{{ current_user_name }}"
|
data-user-name="{{ current_user_name }}"
|
||||||
data-user-role="{{ current_role_name }}">
|
data-user-role="{{ current_role_name }}">
|
||||||
|
|
||||||
<!-- Botón Lanzador Flotante -->
|
<!-- Botón Lanzador Flotante -->
|
||||||
<button id="aiChatLauncher" class="ai-chat-launcher btn shadow-lg" type="button" aria-label="Abrir UdeCi" title="UdeCi - Tutor Virtual UniCABA">
|
<button id="aiChatLauncher" class="ai-chat-launcher btn shadow-lg" type="button" aria-label="Abrir tutor UdeCi" title="UdeCi - Tutor Virtual UniCABA">
|
||||||
<span class="ai-launcher-icon"><i class="bi bi-chat-heart-fill"></i></span>
|
<span class="ai-launcher-icon"><i class="bi bi-stars"></i></span>
|
||||||
<span class="ai-launcher-badge pulse-dot"></span>
|
<span class="ai-launcher-badge pulse-dot"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<!-- Panel de Conversación -->
|
<!-- Panel de Conversación (Bottom Sheet en Móvil / Ventana Flotante en Desktop) -->
|
||||||
<div id="aiChatPanel" class="ai-chat-panel card shadow-lg border-0 d-none" role="dialog" aria-modal="true" aria-labelledby="aiChatTitle">
|
<div id="aiChatPanel" class="ai-chat-panel card border-0 d-none" role="dialog" aria-modal="true" aria-labelledby="aiChatTitle">
|
||||||
<!-- Cabecera Limpia e Institucional de UdeCi -->
|
|
||||||
<div class="card-header ai-chat-header d-flex align-items-center justify-content-between p-3 border-bottom">
|
<!-- Drag Handle Superior (Estilo Nativo Móvil) -->
|
||||||
<div class="d-flex align-items-center gap-2 overflow-hidden">
|
<div class="ai-sheet-handle-bar" id="aiSheetHandleBar" title="Desliza para cerrar">
|
||||||
<div class="ai-avatar-circle">
|
<span class="ai-sheet-handle"></span>
|
||||||
<i class="bi bi-mortarboard-fill text-white"></i>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="lh-sm text-truncate">
|
|
||||||
<div class="d-flex align-items-center gap-2">
|
<!-- Cabecera de Navegación y Acciones -->
|
||||||
<h6 class="mb-0 fw-bold text-white" id="aiChatTitle">UdeCi</h6>
|
<div class="ai-chat-header d-flex align-items-center justify-content-between px-3 pt-1 pb-2">
|
||||||
<span class="badge bg-white text-primary fw-semibold rounded-pill px-2 py-0" style="font-size: 0.68rem;">Tutor Virtual</span>
|
<!-- Botón de Retroceso / Minimizar (Móvil & Desktop) -->
|
||||||
</div>
|
<button type="button" class="ai-btn-circle" id="aiChatBackBtn" title="Cerrar asistente" aria-label="Volver">
|
||||||
<small class="text-white-50 d-flex align-items-center gap-1 mt-1" style="font-size: 0.73rem;">
|
<i class="bi bi-chevron-left fs-6"></i>
|
||||||
<span class="status-indicator-dot"></span>
|
|
||||||
<span>UniCABA • En línea</span>
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex align-items-center gap-1">
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-light border-0 py-1 px-2" id="aiChatClearBtn" title="Reiniciar chat">
|
|
||||||
<i class="bi bi-arrow-clockwise"></i>
|
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-sm btn-outline-light border-0 py-1 px-2" id="aiChatCloseBtn" title="Cerrar">
|
|
||||||
<i class="bi bi-x-lg"></i>
|
<!-- Título Central con Ícono IA -->
|
||||||
|
<div class="d-flex align-items-center gap-2 text-center overflow-hidden">
|
||||||
|
<div class="ai-header-sparkle-badge">
|
||||||
|
<i class="bi bi-stars"></i>
|
||||||
|
</div>
|
||||||
|
<div class="lh-1 text-truncate">
|
||||||
|
<h6 class="mb-0 fw-bold ai-header-title text-truncate" id="aiChatTitle">UdeCi</h6>
|
||||||
|
<small class="ai-header-subtitle">Tutor Virtual UniCABA</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Botones de Acción Derecha: Nuevo Chat + Opciones + Cerrar -->
|
||||||
|
<div class="d-flex align-items-center gap-1">
|
||||||
|
<button type="button" class="ai-btn-circle" id="aiChatClearBtn" title="Nueva conversación" aria-label="Nueva conversación">
|
||||||
|
<i class="bi bi-pencil-square fs-6"></i>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="ai-btn-circle" id="aiChatChipsToggleBtn" title="Temas de ayuda" aria-label="Temas sugeridos">
|
||||||
|
<i class="bi bi-sliders fs-6"></i>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="ai-btn-circle d-none d-md-inline-flex" id="aiChatCloseBtn" title="Cerrar ventana" aria-label="Cerrar">
|
||||||
|
<i class="bi bi-x-lg fs-6"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Área de Mensajes -->
|
<!-- Subtítulo / Disclaimer Institucional (Estilo Mercado Libre) -->
|
||||||
<div class="card-body ai-chat-messages p-3" id="aiChatMessages" tabindex="0">
|
<div class="ai-chat-disclaimer px-3 py-1">
|
||||||
<!-- Mensaje de bienvenida inicial y conversación -->
|
<small class="text-muted d-block text-center">UdeCi usa inteligencia artificial para responderte.</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Panel Desplegable de Temas / Sugerencias Rápidas (+) -->
|
||||||
|
<div id="aiChatQuickChips" class="ai-quick-chips-drawer d-none px-3 py-2 border-bottom">
|
||||||
|
<div class="d-flex align-items-center justify-content-between mb-1">
|
||||||
|
<span class="small fw-semibold text-muted text-uppercase" style="font-size:0.68rem; letter-spacing:0.05em;">Consultas Rápidas</span>
|
||||||
|
<button type="button" class="btn-close btn-close-sm" id="aiChatCloseChipsBtn" aria-label="Ocultar"></button>
|
||||||
|
</div>
|
||||||
|
<div class="ai-chips-container d-flex flex-wrap gap-1" id="aiRoleChipsContainer">
|
||||||
|
<!-- Se inyectan dinámicamente según el rol -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Área de Conversación (Mensajes) -->
|
||||||
|
<div class="ai-chat-messages px-3 py-2" id="aiChatMessages" tabindex="0">
|
||||||
|
<!-- Conversación generada dinámicamente -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Indicador de Respuesta en Progreso -->
|
<!-- Indicador de Respuesta en Progreso -->
|
||||||
@@ -63,32 +94,58 @@
|
|||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Área de Entrada / Envío -->
|
<!-- Dock de Entrada (Input estilo Mercado Libre) -->
|
||||||
<div class="card-footer ai-chat-footer p-2 border-top">
|
<div class="ai-chat-footer px-3 py-2" id="aiChatFooter">
|
||||||
<form id="aiChatForm" class="d-flex align-items-center gap-2 m-0" onsubmit="handleAiChatSubmit(event)">
|
<form id="aiChatForm" class="m-0" onsubmit="handleAiChatSubmit(event)">
|
||||||
<textarea id="aiChatInput" class="form-control form-control-sm ai-chat-textarea"
|
<div class="ai-input-pill-container d-flex align-items-center gap-2">
|
||||||
rows="1"
|
<!-- Botón + para abrir atajos rápidos -->
|
||||||
placeholder="Escribe tu consulta aquí..."
|
<button type="button" class="ai-input-plus-btn" id="aiChatPlusBtn" title="Consultas rápidas" aria-label="Abrir temas">
|
||||||
aria-label="Mensaje para UdeCi"></textarea>
|
<i class="bi bi-plus-lg"></i>
|
||||||
<button type="submit" class="btn btn-primary btn-sm rounded-circle ai-send-btn" id="aiChatSendBtn" title="Enviar consulta">
|
|
||||||
<i class="bi bi-send-fill"></i>
|
|
||||||
</button>
|
</button>
|
||||||
|
<!-- Campo de texto autorregulable -->
|
||||||
|
<textarea id="aiChatInput" class="form-control ai-chat-textarea border-0 shadow-none p-0"
|
||||||
|
rows="1"
|
||||||
|
placeholder="Pregúntame"
|
||||||
|
aria-label="Mensaje para UdeCi"></textarea>
|
||||||
|
<!-- Botón Enviar con ícono elevado -->
|
||||||
|
<button type="submit" class="ai-send-btn" id="aiChatSendBtn" title="Enviar consulta" aria-label="Enviar">
|
||||||
|
<i class="bi bi-arrow-up-circle-fill fs-4"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Contenedor Flotante */
|
/* ==============================================================
|
||||||
|
ESTILOS BASE: WIDGET UdeCi CON ESTÉTICA MERCADO LIBRE
|
||||||
|
============================================================== */
|
||||||
|
|
||||||
|
/* Backdrop para Móvil */
|
||||||
|
.ai-chat-backdrop {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(15, 23, 42, 0.55);
|
||||||
|
backdrop-filter: blur(3px);
|
||||||
|
-webkit-backdrop-filter: blur(3px);
|
||||||
|
z-index: 1065;
|
||||||
|
transition: opacity 0.25s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Contenedor Flotante Principal */
|
||||||
.ai-chat-container {
|
.ai-chat-container {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 24px;
|
bottom: 24px;
|
||||||
right: 24px;
|
right: 24px;
|
||||||
z-index: 1060;
|
z-index: 1070;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Botón Lanzador */
|
/* Botón Lanzador Flotante (Desktop y estado cerrado) */
|
||||||
.ai-chat-launcher {
|
.ai-chat-launcher {
|
||||||
width: 56px;
|
width: 56px;
|
||||||
height: 56px;
|
height: 56px;
|
||||||
@@ -109,7 +166,7 @@
|
|||||||
box-shadow: 0 12px 30px rgba(180, 62, 142, 0.5) !important;
|
box-shadow: 0 12px 30px rgba(180, 62, 142, 0.5) !important;
|
||||||
}
|
}
|
||||||
.ai-launcher-icon {
|
.ai-launcher-icon {
|
||||||
font-size: 1.55rem;
|
font-size: 1.45rem;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
||||||
.pulse-dot {
|
.pulse-dot {
|
||||||
@@ -130,212 +187,226 @@
|
|||||||
100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
|
100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Panel de Conversación */
|
/* ==============================================================
|
||||||
|
PANEL DE CONVERSACIÓN: DESKTOP
|
||||||
|
============================================================== */
|
||||||
.ai-chat-panel {
|
.ai-chat-panel {
|
||||||
width: 380px;
|
width: 400px;
|
||||||
max-width: calc(100vw - 32px);
|
max-width: calc(100vw - 32px);
|
||||||
height: 520px;
|
height: 560px;
|
||||||
max-height: calc(100vh - 90px);
|
max-height: calc(100vh - 90px);
|
||||||
border-radius: 18px !important;
|
border-radius: 24px !important;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35) !important;
|
||||||
animation: aiSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
animation: aiSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
||||||
box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45) !important;
|
background: #ffffff;
|
||||||
backdrop-filter: none !important;
|
border: 1px solid rgba(180, 62, 142, 0.2) !important;
|
||||||
-webkit-backdrop-filter: none !important;
|
z-index: 1075;
|
||||||
opacity: 1 !important;
|
|
||||||
}
|
}
|
||||||
@keyframes aiSlideUp {
|
@keyframes aiSlideUp {
|
||||||
from { opacity: 0; transform: translateY(16px) scale(0.97); }
|
from { opacity: 0; transform: translateY(16px) scale(0.97); }
|
||||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modo Oscuro 100% Sólido y Opaco (Cero Transparencia) */
|
/* Ocultar handle bar en desktop */
|
||||||
[data-bs-theme="dark"] .ai-chat-panel,
|
.ai-sheet-handle-bar {
|
||||||
[data-bs-theme="dark"] #aiChatPanel {
|
display: none;
|
||||||
background-color: #0f172a !important;
|
width: 100%;
|
||||||
background: #0f172a !important;
|
text-align: center;
|
||||||
border: 1px solid #334155 !important;
|
padding: 8px 0 2px 0;
|
||||||
opacity: 1 !important;
|
cursor: grab;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
[data-bs-theme="dark"] .ai-chat-header {
|
.ai-sheet-handle {
|
||||||
background-color: #1e293b !important;
|
display: inline-block;
|
||||||
background: #1e293b !important;
|
width: 40px;
|
||||||
border-bottom: 1px solid #334155 !important;
|
height: 4px;
|
||||||
}
|
background: rgba(100, 116, 139, 0.35);
|
||||||
[data-bs-theme="dark"] .ai-chat-messages,
|
border-radius: 4px;
|
||||||
[data-bs-theme="dark"] #aiChatMessages {
|
|
||||||
background-color: #0f172a !important;
|
|
||||||
background: #0f172a !important;
|
|
||||||
opacity: 1 !important;
|
|
||||||
}
|
|
||||||
[data-bs-theme="dark"] .ai-chat-footer {
|
|
||||||
background-color: #1e293b !important;
|
|
||||||
background: #1e293b !important;
|
|
||||||
border-top: 1px solid #334155 !important;
|
|
||||||
}
|
|
||||||
[data-bs-theme="dark"] .ai-chat-textarea {
|
|
||||||
background-color: #0f172a !important;
|
|
||||||
color: #f8fafc !important;
|
|
||||||
border: 1px solid #475569 !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modo Claro 100% Sólido y Opaco */
|
/* Cabecera Estilo Mercado Libre */
|
||||||
[data-bs-theme="light"] .ai-chat-panel,
|
.ai-chat-header {
|
||||||
[data-bs-theme="light"] #aiChatPanel {
|
background: #ffffff;
|
||||||
background-color: #ffffff !important;
|
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
background: #ffffff !important;
|
|
||||||
border: 1px solid rgba(180, 62, 142, 0.25) !important;
|
|
||||||
opacity: 1 !important;
|
|
||||||
}
|
}
|
||||||
[data-bs-theme="light"] .ai-chat-header {
|
.ai-header-title {
|
||||||
background: linear-gradient(135deg, #B43E8E 0%, #8A256B 100%) !important;
|
color: #0F172A;
|
||||||
border-bottom: 1px solid rgba(180, 62, 142, 0.2) !important;
|
font-size: 0.98rem;
|
||||||
}
|
}
|
||||||
[data-bs-theme="light"] .ai-chat-messages,
|
.ai-header-subtitle {
|
||||||
[data-bs-theme="light"] #aiChatMessages {
|
font-size: 0.72rem;
|
||||||
background-color: #FAF5F8 !important;
|
color: #64748B;
|
||||||
background: #FAF5F8 !important;
|
|
||||||
opacity: 1 !important;
|
|
||||||
}
|
}
|
||||||
[data-bs-theme="light"] .ai-chat-footer {
|
.ai-header-sparkle-badge {
|
||||||
background-color: #ffffff !important;
|
width: 32px;
|
||||||
background: #ffffff !important;
|
height: 32px;
|
||||||
border-top: 1px solid rgba(180, 62, 142, 0.2) !important;
|
|
||||||
}
|
|
||||||
[data-bs-theme="light"] .ai-chat-textarea {
|
|
||||||
background-color: #ffffff !important;
|
|
||||||
color: #1e293b !important;
|
|
||||||
border: 1px solid #cbd5e1 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ai-avatar-circle {
|
|
||||||
width: 36px;
|
|
||||||
height: 36px;
|
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: rgba(255, 255, 255, 0.25);
|
background: linear-gradient(135deg, rgba(180, 62, 142, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
|
||||||
|
color: #B43E8E;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-size: 1.15rem;
|
font-size: 1.05rem;
|
||||||
}
|
|
||||||
.status-indicator-dot {
|
|
||||||
display: inline-block;
|
|
||||||
width: 7px;
|
|
||||||
height: 7px;
|
|
||||||
background-color: #22c55e;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mensajes */
|
/* Botones Circulares del Header */
|
||||||
|
.ai-btn-circle {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
background: rgba(241, 245, 249, 0.85);
|
||||||
|
color: #334155;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.18s ease;
|
||||||
|
}
|
||||||
|
.ai-btn-circle:hover {
|
||||||
|
background: rgba(226, 232, 240, 1);
|
||||||
|
color: #0F172A;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Disclaimer Institucional */
|
||||||
|
.ai-chat-disclaimer {
|
||||||
|
background: rgba(248, 250, 252, 0.85);
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
.ai-chat-disclaimer small {
|
||||||
|
font-size: 0.73rem;
|
||||||
|
color: #64748B !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Drawer de Chips / Consultas Rápidas */
|
||||||
|
.ai-quick-chips-drawer {
|
||||||
|
background: #F8FAFC;
|
||||||
|
max-height: 180px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.ai-chip-pill {
|
||||||
|
font-size: 0.76rem;
|
||||||
|
padding: 5px 12px;
|
||||||
|
border-radius: 20px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
border: 1px solid #CBD5E1;
|
||||||
|
color: #1E293B;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.ai-chip-pill:hover {
|
||||||
|
background: #B43E8E;
|
||||||
|
border-color: #B43E8E;
|
||||||
|
color: #FFFFFF;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Área de Mensajes */
|
||||||
.ai-chat-messages {
|
.ai-chat-messages {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 14px;
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
|
background: #FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mensajes Estilo Mercado Libre */
|
||||||
.ai-msg {
|
.ai-msg {
|
||||||
max-width: 86%;
|
max-width: 88%;
|
||||||
padding: 9px 13px;
|
|
||||||
border-radius: 14px;
|
|
||||||
font-size: 0.86rem;
|
|
||||||
line-height: 1.45;
|
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
|
font-size: 0.92rem;
|
||||||
|
line-height: 1.48;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mensaje del Usuario: Cápsula suave a la derecha con hora */
|
||||||
.ai-msg-user {
|
.ai-msg-user {
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
background-color: #0d6efd;
|
background: #F1F5F9;
|
||||||
color: #ffffff;
|
color: #0F172A;
|
||||||
border-bottom-right-radius: 3px;
|
padding: 9px 14px 6px 14px;
|
||||||
|
border-radius: 20px 20px 4px 20px;
|
||||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
||||||
}
|
}
|
||||||
|
.ai-msg-user .ai-msg-time {
|
||||||
|
font-size: 0.68rem;
|
||||||
|
color: #94A3B8;
|
||||||
|
text-align: right;
|
||||||
|
margin-top: 3px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mensaje del Asistente (UdeCi): Lienzo limpio sin caja pesada */
|
||||||
.ai-msg-assistant {
|
.ai-msg-assistant {
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
border-bottom-left-radius: 3px;
|
color: #0F172A;
|
||||||
|
padding: 2px 4px;
|
||||||
|
background: transparent;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
[data-bs-theme="dark"] .ai-msg-assistant {
|
.ai-msg-assistant p:last-child {
|
||||||
background-color: #1e293b;
|
margin-bottom: 0;
|
||||||
color: #f8fafc;
|
|
||||||
border: 1px solid #334155;
|
|
||||||
}
|
|
||||||
[data-bs-theme="light"] .ai-msg-assistant {
|
|
||||||
background-color: #f8fafc;
|
|
||||||
color: #0f172a;
|
|
||||||
border: 1px solid #e2e8f0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hipervínculos e Integraciones en los Mensajes */
|
/* Fila de Acciones debajo de la respuesta de UdeCi (Copiar, Audio, Feedback) */
|
||||||
.ai-chat-link {
|
.ai-msg-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 8px;
|
||||||
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
.ai-action-icon-btn {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: #94A3B8;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 3px 5px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
border-radius: 6px;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
justify-content: center;
|
||||||
padding: 4px 10px;
|
transition: all 0.15s ease;
|
||||||
margin: 4px 0;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 0.81rem;
|
|
||||||
font-weight: 500;
|
|
||||||
text-decoration: none !important;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
}
|
||||||
[data-bs-theme="light"] .ai-chat-link {
|
.ai-action-icon-btn:hover {
|
||||||
background-color: rgba(13, 110, 253, 0.08);
|
color: #0F172A;
|
||||||
color: #0d6efd;
|
background: rgba(0, 0, 0, 0.05);
|
||||||
border: 1px solid rgba(13, 110, 253, 0.25);
|
|
||||||
}
|
}
|
||||||
[data-bs-theme="light"] .ai-chat-link:hover {
|
.ai-action-icon-btn.active {
|
||||||
background-color: #0d6efd;
|
color: #B43E8E;
|
||||||
color: #ffffff !important;
|
|
||||||
transform: translateY(-1px);
|
|
||||||
box-shadow: 0 2px 6px rgba(13, 110, 253, 0.25);
|
|
||||||
}
|
|
||||||
[data-bs-theme="dark"] .ai-chat-link {
|
|
||||||
background-color: rgba(56, 189, 248, 0.12);
|
|
||||||
color: #38bdf8;
|
|
||||||
border: 1px solid rgba(56, 189, 248, 0.3);
|
|
||||||
}
|
|
||||||
[data-bs-theme="dark"] .ai-chat-link:hover {
|
|
||||||
background-color: #38bdf8;
|
|
||||||
color: #0f172a !important;
|
|
||||||
transform: translateY(-1px);
|
|
||||||
box-shadow: 0 2px 6px rgba(56, 189, 248, 0.3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Botones de sugerencias debajo de la respuesta */
|
/* Opciones / Chips sugeridos en la respuesta */
|
||||||
.ai-msg-options {
|
.ai-msg-options {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
margin-top: 8px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
.ai-option-btn {
|
.ai-option-btn {
|
||||||
font-size: 0.74rem;
|
font-size: 0.78rem;
|
||||||
padding: 3px 9px;
|
padding: 5px 12px;
|
||||||
border-radius: 12px;
|
border-radius: 18px;
|
||||||
background-color: rgba(13, 110, 253, 0.08);
|
background-color: #FFFFFF;
|
||||||
border: 1px solid rgba(13, 110, 253, 0.25);
|
border: 1px solid #CBD5E1;
|
||||||
color: #0d6efd;
|
color: #0F172A;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.15s ease;
|
transition: all 0.15s ease;
|
||||||
}
|
font-weight: 500;
|
||||||
[data-bs-theme="dark"] .ai-option-btn {
|
|
||||||
background-color: rgba(56, 189, 248, 0.1);
|
|
||||||
border-color: rgba(56, 189, 248, 0.3);
|
|
||||||
color: #38bdf8;
|
|
||||||
}
|
}
|
||||||
.ai-option-btn:hover {
|
.ai-option-btn:hover {
|
||||||
background-color: #0d6efd;
|
background-color: rgba(180, 62, 142, 0.1);
|
||||||
color: #ffffff;
|
border-color: #B43E8E;
|
||||||
border-color: #0d6efd;
|
color: #8C256B;
|
||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
[data-bs-theme="dark"] .ai-option-btn:hover {
|
|
||||||
background-color: #38bdf8;
|
|
||||||
color: #0f172a;
|
|
||||||
border-color: #38bdf8;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Indicador de Escritura */
|
/* Indicador de Escritura */
|
||||||
.ai-typing-indicator .typing-dot {
|
.ai-typing-indicator .typing-dot {
|
||||||
@@ -353,81 +424,271 @@
|
|||||||
40% { transform: scale(1.1); opacity: 1; }
|
40% { transform: scale(1.1); opacity: 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Textarea y Botón */
|
/* Dock de Entrada / Input Pill (Estilo Meli) */
|
||||||
.ai-chat-textarea {
|
.ai-chat-footer {
|
||||||
resize: none;
|
background: #ffffff;
|
||||||
border-radius: 18px;
|
border-top: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
padding-left: 12px;
|
position: relative;
|
||||||
padding-right: 12px;
|
z-index: 2;
|
||||||
max-height: 75px;
|
|
||||||
}
|
}
|
||||||
.ai-send-btn {
|
.ai-input-pill-container {
|
||||||
width: 36px;
|
background: #FFFFFF;
|
||||||
height: 36px;
|
border: 1px solid #CBD5E1;
|
||||||
flex-shrink: 0;
|
border-radius: 28px;
|
||||||
display: flex;
|
padding: 6px 8px 6px 12px;
|
||||||
|
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
.ai-input-pill-container:focus-within {
|
||||||
|
border-color: #B43E8E;
|
||||||
|
box-shadow: 0 0 0 3px rgba(180, 62, 142, 0.15);
|
||||||
|
}
|
||||||
|
.ai-input-plus-btn {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: none;
|
||||||
|
background: #F1F5F9;
|
||||||
|
color: #475569;
|
||||||
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
.ai-input-plus-btn:hover {
|
||||||
|
background: #E2E8F0;
|
||||||
|
color: #0F172A;
|
||||||
|
}
|
||||||
|
.ai-chat-textarea {
|
||||||
|
background: transparent !important;
|
||||||
|
resize: none;
|
||||||
|
max-height: 80px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: #0F172A;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
.ai-chat-textarea::placeholder {
|
||||||
|
color: #94A3B8;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
.ai-send-btn {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: #B43E8E;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
transition: transform 0.15s ease, color 0.15s ease;
|
||||||
|
}
|
||||||
|
.ai-send-btn:hover {
|
||||||
|
color: #8C256B;
|
||||||
|
transform: scale(1.08);
|
||||||
|
}
|
||||||
|
.ai-send-btn:disabled {
|
||||||
|
color: #CBD5E1;
|
||||||
|
cursor: not-allowed;
|
||||||
|
transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ==============================================================
|
||||||
|
TEMA OSCURO ([data-bs-theme="dark"])
|
||||||
|
============================================================== */
|
||||||
|
[data-bs-theme="dark"] .ai-chat-panel {
|
||||||
|
background: #0F172A;
|
||||||
|
border-color: #334155 !important;
|
||||||
|
box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6) !important;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-chat-header {
|
||||||
|
background: #0F172A;
|
||||||
|
border-bottom-color: #1E293B;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-header-title {
|
||||||
|
color: #F8FAFC;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-header-subtitle {
|
||||||
|
color: #94A3B8;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-header-sparkle-badge {
|
||||||
|
background: rgba(255, 138, 182, 0.18);
|
||||||
|
color: #FF8AB6;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-btn-circle {
|
||||||
|
background: #1E293B;
|
||||||
|
color: #CBD5E1;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-btn-circle:hover {
|
||||||
|
background: #334155;
|
||||||
|
color: #F8FAFC;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-chat-disclaimer {
|
||||||
|
background: #131D31;
|
||||||
|
border-bottom-color: #1E293B;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-chat-disclaimer small {
|
||||||
|
color: #94A3B8 !important;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-quick-chips-drawer {
|
||||||
|
background: #131D31;
|
||||||
|
border-bottom-color: #1E293B;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-chip-pill {
|
||||||
|
background: #1E293B;
|
||||||
|
border-color: #334155;
|
||||||
|
color: #F8FAFC;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-chip-pill:hover {
|
||||||
|
background: #B43E8E;
|
||||||
|
border-color: #B43E8E;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-chat-messages {
|
||||||
|
background: #0F172A;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-msg-user {
|
||||||
|
background: #1E293B;
|
||||||
|
color: #F8FAFC;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-msg-assistant {
|
||||||
|
color: #F8FAFC;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-action-icon-btn:hover {
|
||||||
|
color: #F8FAFC;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-option-btn {
|
||||||
|
background: #1E293B;
|
||||||
|
border-color: #334155;
|
||||||
|
color: #F8FAFC;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-option-btn:hover {
|
||||||
|
background: rgba(255, 138, 182, 0.2);
|
||||||
|
border-color: #FF8AB6;
|
||||||
|
color: #FF8AB6;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-chat-footer {
|
||||||
|
background: #0F172A;
|
||||||
|
border-top-color: #1E293B;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-input-pill-container {
|
||||||
|
background: #1E293B;
|
||||||
|
border-color: #334155;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-input-pill-container:focus-within {
|
||||||
|
border-color: #FF8AB6;
|
||||||
|
box-shadow: 0 0 0 3px rgba(255, 138, 182, 0.2);
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-input-plus-btn {
|
||||||
|
background: #334155;
|
||||||
|
color: #CBD5E1;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-input-plus-btn:hover {
|
||||||
|
background: #475569;
|
||||||
|
color: #F8FAFC;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-chat-textarea {
|
||||||
|
color: #F8FAFC;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-send-btn {
|
||||||
|
color: #FF8AB6;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-send-btn:hover {
|
||||||
|
color: #FFA5C8;
|
||||||
|
}
|
||||||
|
[data-bs-theme="dark"] .ai-sheet-handle {
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==============================================================
|
||||||
|
UX MÓVIL EXACTA ESTILO MERCADO LIBRE (< 768px):
|
||||||
|
Bottom Sheet Nativo, Sólido, Sin Desbordes, Acoplado al Teclado
|
||||||
|
============================================================== */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.ai-chat-container {
|
.ai-chat-container {
|
||||||
bottom: 16px;
|
position: static !important;
|
||||||
right: 16px;
|
|
||||||
z-index: 1070;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ai-chat-launcher {
|
.ai-chat-launcher {
|
||||||
width: 52px;
|
position: fixed !important;
|
||||||
height: 52px;
|
bottom: 20px !important;
|
||||||
|
right: 20px !important;
|
||||||
|
width: 54px !important;
|
||||||
|
height: 54px !important;
|
||||||
|
z-index: 1060 !important;
|
||||||
}
|
}
|
||||||
.ai-chat-launcher.chat-open {
|
.ai-chat-launcher.chat-open {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Bottom Sheet que ocupa casi toda la pantalla (92vh/92dvh) dejando ver el contexto */
|
||||||
.ai-chat-panel {
|
.ai-chat-panel {
|
||||||
position: fixed !important;
|
position: fixed !important;
|
||||||
top: 0 !important;
|
|
||||||
left: 0 !important;
|
left: 0 !important;
|
||||||
right: 0 !important;
|
right: 0 !important;
|
||||||
bottom: 0 !important;
|
bottom: 0 !important;
|
||||||
|
top: auto !important;
|
||||||
width: 100vw !important;
|
width: 100vw !important;
|
||||||
max-width: 100vw !important;
|
max-width: 100vw !important;
|
||||||
height: 100dvh !important;
|
height: 92vh !important;
|
||||||
max-height: 100dvh !important;
|
height: 92dvh !important;
|
||||||
border-radius: 0 !important;
|
max-height: 92dvh !important;
|
||||||
z-index: 1080 !important;
|
border-top-left-radius: 28px !important;
|
||||||
box-shadow: none !important;
|
border-top-right-radius: 28px !important;
|
||||||
|
border-bottom-left-radius: 0 !important;
|
||||||
|
border-bottom-right-radius: 0 !important;
|
||||||
border: none !important;
|
border: none !important;
|
||||||
|
box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4) !important;
|
||||||
|
z-index: 1080 !important;
|
||||||
|
animation: aiSheetSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
|
||||||
|
overscroll-behavior: contain;
|
||||||
}
|
}
|
||||||
|
@keyframes aiSheetSlideUp {
|
||||||
|
from { transform: translateY(100%); }
|
||||||
|
to { transform: translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mostrar drag handle bar */
|
||||||
|
.ai-sheet-handle-bar {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
.ai-chat-header {
|
.ai-chat-header {
|
||||||
border-radius: 0 !important;
|
padding: 0.4rem 1rem 0.6rem !important;
|
||||||
padding: 0.75rem 1rem !important;
|
|
||||||
}
|
}
|
||||||
.ai-chat-messages {
|
.ai-chat-messages {
|
||||||
padding: 0.85rem !important;
|
padding: 0.85rem 1rem !important;
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
}
|
}
|
||||||
.ai-msg {
|
.ai-msg {
|
||||||
max-width: 90% !important;
|
max-width: 90% !important;
|
||||||
font-size: 0.88rem !important;
|
|
||||||
}
|
|
||||||
.ai-option-btn {
|
|
||||||
font-size: 0.78rem !important;
|
|
||||||
padding: 6px 12px !important;
|
|
||||||
min-height: 32px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dock Inferior móvil anclado */
|
||||||
.ai-chat-footer {
|
.ai-chat-footer {
|
||||||
padding: 0.65rem 0.85rem !important;
|
padding: 0.65rem 0.9rem !important;
|
||||||
padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px)) !important;
|
padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 10px)) !important;
|
||||||
|
box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
.ai-input-pill-container {
|
||||||
|
padding: 7px 10px 7px 12px !important;
|
||||||
}
|
}
|
||||||
.ai-chat-textarea {
|
.ai-chat-textarea {
|
||||||
font-size: 16px !important; /* Previene el auto-zoom involuntario en Safari iOS */
|
font-size: 16px !important; /* Previene auto-zoom molesto en iOS */
|
||||||
padding: 8px 12px !important;
|
}
|
||||||
|
.ai-send-btn i {
|
||||||
|
font-size: 1.85rem !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Bloqueo de scroll en fondo cuando el Bottom Sheet está abierto */
|
||||||
body.ai-chat-mobile-open {
|
body.ai-chat-mobile-open {
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
touch-action: none;
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user