/* Janela flutuante do chat (canto inferior direito), balões e painéis de grupo. */

.ch-box { position: fixed; right: 20px; bottom: 0; z-index: 45; }
.ch-janela {
  width: 360px; height: min(560px, calc(100vh - 90px));
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 32px rgb(0 0 0 / .16);
  overflow: hidden;
}
.ch-janela.minimizada { height: auto; }
.ch-janela.minimizada > :not(.ch-cabeca) { display: none !important; }
.ch-janela.minimizada .ch-cabeca { cursor: pointer; }

.ch-cabeca {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 56px; padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--line);
}
.ch-titulo {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  border: 0; background: none; padding: 0; text-align: left; cursor: default;
}
button.ch-titulo[title="Dados do grupo"] { cursor: pointer; }
.ch-titulo > span { display: flex; flex-direction: column; min-width: 0; }
.ch-titulo b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-titulo small { color: var(--muted); font-size: 11.5px; }
.ch-botoes { display: flex; gap: 4px; flex: none; }
.ch-cabeca .ico { width: 30px; height: 30px; border-color: transparent; background: transparent; }
.ch-cabeca .ico:hover { background: var(--bg); }

.ch-mensagens {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
  padding: 12px 12px 8px;
  background: var(--bg);
}
.ch-vazio { margin: auto; color: var(--faint); font-size: 13px; text-align: center; }
.ch-mais {
  align-self: center; margin-bottom: 8px; padding: 4px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted);
  font-size: 12px; cursor: pointer;
}
.ch-dia { display: flex; justify-content: center; margin: 10px 0 6px; }
.ch-dia span { padding: 2px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.ch-sistema { align-self: center; max-width: 90%; margin: 6px 0; color: var(--muted); font-size: 11.5px; text-align: center; }

.ch-msg {
  align-self: flex-start; max-width: 82%;
  display: flex; flex-direction: column;
  margin-top: 6px; padding: 6px 10px 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px 12px 12px 12px;
}
.ch-msg.minha { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-radius: 12px 4px 12px 12px; }
.ch-msg.seguida { margin-top: 2px; border-radius: 12px; }
.ch-msg.pendente { opacity: .65; }
.ch-autor { font-size: 12px; font-weight: 600; }
.ch-texto { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.ch-hora { align-self: flex-end; color: var(--faint); font-size: 10.5px; }

.ch-rodape { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.ch-campo {
  flex: 1; min-height: 38px; max-height: 120px; resize: none;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 19px;
  background: var(--bg); outline: none; line-height: 1.35;
}
.ch-campo:focus { border-color: var(--accent); }
.ch-enviar {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--wpp); color: #fff; cursor: pointer;
}
.ch-enviar svg { width: 17px; height: 17px; }

/* painéis */
.ch-painel { flex: 1; overflow-y: auto; padding: 14px; }
.ch-escolher, .ch-grupo { display: flex; flex-direction: column; gap: 10px; }
.ch-pessoas { display: flex; flex-direction: column; gap: 2px; }
.ch-pessoa { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: var(--radius-sm); cursor: pointer; }
.ch-pessoa:hover { background: var(--bg); }
.ch-pessoa > span:not(.avatar):not(.ch-admin):not(.ch-acoes-membro) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-grupo .ch-pessoa { cursor: default; flex-wrap: wrap; }
.ch-admin { padding: 1px 7px; border-radius: 999px; background: var(--e-contatado); color: var(--wpp); font-size: 11px; font-weight: 600; }
.ch-acoes-membro { display: flex; gap: 10px; margin-left: auto; }
.ch-rotulo { margin: 4px 0 -4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.ch-erro { margin: 0; color: var(--bad); font-size: 12.5px; }

.btn-link { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12px; cursor: pointer; }
.btn-link.perigo, .btn-linha.perigo { color: var(--bad); }
.btn-link:disabled { opacity: .5; }
.btn-linha {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 6px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; cursor: pointer;
}
.btn-linha:hover { background: var(--bg); }
.btn-linha svg { width: 17px; height: 17px; color: var(--muted); }

.ch-aviso {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 16px;
  border-radius: var(--radius-sm); background: var(--text); color: var(--bg); font-size: 13px;
}

@media (max-width: 560px) {
  .ch-box { inset: 0; }
  .ch-janela, .ch-janela.minimizada { width: 100%; height: 100%; border-radius: 0; }
  .ch-janela.minimizada { position: fixed; left: 0; right: 0; bottom: 0; height: auto; }
  .ch-box:has(.minimizada) { inset: auto 0 0 0; }
}

/* foto e áudio */
.ch-anexar { width: 34px; height: 38px; flex: none; color: var(--muted); }
.ch-anexar svg { width: 19px; height: 19px; }
.ch-msg.com-anexo { padding: 4px 4px 4px; gap: 4px; }
.ch-msg.com-anexo .ch-autor, .ch-msg.com-anexo .ch-texto { padding: 0 6px; }
.ch-msg.com-anexo .ch-hora { padding: 0 6px 2px; }
.ch-foto { display: block; max-width: min(240px, 100%); max-height: 300px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.ch-audio { display: block; width: 240px; max-width: 100%; height: 40px; }
.ch-anexo-carregando { padding: 18px 12px; color: var(--muted); font-size: 12.5px; }
.ch-gravando { display: flex; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--line); font-size: 13.5px; }
.ch-gravando[hidden] { display: none; }
.ch-gravando .ch-enviar { margin-left: auto; }
.ch-rel { font-variant-numeric: tabular-nums; color: var(--muted); }
.ch-rec { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: ch-pisca 1s infinite; }
@keyframes ch-pisca { 50% { opacity: .25; } }
