/* ---------- chat do painel lateral ---------- */
/* Trilho de conversas à esquerda, cabeçalho da conversa, mensagens agrupadas e compositor. */
#panel.com-chat { width: 404px; }
body:has(#panel.com-chat:not([hidden])) #videos-pessoas { right: 428px; }
body:has(#panel.com-chat:not([hidden])) #toasts { right: 430px; }
.aba-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; vertical-align: 1px; }

#tab-chat { display: flex; overflow: hidden; min-height: 0; }
.chat-principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.so-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* trilho */
.chat-trilho { --trilho: #0f0d18; width: 64px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; background: var(--trilho); border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: none; }
.conversa { position: relative; width: 56px; flex: none; display: grid; justify-items: center; gap: 3px; padding: 3px 0 4px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); }
.conversa::before { content: ""; position: absolute; left: -4px; top: 24px; width: 4px; height: 0; border-radius: 0 4px 4px 0; background: var(--text); transform: translateY(-50%); transition: height .15s; }
.conversa.nao-lida::before { height: 8px; }
.conversa:hover::before { height: 20px; }
.conversa.atual::before { height: 36px; }
.conversa-icone { position: relative; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--text); transition: border-radius .15s, background .15s; }
.conversa-icone svg { width: 20px; height: 20px; }
.conversa-icone .portrait { width: 42px; height: 42px; border-radius: inherit; display: block; }
.conversa:hover .conversa-icone { border-radius: 14px; background: var(--surface-3); }
.conversa.atual .conversa-icone { border-radius: 14px; background: var(--accent); color: #fff; }
.conversa.offline .conversa-icone .portrait { filter: grayscale(1) brightness(.7); }
.conversa-status { position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--trilho); }
.conversa-badge { position: absolute; top: 28px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 3px var(--trilho); }
.conversa-rotulo { max-width: 56px; font-size: 10.5px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversa.atual .conversa-rotulo, .conversa.nao-lida .conversa-rotulo, .conversa:hover .conversa-rotulo { color: var(--text); }
.conversa-sep { width: 32px; height: 2px; flex: none; border-radius: 1px; background: var(--line); margin: 4px 0; }
.conversa.nova .conversa-icone { background: transparent; border: 2px dashed var(--line); color: var(--accent-2); }
.conversa.nova:hover .conversa-icone { border-color: var(--accent-2); background: rgba(34, 211, 238, .1); }
.conversa.nova::before { display: none; }

/* cabeçalho */
.chat-cabecalho { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); box-shadow: 0 1px 6px rgba(0, 0, 0, .18); }
.chat-cabecalho-icone { display: grid; place-items: center; flex: none; color: var(--muted); }
.chat-cabecalho-icone svg { width: 22px; height: 22px; }
.chat-cabecalho-icone .portrait { width: 28px; height: 28px; }
.chat-cabecalho-texto { flex: 1; min-width: 0; }
.chat-cabecalho h3 { margin: 0; display: flex; gap: 4px; align-items: baseline; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cerquilha { color: var(--muted); font-weight: 500; }
.chat-cabecalho p { margin: 1px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-cabecalho-acoes { display: flex; gap: 2px; }
.chat-acao { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.chat-acao:hover { background: var(--surface-3); color: var(--text); }
.chat-acao svg { width: 17px; height: 17px; }

/* lista de mensagens */
.chat-area { position: relative; flex: 1; min-height: 0; display: flex; }
.chat-mensagens { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 0 18px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.chat-inicio { padding: 18px 16px 6px; }
.chat-inicio-icone { width: 64px; height: 64px; margin-bottom: 10px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text); overflow: hidden; }
.chat-inicio-icone svg { width: 32px; height: 32px; }
.chat-inicio-icone .portrait { width: 64px; height: 64px; }
.chat-inicio h4 { margin: 0 0 4px; font-size: 20px; font-weight: 800; overflow-wrap: anywhere; }
.chat-inicio p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.chat-dia { display: flex; align-items: center; margin: 18px 14px 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.chat-dia::before, .chat-dia::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.chat-dia span { padding: 0 8px; }
.chat-novas { position: relative; height: 0; margin: 12px 14px 8px 0; border-top: 1px solid var(--danger); }
.chat-novas span { position: absolute; right: 0; top: -8px; padding: 1px 6px; border-radius: 4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; line-height: 14px; letter-spacing: .04em; text-transform: uppercase; }

.msg { position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr); margin-top: 14px; padding: 3px 12px 3px 0; outline: none; }
.msg.continua { margin-top: 0; padding-top: 1px; padding-bottom: 1px; }
.msg:hover, .msg:focus-within, .msg.ativa { background: rgba(255, 255, 255, .035); }
.msg:focus-visible { box-shadow: inset 2px 0 0 var(--accent-2); }
.msg.mencao { background: rgba(250, 204, 21, .07); box-shadow: inset 2px 0 0 var(--warn); }
.msg.mencao:hover { background: rgba(250, 204, 21, .1); }
.msg.destaque { animation: chat-destaque 1.8s ease-out; }
@keyframes chat-destaque { from { background: rgba(168, 85, 247, .32); } to { background: transparent; } }

.msg-resposta { position: relative; grid-column: 2; display: flex; align-items: center; gap: 5px; min-width: 0; margin: 0 0 3px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; text-align: left; }
.msg-resposta::before { content: ""; position: absolute; left: -29px; top: 50%; width: 24px; height: 11px; border-left: 2px solid var(--surface-3); border-top: 2px solid var(--surface-3); border-top-left-radius: 6px; }
.msg-resposta .portrait { width: 16px; height: 16px; flex: none; }
.msg-resposta strong { color: var(--text); font-weight: 600; white-space: nowrap; opacity: .85; }
.msg-resposta-texto { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
button.msg-resposta:hover strong, button.msg-resposta:hover .msg-resposta-texto { color: var(--text); opacity: 1; }
.msg-resposta.excluida { font-style: italic; }

.msg-lateral { grid-column: 1; display: flex; justify-content: center; align-items: flex-start; padding-top: 2px; }
.msg-avatar { width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; }
.msg-avatar .portrait { width: 40px; height: 40px; display: block; }
.msg-avatar:hover { filter: brightness(1.12); }
.msg-hora-curta { visibility: hidden; color: var(--muted); font-size: 10.5px; line-height: 20px; }
.msg:hover .msg-hora-curta, .msg:focus-within .msg-hora-curta, .msg.ativa .msg-hora-curta { visibility: visible; }

.msg-conteudo { grid-column: 2; min-width: 0; }
.msg-topo { display: flex; align-items: baseline; gap: 6px; min-width: 0; line-height: 1.3; }
.msg-autor { max-width: 60%; padding: 0; border: 0; background: none; color: var(--text); font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-autor:hover { text-decoration: underline; }
.msg-autor.admin { color: #c084fc; }
.msg-autor.god { color: #fbbf24; }
.msg-cargo { flex: none; align-self: center; padding: 1px 4px; border-radius: 4px; background: rgba(168, 85, 247, .2); color: #d8b4fe; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; }
.msg-cargo.god { background: rgba(251, 191, 36, .18); color: #fcd34d; }
.msg-topo time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.msg-texto { color: #e7e2f5; font-size: 14px; line-height: 1.42; overflow-wrap: anywhere; }
.msg-paragrafo, .msg-citacao { white-space: pre-wrap; }
.msg-texto.jumbo { font-size: 34px; line-height: 1.25; }
.msg-texto a { color: var(--accent-2); text-decoration: none; }
.msg-texto a:hover { text-decoration: underline; }
.msg-codigo { padding: 0 4px; border: 1px solid var(--line); border-radius: 4px; background: #0d0b16; font-family: Consolas, "Cascadia Code", ui-monospace, monospace; font-size: 12.5px; }
.msg-bloco { max-height: 300px; margin: 4px 0; padding: 8px 10px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: #0d0b16; font-family: Consolas, "Cascadia Code", ui-monospace, monospace; font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; }
.msg-citacao { margin: 2px 0; padding-left: 10px; border-left: 4px solid var(--surface-3); }
.mencao { padding: 0 2px; border-radius: 3px; background: rgba(168, 85, 247, .22); color: #e9d5ff; font-weight: 600; }
.mencao.eu { background: rgba(250, 204, 21, .22); color: #fde68a; }
.spoiler { border-radius: 3px; background: rgba(255, 255, 255, .08); }
.spoiler:not(.revelado) { background: #3a3354; color: transparent; cursor: pointer; }
.spoiler:not(.revelado) * { visibility: hidden; }
.spoiler:not(.revelado):hover { background: #4a4170; }
.msg-editada { color: var(--muted); font-size: 10.5px; }

.msg-reacoes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reacao { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 7px; border: 1px solid transparent; border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 600; }
.reacao:hover { border-color: var(--line); }
.reacao.minha { border-color: var(--accent); background: rgba(168, 85, 247, .18); color: #e9d5ff; }
.reacao-emoji { font-size: 15px; line-height: 1; }
.reacao.adicionar { padding: 0 5px; color: var(--muted); opacity: 0; }
.reacao.adicionar svg { width: 16px; height: 16px; }
.msg:hover .reacao.adicionar, .msg:focus-within .reacao.adicionar, .msg.ativa .reacao.adicionar { opacity: 1; }

.msg-acoes { position: absolute; top: -15px; right: 10px; z-index: 2; display: none; align-items: center; gap: 1px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
.msg:hover .msg-acoes, .msg:focus-within .msg-acoes, .msg.ativa .msg-acoes { display: flex; }
.msg-acao { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 15px; }
.msg-acao:hover { background: var(--surface-3); color: var(--text); }
.msg-acao.rapida { transition: transform .1s; }
.msg-acao.rapida:hover { transform: scale(1.15); }
.msg-acao.perigo:hover { color: var(--danger); }
.msg-acao svg { width: 17px; height: 17px; }
.msg-acoes-sep { width: 1px; height: 18px; margin: 0 2px; background: var(--line); }

.chat-presente { position: absolute; left: 10px; right: 10px; bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px 5px 12px; border-radius: 8px; background: var(--surface-3); box-shadow: 0 4px 16px rgba(0, 0, 0, .4); color: var(--muted); font-size: 12px; }
.chat-presente.com-novas { background: var(--accent); color: #fff; font-weight: 600; }
.chat-presente button { padding: 4px 10px; border: 0; border-radius: 6px; background: rgba(0, 0, 0, .25); color: #fff; font-size: 12px; font-weight: 700; }
.chat-presente button:hover { background: rgba(0, 0, 0, .4); }

/* compositor */
.chat-compositor { position: relative; padding: 0 12px; }
.chat-modo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: #181528; color: var(--muted); font-size: 12.5px; }
.chat-modo strong { color: var(--text); }
.chat-modo kbd { font-size: 11px; padding: 0 4px; }
.chat-modo .chat-acao { width: 24px; height: 24px; }
.chat-caixa { display: flex; align-items: flex-end; gap: 2px; padding: 3px 4px 3px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.chat-compositor.com-modo .chat-caixa { border-radius: 0 0 10px 10px; }
.chat-caixa:focus-within { border-color: var(--accent); }
#chat-input { flex: 1; min-width: 0; max-height: 160px; padding: 8px 0; border: 0; outline: none; resize: none; background: transparent; color: var(--text); font-size: 14px; line-height: 1.4; }
#chat-input::placeholder { color: #7d7699; }
#chat-input:disabled { cursor: not-allowed; }
.chat-botao { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.chat-botao:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.chat-botao:disabled { opacity: .4; cursor: not-allowed; }
.chat-botao.enviar { color: var(--accent); }
.chat-caixa:has(#chat-input:placeholder-shown) .chat-botao.enviar { opacity: .35; }
.chat-compositor.enviando .chat-botao.enviar { opacity: .5; cursor: progress; }
.chat-rodape { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; padding: 3px 2px 5px; color: var(--muted); font-size: 11.5px; }
.chat-digitando { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.chat-digitando > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.chat-digitando strong { color: var(--text); }
.pontinhos { display: inline-flex; gap: 2px; }
.pontinhos i { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); animation: chat-pontinho 1.2s infinite; }
.pontinhos i:nth-child(2) { animation-delay: .15s; }
.pontinhos i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-pontinho { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
.chat-contador { flex: none; font-variant-numeric: tabular-nums; }
.chat-contador.esgotando { color: var(--danger); font-weight: 700; }

/* menções e menus flutuantes */
.chat-sugestoes { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 4px); z-index: 5; max-height: 250px; overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.chat-sugestoes-titulo { padding: 2px 6px 6px; color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.chat-sugestao { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.chat-sugestao .portrait { width: 22px; height: 22px; }
.chat-sugestao span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-sugestao.ativa, .chat-sugestao:hover { background: var(--surface-3); }
.chat-popover { position: absolute; z-index: 6; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.chat-emojis { display: grid; grid-template-columns: repeat(7, 36px); gap: 2px; padding: 8px; }
.chat-emojis button { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; font-size: 20px; }
.chat-emojis button:hover, .chat-emojis button:focus-visible { background: var(--surface-3); }
.chat-nova-dm { width: 260px; display: grid; gap: 8px; padding: 12px; }
.chat-nova-dm h4 { margin: 0; font-size: 14px; }
.chat-nova-dm input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); }
.chat-nova-dm input:focus { border-color: var(--accent); outline: none; }
.chat-nova-dm-lista { display: grid; gap: 2px; max-height: 260px; overflow: auto; }
.chat-nova-dm-pessoa { display: flex; align-items: center; gap: 8px; padding: 6px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; }
.chat-nova-dm-pessoa:hover, .chat-nova-dm-pessoa:focus-visible { background: var(--surface-3); }
.chat-nova-dm-pessoa .portrait { width: 28px; height: 28px; }
.chat-nova-dm-pessoa .nome { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.chat-previa-exclusao { max-height: 180px; margin: 0; padding: 8px 10px; overflow: auto; border-left: 3px solid var(--danger); border-radius: 6px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-previa-exclusao strong { display: block; margin-bottom: 2px; }
.primary.perigo { background: var(--danger); }

@media (max-width: 820px) {
  #panel.com-chat { width: auto; }
  body:has(#panel.com-chat:not([hidden])) #videos-pessoas { right: 12px; }
  body:has(#panel.com-chat:not([hidden])) #toasts { right: 14px; }
  .chat-trilho { width: 58px; }
  .msg-acoes { right: 4px; }
}
