/* ==============================================
   CHATBOT FLUTUANTE DR. LUCAS LEITE (BLINDADO)
   VERSÃO MACGYVER V4.0 - ACABAMENTO PREMIUM
   ============================================== */

/* --- SCROLLBAR MODERNA --- */
#chatbot-container::-webkit-scrollbar { width: 6px; }
#chatbot-container::-webkit-scrollbar-track { background: transparent; }
#chatbot-container::-webkit-scrollbar-thumb { background: #cccccc; border-radius: 10px; }
#chatbot-container::-webkit-scrollbar-thumb:hover { background: #999999; }
#chatbot-container { position: fixed; z-index: 9999; max-width: 360px; bottom: 20px; left: 20px; font-family: "Open Sans", "Segoe UI", sans-serif !important; }

/* --- BUBBLE (O BALÃO FLUTUANTE INICIAL) --- */
#chatbot-bubble { 
    display: flex; 
    flex-direction: column; 
    align-items: flex-start; 
    justify-content: flex-end; 
    position: fixed; 
    z-index: 9999; 
    bottom: 20px; 
    left: 20px; 
    cursor: pointer; 
    transition: all 0.4s ease-in-out; 
    animation: chacoalha-lead 6s ease-in-out infinite;
}

/* 🛑 A TRAVA DE SEGURANÇA DO MACGYVER: 
   Garante que quando o JS esconder o balão, TUDO dentro dele suma de verdade! */
#chatbot-bubble[style*="visibility: hidden"] {
    opacity: 0 !important;
    pointer-events: none !important;
}
#chatbot-bubble[style*="visibility: hidden"] * {
    visibility: hidden !important;
    display: none !important;
}

.chatbot-bubble-avatar { 
    background-image: url('../img/avatar.jpg'); 
    border-radius: 50%; 
    background-size: cover; 
    width: 60px; 
    height: 60px; 
    border: 3px solid #ffffff; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    position: relative;
    z-index: 2;
    margin-top: 0px; 
    margin-left: 0px; 
}

.chatbot-bubble-avatar-online {  
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px; 
    height: 14px; 
    border-radius: 50%; 
    background-color: #25D366; 
    border: 2px solid #ffffff;
}

.chatbot-bubble-message { 
    background-color: #ff414c !important; 
    color: #ffffff !important;
    padding: 12px 20px !important;
    border-radius: 20px 20px 20px 20px !important; 
    font-family: 'Inter', sans-serif !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
    margin-right: 0 !important; 
    margin-bottom: 12px !important; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
    position: relative;
    cursor: pointer;
    border: 1px solid #ff414c !important; 
    transition: all 0.3s ease !important;
    transform-origin: bottom left !important; 
    max-width: 300px !important; 
    display: block !important; 
    transform: scale(1);
    overflow: visible; 
}

#chatbot-bubble:hover .chatbot-bubble-message { box-shadow: 0 6px 20px rgba(0,0,0,0.15); transform: translateY(-2px); }
#chatbot-bubble:hover .chatbot-bubble-avatar { box-shadow: 0 6px 20px rgba(0,0,0,0.2); transform: translateY(-2px); }

/* O Biquinho do Balão apontando pra BAIXO */
.notification-tail {
    position: absolute;
    bottom: -11px; 
    left: 20px; 
    top: auto; 
    right: auto; 
    transform: none; 
    width: 0; 
    height: 0; 
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 12px solid #ff414c; 
}

/* --- CAIXA PRINCIPAL DO CHAT --- */
#chatbot-box { 
    visibility: hidden; 
    position: relative; 
    z-index: 10000; 
    background-color: #ffffff; 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); 
    border-radius: 16px; 
    overflow: hidden;
    transition: all 0.4s ease-out; 
    display: flex;
    flex-direction: column;
    left: 20px;
}

