:root {
    --primary-grad: linear-gradient(135deg, #1e40af 0%, #0284c7 50%, #0ea5e9 100%);
    --primary-color: #0284c7;
    --bg-dark: #0b0f19;
    --bg-card: rgba(15, 23, 42, 0.45);
    --bg-message-user: rgba(2, 132, 199, 0.8);
    --bg-message-bot: rgba(30, 41, 59, 0.45);
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.12);
    --glass-blur: blur(20px);
}

/* Isolamento do CSS do Widget - Impede conflitos com o seu site principal */
.chat-widget-container, .chat-widget-container * {
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

.chat-widget-container {
    margin: 0;
    padding: 0;
}

/* Container do Chat Widget */
.chat-widget-container {
    position: fixed;
    bottom: 10px; /* Subiu 30px para não ficar colado na borda inferior */
    right: 0px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none; /* Permite cliques fora do robô */
}

/* Isolamento de cliques para elementos internos */
.chat-widget-container > * {
    pointer-events: auto;
}

/* Botão Flutuante (Launcher - 100% Robô Transparente) */
.chat-launcher {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: transparent !important;
    border: none !important;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #ffffff;
    outline: none;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    /* Efeito de Sombra 3D Solicitado contornando exatamente os traços do robô transparente! */
    filter: drop-shadow(0px 12px 24px #000) drop-shadow(0px 4px 8px rgba(31, 0, 0, 0.18));
}

/* Efeito de Hover Animando Apenas o Robô (sem qualquer bolha de fundo) */
.chat-launcher:hover {
    transform: scale(1.07) translateY(-6px) rotate(1.5deg);
    filter: drop-shadow(0px 16px 28px #000) drop-shadow(0px 6px 12px rgba(31, 0, 0, 0.25));
}

.chat-launcher svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: transform 0.4s ease;
}

/* O Launcher agora é completamente ocultado quando o chat abre, eliminando a bolha */
.chat-launcher.active {
    display: none !important;
}

/* Estilo de Fallback se o Lottie falhar (mantém a bolha azul estática clássica) */
.chat-launcher.fallback-active {
    width: 60px !important;
    height: 60px !important;
    margin-right: 45px !important;
    margin-bottom: 45px !important;
    background: rgba(0, 34, 150, 0.88) !important;
    border: 1px solid rgba(0, 34, 150, 0.4) !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15) !important;
    backdrop-filter: blur(5px) !important;
    -webkit-backdrop-filter: blur(5px) !important;
    filter: none !important;
}

/* Estado Minimizado aplicado no Container (Robô Fica em 100px e Discreto) */
.chat-widget-container.minimized-active .chat-launcher {
    width: 100px !important;
    height: 100px !important;
    margin-right: 20px !important;
    margin-bottom: 10px !important;
    opacity: 0.9;
    filter: drop-shadow(0px 8px 16px #000) !important;
}

.chat-widget-container.minimized-active .chat-launcher:hover {
    opacity: 1;
    transform: scale(1.06);
}

.chat-widget-container.minimized-active #lottieContainer {
    width: 100px !important;
    height: 100px !important;
}

/* O botão de minimizar acompanha o robô menor, descendo para 90px e continuando visível */
.chat-widget-container.minimized-active .minimize-lottie-btn {
    bottom: 90px !important;
    opacity: 0.9;
    display: block !important;
}

.chat-widget-container.minimized-active .chat-bubble-prompt {
    display: none !important;
}

/* Caixa de Conversa (Chat Window) */
.chat-window {
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: rgba(100, 136, 255, 0.88);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(100, 136, 255, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-right: 25px; /* Afasta a janela das bordas direita/inferior de forma limpa */
    margin-bottom: 20px;
    transform: scale(0.9) translateY(40px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
}

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

/* Cabeçalho do Chat */
.chat-header {
    background: rgba(0, 34, 150, 0.88);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(0, 34, 150, 0.4);
    padding: 24px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar-container {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.avatar-online {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #10b981;
    border: 2px solid #0f172a;
}

.header-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #ffffff;
    margin: 0;
}

.header-info p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
}

/* Corpo de Mensagens */
.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #ffffff;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* Estrutura das Mensagens */
.message-row {
    display: flex;
    width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    animation: bubbleAnim 0.3s ease forwards;
}

@keyframes bubbleAnim {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-row.user .message-bubble {
    background: rgba(0, 34, 150, 0.95);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(0, 34, 150, 0.2);
}

.message-row.bot .message-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.message-bubble a {
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s ease;
}

/* Cor do link na mensagem do Bot (fundo cinza claro) */
.message-row.bot .message-bubble a {
    color: #1d4ed8;
}
.message-row.bot .message-bubble a:hover {
    color: #1e40af;
}

/* Cor do link na mensagem do Usuário (fundo azul escuro) */
.message-row.user .message-bubble a {
    color: #ffffff;
}
.message-row.user .message-bubble a:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* Área de Digitação do Robô */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

/* Rodapé / Input de Mensagem */
.chat-input-area {
    padding: 20px 24px;
    background: #f8fafc;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    outline: none;
    padding: 14px 18px;
    border-radius: 14px;
    color: var(--text-light);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

.send-btn {
    background: rgba(0, 34, 150, 0.88);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(0, 34, 150, 0.4);
    outline: none;
    width: 48px;
    height: 48px;
    color: #ffffff !important;
    font-size: 18px !important;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 34, 150, 0.3);
    background: rgba(0, 34, 150, 1);
}

.send-btn:active {
    transform: translateY(0);
}

/* Formulário de Leads Premium */
.lead-form-container {
    flex: 1;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.2);
    animation: fadeIn 0.4s ease forwards;
    overflow-y: auto;
}

.lead-form-title {
    text-align: center;
    margin-bottom: 5px;
}

.lead-form-title h4 {
    font-size: 1.15rem;
    color: var(--text-light);
    font-weight: 600;
    margin: 0 0 4px 0;
}

.lead-form-title p {
    font-size: 0.8rem;
    color: #ffffff;
    margin: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 500;
    text-align: left;
}

.form-group label span {
    color: #ef4444;
    margin-left: 3px;
}

.form-input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    outline: none;
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--text-light);
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

.form-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 4px;
    text-align: left;
}

.form-consent input[type="checkbox"] {
    margin-top: 2px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.form-consent span {
    font-size: 0.7rem;
    color: #ffffff;
    line-height: 1.3;
}

.form-consent a {
    color: #ffffff;
    text-decoration: underline;
    font-weight: 600;
    transition: all 0.2s ease;
}

.form-consent a:hover {
    color: rgba(255, 255, 255, 0.8);
}

.start-chat-btn {
    background: rgba(0, 34, 150, 0.88);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(0, 34, 150, 0.4);
    padding: 12px;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    margin-top: 6px;
    border: none;
}

.start-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 34, 150, 0.3);
    background: rgba(0, 34, 150, 1);
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsividade Mobile */
@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 15px;
        right: 15px;
        left: 15px;
    }
    .chat-window {
        width: 100%;
        height: calc(100vh - 100px);
        max-height: none;
        border-radius: 20px;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }
}

