/* Conexión al Archivo Maestro */
@import url('./theme.css');

/* =========================================================
   CHATBOT - ESTILOS COMPLETOS
   Variables conectadas al archivo Maestro (theme.css)
   ========================================================= */

:root {
    /* Colores principales del chatbot */
    --chat-color-principal: var(--marca-color-principal);
    --chat-color-principal-hover: var(--marca-color-principal-hover);

    /* Gradientes */
    --chat-gradient-principal: var(--marca-gradiente-principal);
    --chat-gradient-principal-hover: var(--marca-gradiente-hover);

    /* Fondos */
    --chat-color-fondo: var(--marca-fondo-suave);
    --chat-color-fondo-suave: var(--marca-fondo-tarjeta);
    --chat-color-burbuja-bot: var(--marca-fondo-tarjeta);
    --chat-color-burbuja-usuario: var(--marca-color-principal);
    --chat-color-texto-usuario: var(--marca-texto-principal);

    /* Textos */
    --chat-color-texto: var(--marca-texto-base);
    --chat-color-texto-secundario: var(--marca-texto-atenuado);
    --chat-color-texto-suave: var(--marca-texto-apagado);

    /* Bordes */
    --chat-color-borde: var(--marca-fondo-borde);
    --chat-color-borde-suave: #261912;

    /* Nuevo Gradiente Verde para el botón de carrito */
    --chat-gradient-verde: linear-gradient(135deg, #2ecc71 0%, #27ae60 55%, #1e8449 100%);
    --chat-gradient-verde-hover: linear-gradient(135deg, #58d68d 0%, #2ecc71 55%, #27ae60 100%);
}





/* =========================================================
   BOTÓN FLOTANTE DEL CHAT
   ========================================================= */

#botonContenedor {
    position: fixed;
    bottom: 4px;
    right: 4px;
    z-index: 9999;
    cursor: pointer;
    display: block;
}

#botonChat {
    background-color: transparent;
    border: none;
    width: 30px;
    height: 30px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease-in-out;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

#botonChat:hover {
    transform: scale(1.1);
}

.robot-logo-flotante {
    width: 100%;
    height: 100%;
    overflow: visible;
}


/* =========================================================
   VENTANA PRINCIPAL DEL CHAT
   ========================================================= */

#ventanaChat {
    position: fixed;
    top: auto;
    bottom: 2px;
    right: 20px;
    width: 95vw;
    max-width: 380px;
    height: 500px;
    background: var(--chat-color-fondo);
    border-radius: 18px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 10000;
    user-select: none;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(20px);
    opacity: 0;
}

#ventanaChat.visible {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}


/* =========================================================
   CABECERA DEL CHAT
   ========================================================= */

#ventanaChat header {
    background: var(--chat-gradient-principal);
    color: #ffffff;
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 18px 18px 0 0;
    font-weight: bold;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;      /* Evita que la cabecera se aplaste */
    height: 60px;        /* Altura fija para control total */
    box-sizing: border-box;
}

#ventanaChat header button {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
}

#cerrarChat {
    margin-left: auto;
}

#ventanaChat header button:hover {
    color: rgba(255, 255, 255, 0.8);
}


/* =========================================================
   CONVERSACIÓN
   ========================================================= */

   #conversacion {
    padding: 20px 15px 15px;
    overflow-y: auto;
    flex-grow: 1;
    background: var(--chat-color-fondo);
    font-size: 15px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain; /* Evita que la cabecera se despegue o rebote al llegar al tope */
    -webkit-overflow-scrolling: touch;
}


/* =========================================================
   INDICADOR "ESCRIBIENDO" - CORREGIDO
   ========================================================= */

   #escribiendo {
    padding: 5px 15px;
    display: none;           /* <--- ESTO ES LO QUE FALTABA: Debe estar oculto por defecto */
    align-items: center;     /* Centra verticalmente el texto y los puntos */
    gap: 8px;                /* Espacio entre el texto y los puntos */
    color: var(--chat-color-principal);
    font-style: italic;
    font-weight: 600;
    align-self: flex-start;
    min-height: 24px;        /* Asegura que el contenedor tenga altura para alinear */
}

/* El texto "Escribiendo" */
#escribiendo::before {
    content: "Escribiendo";
    line-height: 1;          /* Alineación base para el texto */
}

/* Los puntos parpadeantes */
.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background-color: var(--chat-color-principal);
    border-radius: 50%;
    animation: wave 1.3s infinite;
    margin: 0;               /* Quitamos márgenes que puedan subir el punto */
}

/* Animación de los puntos */
.dot:nth-child(2) {
    animation-delay: 0.2s;
}

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

@keyframes wave {
    0%, 60%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    30% {
        transform: scale(1.1);
        opacity: 1;
    }
}


/* =========================================================
   ZONA DE ENTRADA
   ========================================================= */

