/* =====================================================================
   agente-widget.css — HSJB Assist
   Widget flutuante único do portal, reutilizável em qualquer módulo.

   Personalização por módulo: a cor de destaque pode ser trocada via
   atributo "data-agente-cor" no elemento #agenteBotao (ver agente_widget.js),
   permitindo, se o hospital quiser no futuro, uma cor de header diferente
   por módulo (ex: NSP azul, Banco de Leite rosa, etc). Por padrão, todos
   os módulos usam a mesma paleta institucional abaixo.

   Z-INDEX: mantido abaixo do padrão típico do VLibras (>= 2147483000)
   para não conflitar com o botão de acessibilidade já implementado.
   ===================================================================== */

:root {
    --agente-cor-header:        #17324d;       /* azul-marinho do cabeçalho/botão */
    --agente-cor-header-escura: #0f2438;
    --agente-cor-accent:        #2f6fed;       /* azul do botão de enviar / links de ação */
    --agente-cor-online:        #22a55a;       /* verde do indicador "Online" */
    --agente-cor-fundo-corpo:   #f4f6f9;
    --agente-cor-balao-bot:     #ffffff;
    --agente-cor-balao-usuario: var(--agente-cor-accent);
    --agente-z-index: 1050;
}

/* ---------------------------------------------------------------------
   Botão flutuante
   --------------------------------------------------------------------- */
#agenteBotaoContainer {
    position: fixed;
    right: 24px;
    bottom: 135px;
    z-index: var(--agente-z-index);
    display: flex;
    flex-direction: column;
    align-items: center;
    /* align-items: flex-end; */
    gap: 0px;
}

.agente-badge-online {
    background-color: var(--agente-cor-online);
    color: #fff;
    font-size: .68rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
    letter-spacing: .02em;
}

#agenteBotao {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--agente-cor-header);
    color: #fff;
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    cursor: pointer;
    transition: transform .15s ease-in-out;
}

#agenteBotao:hover {
    transform: scale(1.06);
    background-color: var(--agente-cor-header-escura);
}

/* ---------------------------------------------------------------------
   Painel do chat
   --------------------------------------------------------------------- */
#agentePainel {
    position: fixed;
    right: 85px;
    bottom: 135px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 160px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
    z-index: var(--agente-z-index);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#agentePainel.aberto {
    display: flex;
}

/* Cabeçalho */
.agente-cabecalho {
    background-color: var(--agente-cor-header);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.agente-cabecalho-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, .15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.agente-cabecalho-titulo {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.agente-cabecalho-titulo h6 {
    margin: 0;
    font-weight: 700;
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agente-badge-modulo {
    background-color: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.agente-btn-fechar {
    background: transparent;
    border: none;
    color: #fff;
    opacity: .85;
    font-size: 1.1rem;
    line-height: 1;
    padding: 4px 6px;
    cursor: pointer;
    flex-shrink: 0;
}

.agente-btn-fechar:hover {
    opacity: 1;
}

/* Corpo (mensagens) */
.agente-corpo {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    background-color: var(--agente-cor-fundo-corpo);
}

/* Rodapé (input) */
.agente-rodape {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e9ecef;
    background: #fff;
}

.agente-input {
    flex: 1;
    border: 1px solid #d7dce2;
    border-radius: 999px;
    padding: 9px 16px;
    font-size: .88rem;
    outline: none;
}

.agente-input:focus {
    border-color: var(--agente-cor-accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}

.agente-btn-enviar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--agente-cor-accent);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color .12s;
}

.agente-btn-enviar:hover {
    background-color: #2158c6;
}

.agente-rodape-nota {
    text-align: center;
    font-size: .68rem;
    color: #9aa4b0;
    padding: 4px 0 10px;
    background: #fff;
}

/* Balões de mensagem */
.agente-msg {
    max-width: 90%;
    padding: 12px 15px;
    border-radius: 14px;
    margin-bottom: 10px;
    font-size: 1rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.agente-msg p { margin: 0 0 6px; }
.agente-msg p:last-child { margin-bottom: 0; }
.agente-msg ul { margin: 4px 0; padding-left: 18px; }

.agente-msg-bot {
    background-color: var(--agente-cor-balao-bot);
    color: #26313d;
    border: 1px solid #e6e9ee;
    border-bottom-left-radius: 3px;
    margin-right: auto;
}

.agente-msg-usuario {
    background-color: var(--agente-cor-balao-usuario);
    color: #fff;
    border-bottom-right-radius: 3px;
    margin-left: auto;
}

.agente-msg-acao {
    display: inline-block;
    margin-top: 8px;
    background-color: var(--agente-cor-accent);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 999px;
    text-decoration: none;
}

.agente-msg-acao:hover {
    background-color: #2158c6;
    color: #fff;
}

/* Feedback (👍/👎) sob a resposta */
.agente-feedback {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #e6e9ee;
    display: flex;
    align-items: center;
    gap: 6px;
}

.agente-feedback-pergunta {
    font-size: .8rem;
    color: #8a94a3;
    font-weight: 600;
}

.agente-feedback-btn {
    background: transparent;
    border: 1px solid #e6e9ee;
    border-radius: 999px;
    font-size: 1.2rem;
    line-height: 1;
    padding: 3px 8px;
    cursor: pointer;
    transition: background-color .12s, border-color .12s;
}

.agente-feedback-btn:hover {
    background-color: #eef3fb;
    border-color: var(--agente-cor-accent);
}

.agente-feedback-obrigado {
    font-size: .76rem;
    color: #8a94a3;
    font-style: italic;
}

/* Indicador "digitando" */
.agente-msg-digitando {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 11px 14px;
}

.agente-msg-digitando span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #b7c0cb;
    animation: agenteBounce 1.2s infinite ease-in-out;
}

.agente-msg-digitando span:nth-child(2) { animation-delay: .15s; }
.agente-msg-digitando span:nth-child(3) { animation-delay: .3s; }

@keyframes agenteBounce 
{
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40% { transform: translateY(-4px); opacity: 1; }
}


/* ---------------------------------------------------------------------
   Responsividade mobile
   --------------------------------------------------------------------- */
/*   @media (max-width: 480px)  */
@media (max-width: 768px) 
{
    #agentePainel {
        right: 10px;
        left: 10px;
        bottom: 84px;
        width: auto;
        height: calc(100vh - 150px);
    }

    #agenteBotaoContainer {
        right: 14px;
        bottom: 18px;
    }

    #agenteBotao {
        width: 54px;
        height: 54px;
        font-size: 1.4rem;
    }
}