/* Estilos de controle de exibição do Launcher com Lottie */
.chat-launcher #closeIcon {
    display: none;
}

.chat-launcher.active #lottieContainer,
.chat-launcher.active #launchIcon {
    display: none !important;
}

.chat-launcher.active #closeIcon {
    display: block !important;
}

/* Botão fechar no cabeçalho (Clean & Moderno) */
.close-header-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    padding: 5px;
    margin-left: auto; /* Empurra o botão para a extrema direita */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.close-header-btn:hover {
    color: #ffffff;
    transform: scale(1.15) rotate(90deg);
}

.close-header-btn svg {
    fill: currentColor;
}

/* Balão de Diálogo do Robô (Prompt com Glassmorphism) */
.chat-bubble-prompt {
    position: absolute;
    bottom: 135px; /* Ajustado para cima do robô de 150px */
    right: 35px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #1e293b;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(0, 34, 150, 0.18);
    border: 1px solid rgba(0, 34, 150, 0.12);
    white-space: nowrap;
    pointer-events: auto;
    cursor: pointer;
    opacity: 0;
    transform: translateY(12px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10000;
    animation: bubbleFloat 3s ease-in-out infinite alternate;
}

.chat-bubble-prompt.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Indicador triangular do balãozinho */
.chat-bubble-prompt::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 55px;
    border-width: 7px 7px 0;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.95) transparent;
    display: block;
    width: 0;
}

@keyframes bubbleFloat {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-7px); }
}

/* Botão de Minimizar Robô (Clean, Compacto & Permanente) */
.minimize-lottie-btn {
    position: absolute;
    bottom: 130px; /* Subiu 20px para ficar acima do robô de 150px */
    right: 20px;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 3px 8px;
    font-family: monospace;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    opacity: 0.85; /* Visível permanentemente na tela */
    z-index: 10001;
    pointer-events: auto;
    line-height: 1.2;
}

.minimize-lottie-btn:hover {
    opacity: 1;
    background: rgba(0, 34, 150, 0.85); /* Fundo azul da marca no hover */
    color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 34, 150, 0.25);
}

/* Oculta completamente o botão de minimizar quando a janela do chat estiver ativa (aberta) */
.chat-window.active ~ .minimize-lottie-btn {
    display: none !important;
}
