/* 
   Chatbot Nevinho - Estilo Modernizado (Vanilla CSS)
   Identidade: Azul Institucional
   Autor: Equipe STI
*/

:root {
    /* Paleta Institucional */
    --neves-blue-primary: #0056b3;   /* Cor Principal */
    --neves-blue-dark: #004494;      /* Hover / Fundo Escuro */
    --neves-blue-light: #e6f0ff;     /* Fundo de mensagens do bot / Botões claros */
    --neves-green: #28a745;          /* Ações de Sucesso / Links Externos */
    
    /* Neutros */
    --chat-bg: #f5f7fb;              /* Fundo da janela do chat */
    --text-main: #333333;
    --text-secondary: #666666;
    --white: #ffffff;
    --border-light: rgba(0,0,0,0.06);
    
    /* Sombras Suaves */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-float: 0 8px 25px rgba(0, 86, 179, 0.3);
}

/* Container Geral (Flutuante) */
#chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Outfit', 'Segoe UI', sans-serif; /* Usando fonte do site se disponível */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none; /* Permite clicar através da área vazia */
}

/* Balão de Saudação (Greeting Card Moderno) */
#chatbot-greeting.greeting-card {
    background-color: var(--white);
    color: var(--text-main);
    padding: 16px;
    border-radius: 16px;
    font-size: 14px;
    box-shadow: 0 8px 30px rgba(0, 50, 100, 0.15); /* Sombra mais azulada e suave */
    position: absolute;
    right: 75px;
    bottom: 20px;
    width: 260px;
    
    /* Animação */
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    visibility: hidden;
    pointer-events: auto;
    
    border: 1px solid rgba(255, 255, 255, 0.5); /* Borda sutil */
    cursor: pointer; /* Indica clicável */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#chatbot-greeting.greeting-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(0, 50, 100, 0.2);
}

#chatbot-greeting.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

/* Elementos Internos do Card */
.greeting-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--neves-blue-primary);
    font-family: 'Outfit', sans-serif;
}

.greeting-emoji {
    font-size: 18px;
    animation: wave 2s infinite;
    transform-origin: 70% 70%;
}

@keyframes wave {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60% { transform: rotate(0deg); } /* Pausa */
    100% { transform: rotate(0deg); }
}

#chatbot-greeting p {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary);
}

.greeting-action {
    font-size: 12px;
    font-weight: 600;
    color: var(--neves-blue-primary);
    text-align: right;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Seta indicativa (Triangle) */
#chatbot-greeting::after {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 25px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid var(--white);
    filter: drop-shadow(2px 0 2px rgba(0,0,0,0.05));
    display: block;
}

/* Botão Flutuante (Toggle) Moderno e Animado */
#chatbot-toggle-btn {
    width: 64px;
    height: 64px;
    background: var(--neves-blue-primary); /* Fundo sólido de base */
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    position: relative;
    pointer-events: auto;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
    /* Sombra profunda */
    box-shadow: 0 4px 15px rgba(0, 86, 179, 0.35); 
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001; /* Garante que fique acima de tudo */
}

#chatbot-toggle-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--white); 
    position: relative;
    z-index: 2; /* Fica acima do pulso */
    background: var(--white);
    transition: border-color 0.3s;
}

/* Badge de Notificação ("1") */
#chatbot-toggle-btn::after {
    content: '1';
    position: absolute;
    top: 0;
    right: 0;
    background-color: #ff3b30; /* Vermelho alerta padrão iOS */
    color: white;
    font-size: 11px;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--white);
    z-index: 3;
    animation: bounceIn 0.6s 1.5s backwards; /* Delay para aparecer depois do greeting */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Animação de Pulso (Onda) */
#chatbot-toggle-btn::before {
    content: '';
    position: absolute;
    top: -2px; right: -2px; bottom: -2px; left: -2px;
    border-radius: 50%;
    border: 2px solid var(--neves-blue-primary);
    opacity: 0;
    z-index: 1;
    animation: ripple 2.5s infinite ease-out;
}

@keyframes ripple {
    0% { transform: scale(1); opacity: 0.6; border-width: 2px; }
    100% { transform: scale(1.6); opacity: 0; border-width: 0px; }
}

@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

#chatbot-toggle-btn:hover {
    transform: scale(1.08); /* Efeito suave de crescimento */
    box-shadow: 0 8px 25px rgba(0, 86, 179, 0.5);
}

