/* CSS do Widget do Chatbot Flutuante Lava Bot */

#lavabot-widget {
    position: fixed;
    bottom: 25px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Posições */
.lavabot-pos-right {
    right: 25px;
    align-items: flex-end;
}

.lavabot-pos-left {
    left: 25px;
    align-items: flex-start;
}

.lavabot-pos-left #lavabot-cta-balloon {
    flex-direction: row-reverse;
    left: 0;
}

.lavabot-pos-left #lavabot-trigger-btn {
    align-self: flex-start;
}

.lavabot-pos-left #lavabot-chatbox {
    align-self: flex-start;
}

/* Balão de CTA */
#lavabot-cta-balloon {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-bottom: 12px;
    max-width: 360px;
    width: max-content;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: lavabot-bounce 2.5s infinite;
}

/* Pseudo-elementos gerais para as setas do balão de CTA */
#lavabot-cta-balloon::before,
#lavabot-cta-balloon::after {
    content: '';
    position: absolute;
    border-style: solid;
    display: block;
    width: 0;
    height: 0;
}

/* Posicionamento do balão no topo (default) no canto direito */
.lavabot-pos-right #lavabot-cta-balloon:not(.lavabot-cta-side)::before {
    border-width: 6px 6px 0 6px;
    border-color: #e2e8f0 transparent transparent transparent;
    bottom: -7px;
    right: 25px;
}
.lavabot-pos-right #lavabot-cta-balloon:not(.lavabot-cta-side)::after {
    border-width: 5px 5px 0 5px;
    border-color: #ffffff transparent transparent transparent;
    bottom: -5px;
    right: 26px;
}

/* Posicionamento do balão no topo (default) no canto esquerdo */
.lavabot-pos-left #lavabot-cta-balloon:not(.lavabot-cta-side)::before {
    border-width: 6px 6px 0 6px;
    border-color: #e2e8f0 transparent transparent transparent;
    bottom: -7px;
    left: 25px;
}
.lavabot-pos-left #lavabot-cta-balloon:not(.lavabot-cta-side)::after {
    border-width: 5px 5px 0 5px;
    border-color: #ffffff transparent transparent transparent;
    bottom: -5px;
    left: 26px;
}

/* Posicionamento do balão na lateral (canto direito) */
.lavabot-pos-right #lavabot-cta-balloon.lavabot-cta-side::before {
    border-width: 6px 0 6px 6px;
    border-color: transparent transparent transparent #e2e8f0;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
}
.lavabot-pos-right #lavabot-cta-balloon.lavabot-cta-side::after {
    border-width: 5px 0 5px 5px;
    border-color: transparent transparent transparent #ffffff;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
}

/* Posicionamento do balão na lateral (canto esquerdo) */
.lavabot-pos-left #lavabot-cta-balloon.lavabot-cta-side::before {
    border-width: 6px 6px 6px 0;
    border-color: transparent #e2e8f0 transparent transparent;
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
}
.lavabot-pos-left #lavabot-cta-balloon.lavabot-cta-side::after {
    border-width: 5px 5px 5px 0;
    border-color: transparent #ffffff transparent transparent;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
}

#lavabot-cta-balloon:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.lavabot-widget-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.lavabot-cta-content {
    margin: 0 10px;
}

.lavabot-cta-text {
    font-size: 13px;
    font-weight: 500;
    color: #2d3748;
    line-height: 1.4;
}

/* Botão de Gatilho */
#lavabot-trigger-btn {
    position: relative;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0,0,0,0.22); /* Drop Shadow destacado */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0;
    overflow: visible;
}

#lavabot-trigger-btn:hover {
    transform: scale(1.08);
}

.lavabot-trigger-open-icons {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.lavabot-trigger-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Bolinha Verde de Status Online */
.lavabot-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background-color: #38a169;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.lavabot-online-dot-header {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background-color: #38a169;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

#lavabot-trigger-btn svg {
    display: block;
}

/* Caixa de Chat */
#lavabot-chatbox {
    width: 360px;
    height: 520px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

/* Estilos de Exibição/Esconder com Animação */
.lavabot-hidden {
    display: none !important;
}

/* Animação inicial de entrada da caixa de chat (toca sempre que sai de display:none) */
@keyframes lavabotFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes lavabotBounceIn {
    0% { opacity: 0; transform: scale(0.7); }
    60% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

#lavabot-chatbox.lavabot-entrance-fade { animation: lavabotFadeIn 0.35s ease; }
#lavabot-chatbox.lavabot-entrance-slide { animation: lavabotSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
#lavabot-chatbox.lavabot-entrance-bounce { animation: lavabotBounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* Header */
.lavabot-chat-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.lavabot-chat-header-info {
    display: flex;
    flex-direction: column;
}

.lavabot-bot-name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

.lavabot-status-dot {
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Corpo das Mensagens */
#lavabot-chat-messages {
    flex-grow: 1;
    padding: 20px;
    background: #f7fafc;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Balões de Mensagem */
#lavabot-chatbox .lavabot-msg-row {
    display: flex !important;
    align-items: flex-end !important;
    gap: 10px !important;
    animation: lavabot-slide-up 0.3s ease forwards;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    width: 100% !important;
}

#lavabot-chatbox .lavabot-msg-row.lavabot-msg-user {
    flex-direction: row-reverse !important;
}

#lavabot-chatbox .lavabot-msg-bubble {
    padding: 12px 16px !important;
    border-radius: 16px !important;
    max-width: 80% !important;
    min-width: 40px !important;
    font-size: 13.5px !important;
    line-height: 1.5 !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: inline-block !important;
}

