﻿:root {
    --chat-cor: #1976d2;
    --chat-cor-hover: #1565c0;
    --chat-cor-suave: #e3f0fb;
    --chat-texto: #1f2933;
    --chat-texto-2: #5f6b7a;
    --chat-texto-3: #8a94a3;
    --chat-linha: #e6e9ee;
    --chat-fundo: #ffffff;
    --chat-fundo-2: #f4f6f9;
    --chat-bolha-outro: #f2f2f2;
    --chat-bolha-minha: #3762fc;
    --chat-erro: #c62828;
    --chat-vista: #ffffff;
}

.chat-gatilho [hidden],
.chat-painel [hidden] {
    display: none !important;
}

.chat-gatilho {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 17px;
    cursor: pointer;
    transition: background 0.15s;
}

    .chat-gatilho:hover,
    .chat-gatilho[aria-expanded="true"] {
        background: rgba(0, 0, 0, 0.06);
    }

    .chat-gatilho:focus-visible {
        outline: 2px solid var(--chat-cor);
        outline-offset: 2px;
    }

.chat-gatilho-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    border: 2px solid #fff;
    background: #d93025;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 13px;
    text-align: center;
    box-sizing: border-box;
}

.chat-painel {
    position: fixed;
    top: 48px;
    right: 12px;
    z-index: 9000;
    width: 400px;
    height: 560px;
    max-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--chat-fundo);
    color: var(--chat-texto);
    font-family: 'Inter', 'Open Sans', Arial, sans-serif;
    border-radius: 0 0 4px 4px;
    border: 1px solid var(--chat-linha);
    border-top: 0;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.06);
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-4px);
    transform-origin: top right;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

    .chat-painel.aberto {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
    }

    .chat-painel *,
    .chat-painel *::before,
    .chat-painel *::after {
        box-sizing: border-box;
    }

.chat-view {
    display: none;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

    .chat-view.ativa {
        display: flex;
    }

.chat-topo {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 52px;
    padding: 8px 8px 8px 14px;
    border-bottom: 1px solid var(--chat-linha);
    flex-shrink: 0;
}

    .chat-topo .chat-topo-btn:first-child {
        margin-left: -6px;
    }

.chat-topo-titulo {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-family: inherit; /* h2: sem isso vinha a fonte de heading do tema, não a Inter do painel */
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--chat-texto);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-topo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--chat-texto-2);
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

    .chat-topo-btn:hover {
        background: var(--chat-fundo-2);
        color: var(--chat-texto);
    }

    .chat-topo-btn[data-chat-acao="nova"] {
        color: var(--chat-cor);
    }

    .chat-topo-btn:focus-visible,
    .chat-item:focus-visible,
    .chat-enviar:focus-visible {
        outline: 2px solid var(--chat-cor);
        outline-offset: -2px;
    }

.chat-lista {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    border-bottom: 1px solid var(--chat-fundo-2);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}

    .chat-item:hover {
        background: var(--chat-fundo-2);
    }

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: contain;
    background: var(--chat-fundo-2);
    border: 1px solid var(--chat-linha);
    flex-shrink: 0;
}

.chat-avatar-sm {
    width: 30px;
    height: 30px;
}

.chat-item-contato .chat-avatar {
    width: 34px;
    height: 34px;
}

/* modo dev: contato sem vínculo com o lado logado */
.chat-item-tag {
    flex-shrink: 0;
    margin-left: auto;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--chat-fundo-2);
    border: 1px solid var(--chat-linha);
    color: var(--chat-texto-3);
    font-size: 11px;
    white-space: nowrap;
}

.chat-selo-dev {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 4px;
    background: #1a1a2e;
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.6;
    vertical-align: middle;
}

.chat-lista-limite {
    padding: 8px 16px 12px;
    font-size: 12px;
    color: var(--chat-texto-3);
    text-align: center;
}

.chat-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item-nome {
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--chat-texto);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-previa {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    font-size: 13px;
    color: var(--chat-texto-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-previa-vazia {
    color: var(--chat-texto-3);
}

.chat-previa-status {
    font-size: 11px;
    color: var(--chat-texto-3);
    flex-shrink: 0;
}

.chat-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    flex-shrink: 0;
}

.chat-item-hora {
    font-size: 11px;
    color: var(--chat-texto-3);
}

.chat-contagem {
    min-width: 19px;
    height: 19px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--chat-cor);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 19px;
    text-align: center;
}

.chat-item-nao-lido .chat-item-nome {
    font-weight: 600;
}

.chat-item-nao-lido .chat-item-previa {
    color: var(--chat-texto);
}

.chat-item-nao-lido .chat-item-hora {
    color: var(--chat-cor);
    font-weight: 600;
}

.chat-vazio {
    padding: 36px 28px;
    text-align: center;
    font-size: 13px;
    line-height: 1.5;
    color: var(--chat-texto-3);
}

.chat-busca {
    position: relative;
    padding: 10px 14px;
    border-bottom: 1px solid var(--chat-fundo-2);
    flex-shrink: 0;
}

    .chat-busca i {
        position: absolute;
        left: 26px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 13px;
        color: var(--chat-texto-3);
        pointer-events: none;
    }

    .chat-busca input {
        width: 100%;
        height: 36px;
        padding: 0 12px 0 34px;
        border: 1px solid var(--chat-linha);
        border-radius: 8px;
        background: var(--chat-fundo);
        font: inherit;
        font-size: 13px;
        outline: none;
        transition: border-color 0.15s;
    }

        .chat-busca input:focus {
            border-color: var(--chat-cor);
        }

.chat-topo-titulo-conversa {
    font-size: 14px;
}