/* --- CABEÇALHO --- */
.chatbot-box-header { 
    color: #fff; 
    background: linear-gradient(135deg, #000107, #1a1a24); 
    padding: 15px; 
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 2;
}

.chatbot-box-header-avatar { 
    background-image: url('../img/avatar.jpg'); 
    border-radius: 50%; 
    background-size: cover; 
    width: 45px; 
    height: 45px; 
    position: relative; 
    margin-right: 12px;
}

.chatbot-box-header-avatar-online { 
    position: absolute; 
    bottom: 0; 
    right: 0; 
    background: #25D366; 
    width: 12px; 
    height: 12px; 
    border-radius: 50%; 
    border: 2px solid #000107; 
}

.chatbot-box-header-status { font-size: 12px; color: #a0a0a0; margin-top: 2px;}
.chatbot-box-header-name { font-weight: bold; font-size: 15px; }

/* --- ÁREA DE MENSAGENS --- */
#chatbot-box-content { 
    height: 330px; 
    padding: 15px 15px 5px 15px; 
    overflow-y: auto; 
    background-color: #f8f9fa;
    scroll-behavior: smooth;
}

#chatbot-box-content > div { width: 100%; display: inline-block; clear: both; }

/* Mensagem do Robô (Esquerda) */
.chatbot-box-content-chat { 
    padding: 12px 16px; 
    max-width: 85%; 
    margin-bottom: 12px; 
    background: #ffffff !important; 
    color: #333333;
    border-radius: 0 16px 16px 16px; 
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    float: left;
}

/* Mensagem do Usuário (Direita) */
.chatbot-box-content-chat-right { 
    padding: 12px 16px; 
    max-width: 85%; 
    margin-bottom: 12px; 
    background: #000107 !important; 
    color: #ffffff; 
    border-radius: 16px 0 16px 16px; 
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    float: right;
}

/* --- BOTÕES DE OPÇÃO (ESTILO OUTLINE PREMIUM) --- */
.chatbot-btn { 
    margin: 8px 6px 0 0; 
    padding: 8px 14px; 
    border-radius: 20px; 
    display: inline-block; 
    cursor: pointer; 
    color: #ce0e0e; 
    background-color: #ffffff; 
    border: 1px solid #ce0e0e;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease; 
}
.chatbot-btn > * { pointer-events: none; }
.chatbot-btn:hover { background-color: #ce0e0e; color: #ffffff; box-shadow: 0 4px 10px rgba(206, 14, 14, 0.3); }

.chatbot-start { background-color: #ce0e0e; color: #ffffff; padding: 10px 18px; margin-top: 10px; border: none; box-shadow: 0 4px 10px rgba(206, 14, 14, 0.3); }
.chatbot-start:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(206, 14, 14, 0.4); }

/* --- RODAPÉ E INPUTS --- */
#chatbot-box-footer { 
    background-color: #ffffff; 
    padding: 15px; 
    position: relative;
    border-top: 1px solid #eeeeee;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
    box-sizing: border-box;
}

.chatbot-input { 
    display: none; 
    background-color: #f1f3f5 !important; 
    border: 1px solid transparent !important; 
    border-radius: 24px !important; 
    padding: 14px 50px 14px 20px !important; 
    width: 100% !important; 
    box-sizing: border-box !important; 
    font-size: 14px !important;
    color: #333 !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.03) !important;
    transition: all 0.3s ease;
}
.chatbot-input:focus { outline: none !important; border: 1px solid #ce0e0e !important; background-color: #ffffff !important; }
.chatbot-input-error { background-color: #fff0f0 !important; border: 1px solid #ffcccc !important; }

#chatbot-input-none { 
    display: block; 
    cursor: no-drop !important; 
    background-color: #f8f9fa !important; 
    color: #999 !important; 
}

/* --- BOTÕES DE ENVIAR --- */
#chatbot-send, #chatbot-not-send { 
    position: absolute; 
    bottom: 18px; 
    right: 20px; 
    width: 38px; 
    height: 38px; 
    border-radius: 50%; 
    transition: all 0.3s;
    z-index: 5;
}

#chatbot-send { 
    cursor: pointer; 
    background: #ce0e0e; 
    box-shadow: 0 4px 10px rgba(206, 14, 14, 0.3); 
}
#chatbot-send:hover { 
    background: #a80a0a; 
    transform: scale(1.05); 
}

#chatbot-not-send { 
    cursor: no-drop; 
    background-color: transparent; 
}
#chatbot-not-send svg path { 
    fill: #b0b0b0; 
}

#chatbot-send svg, #chatbot-not-send svg { 
    width: 20px !important; 
    height: 20px !important; 
    margin: 9px !important; 
}

/* --- ANIMAÇÃO DE DIGITANDO --- */
.lds-ellipsis-content { width: 100%; text-align: left; padding-left: 10px; }
.lds-ellipsis { display: inline-block; position: relative; width: 60px; height: 30px; }
.lds-ellipsis div { position: absolute; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: #ce0e0e; animation-timing-function: cubic-bezier(0, 1, 1, 0); }
.lds-ellipsis div:nth-child(1) { left: 6px; animation: lds-ellipsis1 0.6s infinite; }
.lds-ellipsis div:nth-child(2) { left: 6px; animation: lds-ellipsis2 0.6s infinite; }
.lds-ellipsis div:nth-child(3) { left: 24px; animation: lds-ellipsis2 0.6s infinite; }
.lds-ellipsis div:nth-child(4) { left: 42px; animation: lds-ellipsis3 0.6s infinite; }
@keyframes lds-ellipsis1 { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes lds-ellipsis3 { 0% { transform: scale(1); } 100% { transform: scale(0); } }
@keyframes lds-ellipsis2 { 0% { transform: translate(0, 0); } 100% { transform: translate(18px, 0); } }

/* --- MOTOR DA CHACOALHADA (CHAMAR ATENÇÃO) --- */
@keyframes chacoalha-lead {
    0%, 85%, 100% { transform: translateY(0) rotate(0deg); }
    88% { transform: translateY(-5px) rotate(-3deg); }
    91% { transform: translateY(-5px) rotate(3deg); }
    94% { transform: translateY(-5px) rotate(-3deg); }
    97% { transform: translateY(-5px) rotate(3deg); }
}