/*
 * =============================================
 * Chat Button & Lead Capture - AI Chat Styles (v5.7.3 - Final Animation Fix)
 * =============================================
 */

/* ============================================= */
/* [BASE] Definições e Variáveis Dinâmicas      */
/* ============================================= */
:root {
    --cblc-dynamic-color: #00a884;
}

/* ============================================= */
/* [BASE] Animações Compartilhadas              */
/* ============================================= */
@keyframes cblc_pulsate { from { transform: scale(1); box-shadow: 0 2px 8px rgba(0,0,0,0.1); } to { transform: scale(1.05); box-shadow: 0 4px 16px rgba(0,0,0,0.2); } }
@keyframes cblc_glow { from { box-shadow: 0 0 5px var(--cblc-dynamic-color), 0 0 10px var(--cblc-dynamic-color), 0 0 15px #ffffff; } to { box-shadow: 0 0 10px color-mix(in srgb, var(--cblc-dynamic-color) 80%, #fff), 0 0 20px color-mix(in srgb, var(--cblc-dynamic-color) 80%, #fff), 0 0 25px #ffffff; } }
@keyframes cblc_shake { 0%, 100% { transform: rotate(0deg); } 2%, 6% { transform: rotate(5deg); } 4%, 8% { transform: rotate(-5deg); } }
@keyframes cblc_slideUp { from { transform: scale(0.95) translateY(10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
@keyframes cblc_bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }

/* >>> INÍCIO DA CORREÇÃO: Animação de entrada suave e unificada <<< */
@keyframes cblc_slide_in_and_fade {
    from {
        transform: translateY(120px); /* Começa totalmente fora da tela */
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
/* >>> FIM DA CORREÇÃO <<< */

/* ============================================= */
/* [BASE] Gatilhos Flutuantes (Botão e Avatar)  */
/* ============================================= */

/* >>> INÍCIO DA CORREÇÃO: Lógica de animação unificada <<< */
#wa-float-button,
.cblc-avatar-trigger-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
    cursor: pointer;
    opacity: 0; /* Começa invisível, a animação controla a aparição */
    animation-fill-mode: forwards;
    animation-name: cblc_slide_in_and_fade;
    animation-duration: 0.7s;
    animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1);
    animation-delay: 1s;
}
/* >>> FIM DA CORREÇÃO <<< */

#wa-float-button {
    background-color: var(--cblc-dynamic-color);
    color: white;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    gap: 8px;
    font-family: sans-serif;
    font-weight: bold;
    font-size: 15px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    transition: transform .3s ease;
}
#wa-float-button:hover { transform: scale(1.1); }

.cblc-avatar-trigger-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}
.cblc-avatar-photo,
.cblc-chat-header .cblc-agent-photo {
    position: relative;
    flex-shrink: 0;
}
.cblc-avatar-photo img,
.cblc-chat-header .cblc-agent-photo img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.9);
}
.cblc-avatar-photo { width: 60px; height: 60px; }
.cblc-chat-header .cblc-agent-photo { width: 45px; height: 45px; }

.cblc-avatar-message {
    background-color: #fff;
    padding: 15px 20px;
    border-radius: 20px;
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 250px;
    font-family: sans-serif;
    font-size: 15px;
    color: #333;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.4s ease, transform 0.4s ease;
    transform-origin: bottom right;
}
.cblc-avatar-message.visible { opacity: 1; transform: scale(1); }

.cblc-avatar-photo::after,
.cblc-agent-photo::after {
    content: '';
    position: absolute;
    z-index: 10;
    background-color: #25D366;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.cblc-avatar-photo::after { width: 15px; height: 15px; border: 2px solid white; bottom: 2px; right: 2px; }
.cblc-agent-photo::after { width: 12px; height: 12px; border: 2px solid var(--cblc-dynamic-color); bottom: 0px; right: 0px; }

/* ============================================= */
/* [ESPECÍFICO] Estilos do Modal de Chat com IA */
/* ============================================= */

#cblc-chat-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    font-family: sans-serif;
}

.cblc-chat-content {
    position: absolute;
    bottom: 95px;
    right: 25px;
    width: 90%;
    max-width: 380px;
    height: 70vh;
    max-height: 550px;
    background-color: #F0F2F5;
    border-radius: 8px;
    box-shadow: 0 6px 20px 0 rgba(0,0,0,0.19);
    display: flex;
    flex-direction: column;
    animation: cblc_slideUp .4s cubic-bezier(0.23, 1, 0.32, 1);
    transform-origin: bottom right;
}

