/* Chatbot FAB & Window Styles */
:root {
    --chat-primary: #0284c7;
    --chat-bg: #ffffff;
    --chat-border: #e2e8f0;
    --chat-text: #0f172a;
    --chat-user-msg: #0284c7;
    --chat-bot-msg: #f1f5f9;
}

#chat-fab {
    position: fixed;
    bottom: 110px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.2s, box-shadow 0.2s;
}

#chat-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#chat-fab svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

#chat-window {
    position: fixed;
    bottom: 180px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    border: 1px solid var(--chat-border);
}

#chat-window.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.chat-header {
    background: var(--chat-primary);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.chat-header .close-btn {
    cursor: pointer;
    opacity: 0.8;
}

.chat-header .close-btn:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--chat-user-msg);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.bot {
    align-self: flex-start;
    background: var(--chat-bot-msg);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

/* Formato markdown bsico para la respuesta del bot */
.chat-msg.bot p { margin: 0 0 8px 0; }
.chat-msg.bot p:last-child { margin: 0; }
.chat-msg.bot ul, .chat-msg.bot ol { margin: 0 0 8px 0; padding-left: 20px; }
.chat-msg.bot pre { background: #e2e8f0; padding: 8px; border-radius: 4px; overflow-x: auto; font-size: 0.8rem; }
.chat-msg.bot code { font-family: monospace; background: #e2e8f0; padding: 2px 4px; border-radius: 4px; }

.chat-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
}

.chat-input-area input:focus {
    border-color: var(--chat-primary);
}

.chat-input-area button {
    background: var(--chat-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-input-area button:hover {
    background: #0369a1;
}

.chat-input-area button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    margin-left: -2px;
}

.typing-indicator {
    display: none;
    align-self: flex-start;
    background: var(--chat-bot-msg);
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