#entradaChat {
    display: flex;
    flex-direction: column;
    padding: 10px;
    border-top: 1px solid var(--chat-color-borde-suave);
    background-color: var(--chat-color-fondo);
    flex-shrink: 0;
    position: relative;
    z-index: 10002;
}

#iconoUsuario {
    flex-shrink: 0;
    color: var(--chat-color-texto-secundario);
    background-color: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, color 0.2s ease;
}

#iconoUsuario:hover {
    transform: scale(1.1);
    color: #e11d48; /* Toque rojizo sutil al pasar el cursor para denotar alerta */
}

#entradaChat textarea {
    flex-grow: 1;
    padding: 10px 15px;
    background: var(--chat-color-burbuja-bot);
    border: 1px solid var(--chat-color-borde);
    border-radius: 20px;
    font-size: 16px; /* 16px evita el zoom automático forzado en cualquier celular */
    box-sizing: border-box;
    resize: none;
    overflow-y: hidden;
    min-height: 40px;
    max-height: 100px;
    color: var(--chat-color-texto);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.prompt-text {
    font-size: 13px;
    color: var(--chat-color-texto-secundario);
    margin: 0;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* =========================================================
   BOTÓN ENVIAR
   ========================================================= */

#botonEnviar {
    background-color: transparent;
    color: var(--chat-color-principal);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, color 0.2s;
    padding: 0;
}

#botonEnviar:hover {
    transform: scale(1.1);
    color: var(--chat-color-principal-hover);
}

#botonEnviar svg {
    width: 24px;
    height: 24px;
}




/* =========================================================
   MENSAJE DEL USUARIO
   ========================================================= */

   .mensajeUsuario {
    background: var(--chat-gradient-principal);
    color: var(--chat-color-texto-usuario);
    padding: 10px 14px;
    border-radius: 18px 18px 0 18px;
    margin-bottom: 4px;
    margin-left: auto; /* Empuja la burbuja a la derecha de forma limpia */
    display: table;    /* Obliga al navegador antiguo a medir la palabra completa ("ok", "Hola") */
    max-width: 85%;
    text-align: left;
    box-shadow: 0 2px 4px rgba(230, 81, 0, 0.2);
}


/* =========================================================
   MENSAJE DEL BOT
   ========================================================= */

.mensajeBot {
    background-color: var(--chat-color-burbuja-bot);
    background-image: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08));
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    color: var(--chat-color-texto);
    padding: 10px 14px;
    border-radius: 18px 18px 18px 0;
    margin-bottom: 6px;
    max-width: 85%;
    align-self: flex-start;
    word-wrap: break-word;
    text-align: left;
}

.mensajeBot a {
    font-weight: bold;
    text-decoration: none;
    color: var(--chat-color-principal);
}

.mensajeBot a:hover {
    text-decoration: underline;
}

.mensajeBot img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-top: 10px;
    border-radius: 8px;
}

.mensajeBot iframe {
    max-width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border-radius: 8px;
    border: none;
}


/* =========================================================
   OPCIONES DEL MENÚ DEL BOT
   ========================================================= */

.mensajeBot .menu-opcion {
    display: block;
    background-color: var(--chat-color-fondo);
    border: 1px solid var(--chat-color-borde);
    border-radius: 12px;
    padding: 10px 15px;
    margin-top: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 14px;
    color: var(--chat-color-texto);
}

.mensajeBot .menu-opcion:hover {
    background-color: var(--chat-color-fondo-suave);
    border-color: var(--chat-color-principal);
    transform: translateY(-1px);
}

.mensajeBot .menu-opcion span {
    margin-right: 10px;
    font-size: 16px;
}


/* =========================================================
   LOGO DEL ROBOT EN LA CONVERSACIÓN
   ========================================================= */

.prompt-robot-logo {
    width: 40px;
    height: 40px;
    align-self: flex-end;
    margin-top: 5px;
    margin-right: 5px;
}


/* =========================================================
   SECCIÓN UNIFICADA DE SUGERENCIAS 
   (Autocompletado y Botones Rápidos)
   ========================================================= */

/* --- A. LISTA DE AUTOCOMPLETADO (La que sale al escribir) --- */
#listaSugerencias {
    position: absolute;
    bottom: 105px; 
    left: 10px;
    right: 10px;
    background: var(--chat-gradient-principal); 
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px; 
    max-height: 150px; /* Bajamos un poco a 140px o 150px para que no choque con el techo al abrir teclado */
    margin: 0;
    padding: 0;
    list-style: none;
    z-index: 10010; 
    display: none;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);

    /* --- SOLUCIÓN PARA TECLADO MÓVIL --- */
    overflow-y: scroll !important; /* Cambiamos 'auto' por 'scroll' para forzar el mecanismo */
    -webkit-overflow-scrolling: touch; 
    touch-action: pan-y !important; /* Forzamos que el dedo solo mueva el eje Y */
    
    /* ACELERACIÓN POR HARDWARE (Esto es lo que soluciona el bloqueo del teclado) */
    transform: translate3d(0,0,0); 
    backface-visibility: hidden;
    perspective: 1000;
    
    /* AISLAMIENTO */
    overscroll-behavior: contain;
    pointer-events: auto !important;
    user-select: auto !important;
}