.chat-corpo {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 12px 10px;
    background: var(--chat-fundo);
    scrollbar-width: thin;
}

.chat-mensagens {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.chat-vazio--conversa {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 24px 28px 40px;
}

    .chat-vazio-anim {
        width: 132px;
        height: 96px;
        mix-blend-mode: multiply;
        opacity: .9;
        pointer-events: none;
    }

    .chat-vazio--conversa p {
        max-width: 240px;
        margin: 0;
    }

.chat-carregando,
.chat-inicio {
    padding: 10px 0 4px;
    text-align: center;
    font-size: 12px;
    color: var(--chat-texto-3);
}

.chat-dia {
    align-self: center;
    margin: 12px 0 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--chat-fundo-2);
    font-size: 11.5px;
    color: var(--chat-texto-2);
    user-select: none;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    margin-top: 2px;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

    .chat-msg.chat-msg-inicio-grupo {
        margin-top: 8px;
    }

    .chat-msg.is-new {
        opacity: 0;
        transform: translateY(6px);
    }

.chat-msg-outro-lado {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg-meu-lado {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg-nome {
    margin: 0 10px 2px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--chat-texto-2);
}

.chat-msg-bolha {
    position: relative;
    padding: 10px 14px 9px;
    border-radius: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.chat-msg-outro-lado .chat-msg-bolha {
    background: var(--chat-bolha-outro);
    color: var(--chat-texto);
}

.chat-msg-meu-lado .chat-msg-bolha {
    background: var(--chat-bolha-minha);
    color: #fff;
}

.chat-msg-texto {
    display: inline;
    margin: 0;
    white-space: pre-wrap;
}

.chat-msg-meta {
    float: right;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 6px 0 -2px 10px;
    font-size: 10.5px;
    line-height: 1;
    white-space: nowrap;
    opacity: 0.7;
}

.chat-msg-meu-lado .chat-msg-meta {
    opacity: 0.85;
}

.chat-msg-status {
    font-size: 10px;
}

.chat-msg-vista {
    color: var(--chat-vista);
}

.chat-item .chat-msg-vista {
    color: var(--chat-cor);
}

.chat-msg-pendente .chat-msg-bolha {
    opacity: 0.7;
}

.chat-msg-falhou {
    cursor: pointer;
}

    .chat-msg-falhou .chat-msg-bolha {
        background: #fdecea;
        color: var(--chat-texto);
        box-shadow: inset 0 0 0 1px #f5c2bd;
    }

.chat-msg-erro {
    margin: 3px 4px 0;
    font-size: 11.5px;
    color: var(--chat-erro);
}

.chat-rodape {
    padding: 8px 10px 10px;
    border-top: 1px solid var(--chat-linha);
    background: var(--chat-fundo);
    flex-shrink: 0;
}

.chat-rodape-aviso {
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff8e1;
    color: #7a5b00;
    font-size: 12px;
    line-height: 1.4;
}

.chat-compor {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 4px 4px 4px 12px;
    border: 1px solid var(--chat-linha);
    border-radius: 20px;
    background: var(--chat-fundo-2);
    transition: border-color 0.15s, background 0.15s;
}

    .chat-compor:focus-within {
        border-color: var(--chat-cor);
        background: var(--chat-fundo);
    }

.chat-texto {
    flex: 1;
    min-height: 34px;
    max-height: 120px;
    padding: 7px 0;
    border: 0;
    background: transparent;
    color: var(--chat-texto);
    font: inherit;
    font-size: 14px;
    line-height: 20px;
    resize: none;
    outline: none;
    overflow-y: auto;
    scrollbar-width: thin;
}

    .chat-texto:disabled {
        cursor: not-allowed;
    }

.chat-enviar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #3761fa; /* mesmo azul do logo Betha */
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, filter 0.15s, transform 0.1s;
}

    .chat-enviar:hover {
        filter: brightness(0.88);
    }

    .chat-enviar:active {
        transform: scale(0.94);
    }

    .chat-enviar:disabled {
        filter: grayscale(1);
        opacity: 0.45;
        cursor: not-allowed;
        transform: none;
    }

    .chat-enviar-logo {
        display: block;
        width: 20px;
        height: 20px;
        border-radius: 5px;
        pointer-events: none;
    }

.chat-contador {
    margin-top: 4px;
    padding-right: 6px;
    text-align: right;
    font-size: 11px;
    color: #b7791f;
}

    .chat-contador.chat-contador-limite {
        color: var(--chat-erro);
        font-weight: 600;
    }

@media (max-width: 480px) {
    .chat-painel {
        top: 48px;
        right: 8px;
        left: 8px;
        width: auto;
        height: calc(100vh - 56px);
        max-height: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-painel,
    .chat-painel.aberto,
    .chat-msg {
        transition: none;
    }

        .chat-msg.is-new {
            opacity: 1;
            transform: none;
        }
}

.chat-painel button,
.chat-painel input,
.chat-painel textarea {
    font-family: inherit;
}

.chat-texto-dica {
    position: absolute;
    left: 13px;
    right: 52px;
    top: 4px;
    line-height: 34px;
    font-size: 14px;
    color: var(--chat-texto-3);
    white-space: nowrap;
    overflow: hidden;
    pointer-events: none;
    transition: opacity .15s ease;
}

.chat-texto:not(:placeholder-shown) ~ .chat-texto-dica,
.chat-texto:disabled ~ .chat-texto-dica {
    opacity: 0;
}

    .chat-texto-dica.is-saindo {
        opacity: 0;
        transform: translateY(-3px);
        transition: opacity .8s ease, transform .8s ease;
    }
