/* ==========================================================================
   Chatbot Widget — Assistente de vendas público (SNAP AI)
   Aparece em todas as páginas públicas no canto inferior-direito.
   ========================================================================== */

/* ---------- Botão flutuante (FAB) ---------- */
.chatbot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a66c2, #004182);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(10, 102, 194, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chatbot-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(10, 102, 194, 0.5);
}

.chatbot-fab svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

/* Badge de notificação */
.chatbot-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    display: none;
}

.chatbot-fab-badge.active {
    display: block;
    animation: chatbot-pulse 2s infinite;
}

@keyframes chatbot-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ---------- Janela do chat ---------- */
.chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    border-radius: 16px;
    background: var(--neutral-0, #fff);
    border: 1px solid var(--neutral-200, #e2e8f0);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.chatbot-window.open {
    display: flex;
    animation: chatbot-slideUp 0.3s ease;
}

@keyframes chatbot-slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #0a66c2, #004182);
    color: #fff;
    padding: 16px 16px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.chatbot-header-info {
    flex: 1;
    min-width: 0;
}

.chatbot-header-name {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}

.chatbot-header-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-header-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.chatbot-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.chatbot-close:hover {
    opacity: 1;
}

/* Mensagens */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 320px;
}

.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-msg a {
    color: #0a66c2;
    text-decoration: underline;
}

.chatbot-msg.bot {
    background: var(--neutral-50, #f8fafc);
    border: 1px solid var(--neutral-200, #e2e8f0);
    color: var(--text-primary, #1e293b);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chatbot-msg.user {
    background: #0a66c2;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-msg.user a {
    color: #bfdbfe;
}

/* Typing indicator */
.chatbot-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 14px;
    background: var(--neutral-50, #f8fafc);
    border: 1px solid var(--neutral-200, #e2e8f0);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.chatbot-typing.active {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--neutral-400, #94a3b8);
    animation: chatbot-blink 1.4s infinite;
}

.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbot-blink {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Input */
.chatbot-input-area {
    border-top: 1px solid var(--neutral-200, #e2e8f0);
    padding: 12px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    background: var(--neutral-0, #fff);
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--neutral-200, #e2e8f0);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    background: var(--neutral-25, #fcfcfd);
    color: var(--text-primary, #1e293b);
    transition: border-color 0.2s;
}

.chatbot-input:focus {
    border-color: #0a66c2;
}

.chatbot-input::placeholder {
    color: var(--neutral-400, #94a3b8);
}

.chatbot-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #0a66c2;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    background: #004182;
}

.chatbot-send:disabled {
    background: var(--neutral-300, #cbd5e1);
    cursor: not-allowed;
}

.chatbot-send svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* Powered by */
.chatbot-footer {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: var(--neutral-400, #94a3b8);
    background: var(--neutral-25, #fcfcfd);
    border-top: 1px solid var(--neutral-200, #e2e8f0);
}

/* ---------- Lead capture form ---------- */
.chatbot-lead-form {
    align-self: flex-start;
    max-width: 90%;
    padding: 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(10, 102, 194, 0.08), rgba(10, 102, 194, 0.03));
    border: 1px solid rgba(10, 102, 194, 0.2);
}

.chatbot-lead-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin-bottom: 10px;
}

.chatbot-lead-input {
    display: block;
    width: 100%;
    border: 1px solid var(--neutral-200, #e2e8f0);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 8px;
    outline: none;
    background: var(--neutral-0, #fff);
    color: var(--text-primary, #1e293b);
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.chatbot-lead-input:focus {
    border-color: #0a66c2;
}

.chatbot-lead-input::placeholder {
    color: var(--neutral-400, #94a3b8);
}

.chatbot-lead-btn {
    display: block;
    width: 100%;
    padding: 9px 14px;
    border: none;
    border-radius: 8px;
    background: #0a66c2;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.chatbot-lead-btn:hover {
    background: #004182;
}

.chatbot-lead-btn:disabled {
    background: var(--neutral-300, #cbd5e1);
    cursor: not-allowed;
}

.chatbot-lead-error {
    color: #ef4444;
    font-size: 11px;
    margin-top: 4px;
    min-height: 16px;
}

/* ---------- Dark mode ---------- */
[data-bs-theme="dark"] .chatbot-window {
    background: var(--bg-card, #1e293b);
    border-color: var(--neutral-200, #475569);
}

[data-bs-theme="dark"] .chatbot-msg.bot {
    background: var(--bg-hover, #334155);
    border-color: var(--neutral-200, #475569);
    color: var(--text-primary, #f1f5f9);
}

[data-bs-theme="dark"] .chatbot-typing {
    background: var(--bg-hover, #334155);
    border-color: var(--neutral-200, #475569);
}

[data-bs-theme="dark"] .chatbot-input-area {
    background: var(--bg-card, #1e293b);
    border-color: var(--neutral-200, #475569);
}

[data-bs-theme="dark"] .chatbot-input {
    background: var(--bg-hover, #334155);
    border-color: var(--neutral-200, #475569);
    color: var(--text-primary, #f1f5f9);
}

[data-bs-theme="dark"] .chatbot-footer {
    background: var(--bg-surface, #1e293b);
    border-color: var(--neutral-200, #475569);
}

[data-bs-theme="dark"] .chatbot-lead-form {
    background: linear-gradient(135deg, rgba(10, 102, 194, 0.15), rgba(10, 102, 194, 0.05));
    border-color: rgba(10, 102, 194, 0.3);
}

[data-bs-theme="dark"] .chatbot-lead-title {
    color: var(--text-primary, #f1f5f9);
}

[data-bs-theme="dark"] .chatbot-lead-input {
    background: var(--bg-hover, #334155);
    border-color: var(--neutral-200, #475569);
    color: var(--text-primary, #f1f5f9);
}

[data-bs-theme="dark"] .chatbot-fab {
    box-shadow: 0 4px 16px rgba(10, 102, 194, 0.6);
}

[data-bs-theme="dark"] .chatbot-fab-badge {
    border-color: var(--bg-body, #0f172a);
}

[data-bs-theme="dark"] .chatbot-msg a {
    color: var(--primary-200, #99d1f3);
}

[data-bs-theme="dark"] .chatbot-msg.user a {
    color: #bfdbfe;
}

[data-bs-theme="dark"] .chatbot-input:focus {
    border-color: var(--primary, #0a66c2);
}

[data-bs-theme="dark"] .chatbot-lead-input:focus {
    border-color: var(--primary, #0a66c2);
}

[data-bs-theme="dark"] .chatbot-lead-error {
    color: var(--danger, #ef4444);
}

/* ---------- Mobile responsivo ---------- */
@media (max-width: 480px) {
    .chatbot-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
    }

    .chatbot-fab {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .chatbot-fab svg {
        width: 24px;
        height: 24px;
    }
}