.cblc-chat-header {
    padding: 10px 15px;
    background-color: var(--cblc-dynamic-color);
    color: white;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.cblc-agent-info {
    flex-grow: 1;
    text-align: left;
}
.cblc-agent-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
}
.cblc-agent-info p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}
.cblc-chat-header .close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    margin-left: auto;
    padding: 0 5px;
}

.cblc-chat-body {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: #E5DDD5; /* Fundo padrão do WhatsApp */
}
.cblc-chat-messages {
    display: flex;
    flex-direction: column;
}
.cblc-message {
    padding: 8px 12px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    margin-bottom: 10px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}
.user-message {
    background-color: #dcf8c6;
    color: #303030;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.ai-message {
    background-color: #ffffff;
    color: #303030;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.notice-message {
    background-color: #fdfdea;
    color: #666;
    font-size: 11px;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    margin: 0 auto 10px auto;
    max-width: 95%;
    line-height: 1.4;
    align-self: center;
}
.notice-message a {
    color: #0073aa;
    text-decoration: underline;
}

.cblc-chat-footer {
    padding: 10px;
    background-color: #f0f2f5;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    align-items: center;
}
.cblc-chat-footer textarea {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 10px 15px;
    font-family: sans-serif;
    font-size: 15px;
    line-height: 1.4;
    resize: none;
    overflow-y: hidden;
    min-height: 25px;
    max-height: 120px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.cblc-chat-footer textarea:focus {
    border-color: var(--cblc-dynamic-color);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cblc-dynamic-color) 30%, transparent);
}
.cblc-chat-footer button {
    background-color: var(--cblc-dynamic-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color .2s ease;
    flex-shrink: 0;
}
.cblc-chat-footer button:hover {
    background-color: color-mix(in srgb, var(--cblc-dynamic-color) 85%, #000);
}
.cblc-chat-footer button svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

/* Indicador de Digitação DENTRO do chat */
.cblc-typing-indicator {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background-color: #ffffff;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    margin-bottom: 10px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}
.cblc-typing-indicator span {
    height: 8px;
    width: 8px;
    background-color: #9E9E9E;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: cblc_bounce 1.4s infinite both;
}
.cblc-typing-indicator span:nth-child(2) { animation-delay: .2s; }
.cblc-typing-indicator span:nth-child(3) { animation-delay: .4s; }

/* Indicador de Digitação no Balão do Avatar (FORA do chat) */
#cblc-typing-indicator-bubble {
    background-color: #fff;
    padding: 15px 20px;
    border-radius: 20px;
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    transition: opacity 0.4s ease;
    position: absolute;
    bottom: 0;
    right: 75px; /* (largura do avatar 60px + gap 15px) */
}
#cblc-typing-indicator-bubble.hidden { opacity: 0; }

/* Botões de Resposta Rápida e CTAs */
.cblc-quick-reply-buttons, .cblc-cta-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    justify-content: flex-start;
}
.cblc-quick-reply-button {
    background-color: #e0f2f1;
    color: var(--cblc-dynamic-color);
    border: 1px solid var(--cblc-dynamic-color);
    border-radius: 16px;
    padding: 8px 15px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.cblc-quick-reply-button:hover {
    background-color: var(--cblc-dynamic-color);
    color: white;
}
.cblc-cta-button {
    width: 100%;
    background-color: var(--cblc-dynamic-color);
    color: white;
    padding: 14px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    white-space: normal;
    line-height: 1.3;
    height: auto;
}
.cblc-cta-button:hover {
    background-color: color-mix(in srgb, var(--cblc-dynamic-color) 85%, #000);
    transform: scale(1.02);
}
.cblc-quick-reply-button:disabled {
    background-color: #f0f0f0;
    color: #aaa;
    border-color: #ddd;
    cursor: not-allowed;
}

/* Marca d'água */
.cblc-branding {
    text-align: center;
    padding: 8px 0;
    font-size: 10px;
    background-color: #f0f2f5;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    flex-shrink: 0;
}
.cblc-branding a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s ease;
}
.cblc-branding a:hover {
    color: #333;
}