/* Quando hover no botão, remove a borda branca da imagem para um look mais clean */
#chatbot-toggle-btn:hover img {
    border-color: rgba(255,255,255,0.8);
}

/* Janela do Chat (Window) */
#chatbot-window {
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background-color: var(--chat-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 85px;
    right: 0;
    
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    
    border: 1px solid var(--border-light);
}

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

/* Cabeçalho (Header) */
.chat-header {
    background: linear-gradient(135deg, var(--neves-blue-primary) 0%, var(--neves-blue-dark) 100%);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.chat-header .chat-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header .chat-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--white);
    border: 2px solid rgba(255,255,255,0.3);
}

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

.chat-header .chat-profile-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-header .chat-profile-info span {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}
/* Bolinha verde de online */
.chat-header .chat-profile-info span::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background-color: #4cd137;
    border-radius: 50%;
}

/* Botões do Header (Minimizar, Fonte) */
#minimize-chat-btn, .font-control-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: var(--white);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%; /* Redondos ficam mais modernos aqui */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-family: monospace; /* Para o A+ A- */
    font-weight: bold;
}

#minimize-chat-btn:hover, .font-control-btn:hover {
    background: rgba(255,255,255,0.35);
}

/* Corpo do Chat */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Scrollbar Bonita */
.chat-body::-webkit-scrollbar {
    width: 6px;
}
.chat-body::-webkit-scrollbar-track {
    background: transparent;
}
.chat-body::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 10px;
}

/* Mensagens */
@keyframes messageSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    animation: messageSlideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Mensagem do Bot */
.bot-message {
    background-color: var(--white);
    color: var(--text-main);
    border-bottom-left-radius: 4px; /* Orelha do balão */
    align-self: flex-start;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.03);
}

/* Mensagem do Usuário */
.user-message {
    background: var(--neves-blue-primary);
    color: var(--white);
    border-bottom-right-radius: 4px; /* Orelha do balão */
    align-self: flex-end;
    box-shadow: var(--shadow-sm);
}

/* Mensagens de Alerta (Avisos) */
.alert-message {
    border-left-width: 4px !important;
    border-radius: 8px !important;
    font-size: 14px;
    max-width: 90%;
}

/* Botões de Opção */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    animation: messageSlideUp 0.4s ease-out forwards;
    animation-delay: 0.1s; /* Delay para aparecer depois do texto */
    opacity: 0; /* Começa invisível */
    animation-fill-mode: forwards;
}

.option-btn {
    background-color: var(--neves-blue-light); /* Azul bem clarinho */
    border: 1px solid transparent;
    color: var(--neves-blue-primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.option-btn:hover {
    background-color: var(--neves-blue-primary);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 86, 179, 0.2);
}

/* Links Externos (Actions) */
a.option-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

/* Indicador de Digitação (Typing) */
#typing-indicator {
    background-color: transparent;
    box-shadow: none;
    padding: 0;
    margin-left: 10px;
    color: #999;
}
/* Criando as bolinhas animadas via CSS puro */
#typing-indicator::after {
    content: '...';
    animation: typing 1.5s infinite steps(4);
    font-weight: bold;
    font-size: 20px;
    display: inline-block;
    width: 20px;
    text-align: left;
}
@keyframes typing {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Rodapé (Input) */
.chat-footer {
    padding: 16px;
    background-color: var(--white);
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-light);
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    outline: none;
    font-size: 15px;
    background: #FAFAFA;
    transition: all 0.2s;
    color: var(--text-main);
}

#chat-input:focus {
    border-color: var(--neves-blue-primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

#send-btn {
    background: var(--neves-blue-primary);
    color: var(--white);
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 86, 179, 0.2);
}

#send-btn:hover {
    background: var(--neves-blue-dark);
    transform: scale(1.05);
}

#send-btn i {
    font-size: 16px;
    margin-left: -2px; /* Ajuste visual óptico */
}

/* Responsividade Mobile */
@media (max-width: 480px) {
    #chatbot-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
        z-index: 10000;
    }

    #chatbot-toggle-btn {
        margin-right: 10px;
        margin-bottom: 10px;
    }

    #chatbot-greeting {
        display: none; /* Hide greeting on mobile to avoid clutter */
    }

    .chat-header {
        padding-top: max(16px, env(safe-area-inset-top)); /* Notch support */
    }
}
