#n8n-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 1050;
    transition: transform 0.3s ease-in-out;
    background-color: transparent;
    overflow: hidden;
}

#n8n-chat-button:hover {
    transform: scale(1.1);
}

#n8n-chat-window {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1050;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    font-family: 'Roboto', sans-serif;
}

/* Cabecera del chat */
.chat-header {
    background: #004a87; /* Azul institucional UAT */
    color: white;
    padding: 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Área de mensajes */
#chat-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Mensajes individuales */
.msg-bot {
    align-self: flex-start;
    background-color: #e9ecef;
    padding: 10px 14px;
    border-radius: 15px 15px 15px 0;
    max-width: 90%;
    font-size: 14px;
    color: #333;
    overflow-wrap: break-word;
    line-height: 1.5;
}

/* --- ARREGLO PARA ELIMINAR CUADROS DE TEXTO (CODE/PRE) --- */
.msg-bot pre, .msg-bot code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: 'Roboto', sans-serif !important;
    font-size: 14px !important;
    color: inherit !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
}

/* --- ESTILOS MEJORADOS PARA TABLAS Y NEGRITAS DEL BOT --- */
.msg-bot table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 12px;
    background: white;
    border: 1px solid #ddd;
    table-layout: fixed;
    display: table;
}

.msg-bot th {
    background-color: #004a87;
    color: white;
    padding: 8px;
    text-align: left;
    border: 1px solid #003d70;
    word-wrap: break-word;
}

.msg-bot td {
    border: 1px solid #ccc;
    padding: 6px;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.msg-bot strong {
    color: #d1612e; /* Naranja UAT */
    font-weight: 700;
}
/* Estilo para enlaces dentro del bot (correos/webs) */
.msg-bot a {
    color: #004a87;
    text-decoration: underline;
    font-weight: bold;
}

.msg-bot ul, .msg-bot ol {
    padding-left: 20px;
    margin: 5px 0;
}

.msg-bot h3 {
    font-size: 16px;
    color: #004a87;
    margin-top: 10px;
    border-bottom: 1px solid #ccc;
}
/* -------------------------------------------------------- */

.msg-user {
    align-self: flex-end;
    background-color: #004a87;
    color: white;
    padding: 10px 14px;
    border-radius: 15px 15px 0 15px;
    max-width: 85%;
    font-size: 14px;
}

/* Área de input */
.chat-input-area {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    background: white;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 15px;
    outline: none;
    font-size: 14px;
}

.chat-input-area button {
    background: none;
    border: none;
    color: #004a87;
    margin-left: 10px;
    cursor: pointer;
    font-size: 18px;
}

/* Responsivo para móviles */
@media (max-width: 768px) {
    #n8n-chat-window {
        width: 90%;
        right: 5%;
        height: 60vh;
        bottom: 90px;
    }
}

/* Chatbot CSP fixes */
#n8n-chat-window.hidden { display: none; }
.btn-close-chat { background:none; border:none; color:white; cursor:pointer; }
.img-chat-btn { width: 100%; height: 100%; object-fit: cover; }

/* Botones de links/documentos generados por la IA */
.btn-chat-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #004a87, #0066b8);
    color: white !important;
    text-decoration: none !important;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    margin: 4px 2px;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 2px 6px rgba(0,74,135,0.25);
}
.btn-chat-link:hover {
    background: linear-gradient(135deg, #003870, #004a87);
    transform: translateY(-1px);
    color: white !important;
}
.btn-chat-link .link-icon {
    font-size: 14px;
}

/* Botón de descarga de documentos (verde) */
.btn-chat-doc {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #1a7a3e, #22a050);
    color: white !important;
    text-decoration: none !important;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    margin: 4px 2px;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 2px 6px rgba(26,122,62,0.25);
}
.btn-chat-doc:hover {
    background: linear-gradient(135deg, #145f30, #1a7a3e);
    transform: translateY(-1px);
    color: white !important;
}
.btn-chat-doc .link-icon {
    font-size: 14px;
}
