/* --- Chatbot Professional UI --- */
:root {
    --chat-primary: #f54927; /* Naranja profesional según referencia */
    --chat-bg: #ffffff;
    --chat-text: #0A2F2E;
    --chat-bot-msg: #f1f1f1;
    --chat-user-msg: #e5f2f6;
    --chat-accent: #ff4757; /* Rojo para notificaciones */
}

#n8n-chat-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 999999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* --- Tooltip --- */
#chat-tooltip {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: white;
    color: #333;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease;
    border: 1px solid #eee;
    pointer-events: none;
}
#chat-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 25px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
}
.show-attention #chat-tooltip { opacity: 1; transform: translateY(0); }

/* --- Burbuja --- */
#chat-trigger {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
#chat-trigger svg { width: 32px; height: 32px; }

#chat-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--chat-accent);
    color: white;
    font-size: 11px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2.5px solid white;
}

/* --- Efecto Pulse --- */
.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--chat-primary);
    border-radius: 50%;
    opacity: 0.6;
    z-index: -1;
    animation: chat-pulse 2s infinite;
    display: none;
}
.show-attention .pulse-ring, .show-attention #chat-badge { display: block; }

@keyframes chat-pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* --- Ventana de Chat --- */
#chat-window {
    width: 360px;
    max-width: 88vw;
    height: 520px;
    max-height: 70vh;
    background: var(--chat-bg);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 85px;
    right: 0;
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.n8n-chat-open #chat-window { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

.chat-header { background: var(--chat-primary); color: white; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; }
.status-online { font-size: 11px; opacity: 0.8; display: flex; align-items: center; margin-top: 2px; }
.status-online::before { content: ''; width: 7px; height: 7px; background: #2ecc71; border-radius: 50%; margin-right: 6px; }

#chat-messages { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; background: #f9f9f9; }
.message { padding: 12px 16px; border-radius: 15px; font-size: 14px; max-width: 80%; line-height: 1.5; }
.bot { background: white; align-self: flex-start; color: var(--chat-text); border: 1px solid #eee; }
.user { background: var(--chat-user-msg); align-self: flex-end; color: var(--chat-primary); font-weight: 500; }

/* Typing Indicator */
.typing { display: flex; gap: 4px; padding: 12px 16px; background: white; border: 1px solid #eee; border-radius: 15px; width: fit-content; align-self: flex-start; }
.typing span { width: 6px; height: 6px; background: #ccc; border-radius: 50%; animation: blink 1.4s infinite both; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.chat-input-area { padding: 15px; border-top: 1px solid #eee; display: flex; gap: 10px; background: white; }
#user-input { flex: 1; border: 1px solid #eee; border-radius: 25px; padding: 10px 18px; outline: none; font-size: 14px; transition: border 0.3s; }
#user-input:focus { border-color: var(--chat-primary); }
#send-btn { 
    background: var(--chat-primary) !important; 
    border: none; 
    color: white !important; 
    cursor: pointer; 
    border-radius: 50%; 
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    padding: 0;
}

#send-btn svg {
    width: 18px;
    height: 18px;
    margin-left: -2px; 
}
#send-btn:hover { transform: scale(1.1); }
.close-btn { background: none; border: none; color: white; font-size: 26px; cursor: pointer; line-height: 1; }