#lavabot-chatbox .lavabot-msg-row.lavabot-msg-bot .lavabot-msg-bubble {
    background: #ffffff !important;
    color: #2d3748 !important;
    border-radius: 16px 16px 16px 4px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
}

#lavabot-chatbox .lavabot-msg-row.lavabot-msg-user .lavabot-msg-bubble {
    color: #ffffff !important;
    border-radius: 16px 16px 4px 16px !important;
}

/* Rodapé / Input */
#lavabot-chat-footer {
    border-top: 1px solid #edf2f7;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
}

#lavabot-input-wrapper {
    flex-grow: 1;
}

/* Estilo dos Inputs */
.lavabot-input-field {
    width: 100%;
    border: 1px solid #cbd5e0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
}

.lavabot-input-field:focus {
    border-color: #a0aec0;
}

/* Opções de Múltipla Escolha */
.lavabot-options-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 5px;
}

.lavabot-option-btn {
    border: 1px solid #cbd5e0;
    background: #ffffff;
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.lavabot-option-btn:hover {
    background: #f7fafc;
    border-color: #a0aec0;
}

.lavabot-option-img-wrap {
    display: block;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 6px;
}

.lavabot-option-img {
    width: 100%;
    max-height: 110px;
    object-fit: cover;
    display: block;
}

.lavabot-option-text {
    display: block;
}

/* Botão Enviar */
#lavabot-send-btn {
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
}

#lavabot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(0.95);
}

/* Animações */
@keyframes lavabot-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes lavabot-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typing animation dots */
.lavabot-typing-bubble {
    background: #ffffff !important;
    border-radius: 16px 16px 16px 4px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
}

.lavabot-typing-dot {
    width: 6px;
    height: 6px;
    background-color: #718096;
    border-radius: 50%;
    display: inline-block;
    animation: lavabot-typing-bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes lavabot-typing-bounce {
    0%, 80%, 100% { 
        transform: scale(0);
    } 40% { 
        transform: scale(1.0);
    }
}

/* Posições de CTA Laterais */
.lavabot-pos-right #lavabot-cta-balloon.lavabot-cta-side {
    position: absolute;
    bottom: 10px;
    right: 80px; /* 65px width of button + 15px gap */
    margin-bottom: 0;
    max-width: 360px;
    animation: none; /* remove bounce to prevent clipping */
}

.lavabot-pos-left #lavabot-cta-balloon.lavabot-cta-side {
    position: absolute;
    bottom: 10px;
    left: 80px;
    margin-bottom: 0;
    max-width: 360px;
    animation: none; /* remove bounce */
}

/* Estilo do Botão Selecionado no Chat e Confirmação */
.lavabot-option-btn.lavabot-option-selected {
    background: #ebf8ff !important;
    color: #2b6cb0 !important;
    border-color: #90cdf4 !important;
    font-weight: 700 !important;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    /* !important necessário: a partir da personalização de "Tamanho da Caixa de Chat" (largura/
       altura), o widget passou a receber width/height inline no HTML — inline sempre vence uma
       regra de classe do stylesheet, então sem !important aqui o tamanho customizado do desktop
       vazaria pro mobile e quebraria o layout responsivo (mesma lógica de especificidade do
       BUG-006 documentado no ecossistema). */
    #lavabot-chatbox {
        width: calc(100vw - 30px) !important;
        height: calc(100vh - 120px) !important;
        bottom: 80px;
        right: 15px;
        position: fixed;
    }
    /* Balão no topo (posição padrão, não lateral): no desktop o max-width:360px + width:max-content
       (herdado da regra base) é adequado, mas no mobile 360px quase sempre sobra MENOS espaço que
       a tela disponível — o texto do CTA quebrava em várias linhas em vez de esticar e usar a
       largura real da tela. width:auto + max-width baseado no viewport (mesmo raciocínio já usado
       abaixo pra variante lateral) resolve. */
    #lavabot-cta-balloon:not(.lavabot-cta-side) {
        max-width: calc(100vw - 50px);
        width: auto;
    }
    .lavabot-pos-right #lavabot-cta-balloon.lavabot-cta-side {
        right: 75px;
        max-width: calc(100vw - 100px);
        width: auto;
    }
    .lavabot-pos-left #lavabot-cta-balloon.lavabot-cta-side {
        left: 75px;
        max-width: calc(100vw - 100px);
        width: auto;
    }
}

/* Botão com Link nas Mensagens */
.lavabot-msg-link-btn {
    display: inline-block;
    padding: 10px 18px;
    background-color: #0052cc;
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: background-color 0.2s;
}

.lavabot-msg-link-btn:hover {
    filter: brightness(0.95);
}

/* Novo Botão de Fechar no Header e Estado de Chat Ativo */
.lavabot-close-chat-btn {
    background: transparent !important;
    border: none !important;
    font-size: 28px !important;
    font-weight: 300 !important;
    cursor: pointer !important;
    color: inherit !important;
    padding: 0 !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    transition: background-color 0.2s !important;
    line-height: 1 !important;
    box-shadow: none !important;
}

.lavabot-close-chat-btn:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
}

/* Oculta o gatilho gigante e o CTA quando o chatbox estiver aberto */
#lavabot-widget.lavabot-chat-active #lavabot-trigger-btn,
#lavabot-widget.lavabot-chat-active #lavabot-cta-balloon {
    display: none !important;
}