/* Ajuste para que los elementos de la lista sean más fáciles de tocar con teclado abierto */
#listaSugerencias li {
    padding: 14px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    color: #ffffff;
    /* Evita que el navegador intente "seleccionar" texto en lugar de scrollear */
    -webkit-user-select: none; 
    user-select: none; 
}



#listaSugerencias li:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- B. BOTONES DE SUGERENCIAS RÁPIDAS (Las burbujas en el chat) --- */
.sugerencias-rapidas-contenedor {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
    /* Eliminamos el max-height y el overflow para que se vean siempre */
    height: auto; 
    overflow: visible; 
}

.sugerencia-rapida {
    background-color: var(--chat-color-fondo);
    color: var(--chat-color-principal);
    border: 1px solid var(--chat-color-principal);
    border-radius: 15px;
    padding: 5px 10px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 600;
}

.sugerencia-rapida:hover {
    background: var(--chat-gradient-principal);
    color: #ffffff;
}




/* =========================================================
   RESPONSIVE
   ========================================================= */

   @media (max-width: 600px) {
    #ventanaChat {
        width: 100% !important;
        max-width: 100% !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
        transform: none !important;
        height: 100% !important;
        position: fixed !important;
        overscroll-behavior: contain !important;
    }

    #ventanaChat header {
        border-radius: 0 !important; /* Cabecera recta en móvil de borde a borde */
    }
}




.carrito-chat-flotante {
    display: none;
}

#botonCarritoChat {
    background: #ffffff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-color-principal);
    cursor: pointer;
    position: relative;
    padding: 0;
    flex-shrink: 0;
}

.carrito-chat-pulso {
    animation: carritoChatLatido 0.6s ease-in-out 2;
}

.badge-carrito-chat {
    position: absolute;
    top: -5px;
    right: -10px;
    background: #ff0000;
    color: #ffffff;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border: 1px solid white;
    line-height: 1;
}

@keyframes carritoChatLatido {
    0%, 100% { transform: scale(1); }
    10% { transform: scale(1.15); }
    20% { transform: scale(1); }
}




.boton-carrito-chat-contenedor {
    margin-top: 8px;
    margin-bottom: 15px;
    align-self: flex-start;
}

.boton-carrito-chat {
    background: var(--chat-gradient-verde); /* <--- Aquí aplicamos el verde */
    color: #ffffff;
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3); /* Sombra verde suave */
    transition: transform 0.2s ease;
}

.boton-carrito-chat:hover {
    background: var(--chat-gradient-verde-hover); /* Verde más brillante al pasar el mouse */
    transform: scale(1.05); /* Crece un poquito al pasar el mouse */
}



/* =========================================================
   VENTANA EMERGENTE DE DENUNCIA (DENTRO DEL CHAT)
   ========================================================= */
   .modal-denuncia-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65); /* Fondo oscuro semitransparente sobre los mensajes */
    z-index: 10050; /* Queda delante de la conversación */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-radius: 18px;
    box-sizing: border-box;
}

.modal-denuncia-caja {
    background: var(--chat-color-fondo);
    width: 100%;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-denuncia-cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 15px;
    color: var(--chat-color-texto);
}

.modal-denuncia-cabecera button {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--chat-color-texto-secundario);
    padding: 0;
}

.modal-denuncia-cabecera button:hover {
    color: var(--chat-color-texto);
}

#textoDenuncia {
    width: 100%;
    border: 1px solid var(--chat-color-borde);
    background-color: var(--chat-color-fondo-suave);
    border-radius: 10px;
    padding: 10px;
    font-size: 14px;
    box-sizing: border-box;
    resize: none;
    color: var(--chat-color-texto);
    font-family: inherit;
    outline: none;
}

#textoDenuncia:focus {
    border-color: var(--chat-color-principal);
}

.modal-denuncia-botones {
    display: flex;
    justify-content: flex-end;
}

.btn-enviar-denuncia {
    background: var(--chat-gradient-principal);
    color: #ffffff;
    border: none;
    padding: 9px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.btn-enviar-denuncia:hover {
    opacity: 0.9;
}

/* =========================================================
   ANIMACIÓN PULSO PARA NOTIFICACIÓN DEL CHAT MINIMIZADO
   ========================================================= */
   @keyframes pulsoLatidoNotif {
    0% { transform: scale(1); }
    50% { transform: scale(1.22); }
    100% { transform: scale(1); }
}