/* conversa.css — Área da conversa, relatório na tela e toasts.
   Parte de painel.css, dividido em 13/09/2026: um arquivo de 3.782 linhas
   não se navega. A ORDEM dos <link> no index.html importa (cascata). */

/* ---------- área da conversa ---------- */
#conversa { display: flex; flex-direction: column; min-width: 0; background: var(--fundo); }

/* ---------- relatório "Todos": métricas por atendimento ---------- */
#relatorio { flex: 1; overflow-y: auto; padding: 22px 26px; min-height: 0; }
#relatorio > header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
#relatorio h2 { font-size: 17px; font-weight: 700; font-family: var(--fonte-titulo); }
#relatorio-total { font-size: 12px; color: var(--texto-2); }
.rel-vao { flex: 1; }
.rel-dica { font-size: 11.5px; color: var(--texto-3); }
#relatorio-tabela {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--r-l);
  overflow: auto;
}
#relatorio-tabela table { width: 100%; border-collapse: collapse; }
#relatorio-tabela th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--texto-3);
  padding: 11px 14px;
  border-bottom: 1px solid var(--borda);
  white-space: nowrap;
}
#relatorio-tabela td {
  padding: 11px 14px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--fundo);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
#relatorio-tabela tr[data-id] { cursor: pointer; }
#relatorio-tabela tr[data-id]:hover td { background: var(--verde-tinta); }
#relatorio-tabela tr:last-child td { border-bottom: 0; }
#relatorio-tabela td small { display: block; color: var(--texto-3); font-size: 11px; margin-top: 1px; }
.rel-cliente { display: flex; align-items: center; gap: 10px; }
.rel-cliente .avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-s);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.rel-cliente b { font-size: 13px; font-weight: 600; }
.rel-cliente b i { font-style: normal; font-weight: 400; color: var(--texto-3); }
.rel-cliente small.perdida { color: var(--alerta); font-weight: 600; }
.rel-cliente small.esperando { color: var(--ambar-700); font-weight: 600; }
.aval.boa { color: var(--verde-texto); font-weight: 600; }
.aval.ruim { color: var(--alerta); font-weight: 600; }
.rel-nada { padding: 32px; color: var(--texto-3); font-size: 13px; text-align: center; }

/* ---------- toasts de mensagem recebida (canto inferior direito) ---------- */
#toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 65;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}
.toast {
  background: var(--verde-600);
  color: #fff;
  border-radius: var(--r-l);
  padding: 10px 12px 12px;
  box-shadow: var(--sombra-2);
  animation: alerta-entra .25s ease-out;
  width: 300px;
}
.toast-titulo {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .85;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toast-x { background: none; border: 0; color: #fff; opacity: .7; font-size: 15px; line-height: 1; padding: 0 2px; }
.toast-x:hover { opacity: 1; }
.toast-quem { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; min-width: 0; }
.toast-quem b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-avatar {
  width: 28px; height: 28px;
  border-radius: var(--r-s);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.toast-texto { font-size: 12.5px; margin: 6px 0 10px; opacity: .95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-acoes { display: flex; gap: 8px; }
.toast-responder {
  background: #fff;
  color: var(--verde-700);
  border: 0;
  border-radius: var(--r-s);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
}
.toast-ignorar {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border: 0;
  border-radius: var(--r-s);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}
.toast-ignorar:hover { background: rgba(255, 255, 255, .26); }
/* conversa SUA: toast cinza (rotina); verde fica para conversa de outro atendente */
.toast.minha { background: #454d5c; }
.toast.minha .toast-responder { color: #454d5c; }
#vazio {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--texto-3);
}
#vazio h2 { font-size: 15px; font-weight: 600; color: var(--texto-2); margin-top: 10px; }
#vazio p { font-size: 13px; }
#vazio .atalhos {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 12px;
  color: var(--texto-3);
}
#vazio .atalhos span { display: inline-flex; align-items: center; gap: 5px; }
#vazio kbd {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 11px;
  color: var(--texto-2);
}

#chat { flex: 1; display: flex; min-height: 0; }
#chat-principal { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

#chat-cabecalho {
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
  padding: 11px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 2;
}
#chat-cabecalho .info { display: flex; align-items: center; gap: 11px; }
#chat-cabecalho .mini-avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-avatar);
  background: var(--verde-600);
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#chat-cabecalho .info .nome { font-size: 15.5px; font-weight: 600; font-family: var(--fonte-titulo); }
#chat-cabecalho .info .nome .emp { font-weight: 400; color: var(--texto-2); font-size: 13px; }
#chat-cabecalho .info .linha { font-size: 12px; color: var(--texto-2); margin-top: 2px; }
#chat-cabecalho .acoes { display: flex; gap: 8px; align-items: center; }
#chat-cabecalho .chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-s);
}
.chip.novo { background: var(--ambar-100); color: var(--ambar-700); }
.chip.transf { background: var(--ambar-100); color: var(--ambar-700); border: 1px dashed #ecc463; }
.chip.atendimento { background: var(--verde-claro); color: var(--verde-700); }
.chip.finalizado { background: var(--borda); color: var(--texto-2); }
.chip.janela { background: var(--ambar-100); color: var(--ambar-700); border: 1px solid #ecc463; }

/* selo de canal no cabeçalho da conversa de WhatsApp */
#chat-cabecalho .info .nome .canal-wa {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 2px 7px;
  margin-right: 7px;
  border-radius: var(--r-s);
  background: var(--verde-claro);
  color: var(--verde-700);
  vertical-align: 2px;
}
#chat-cabecalho button, #chat-cabecalho select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--borda);
  background: var(--superficie);
  color: var(--texto);
  border-radius: var(--r-m);
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
#chat-cabecalho button:hover { border-color: var(--texto-3); }
#chat-cabecalho button.principal {
  background: var(--verde-600);
  color: #fff;
  border-color: var(--verde-600);
  font-weight: 600;
}
#chat-cabecalho button.principal:hover { background: var(--verde-700); }

#chat-mensagens {
  flex: 1;
  overflow-y: auto;
  background-repeat: no-repeat;
  background-position: right -150px bottom -180px;
  background-size: 460px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'><g fill='%23ffffff' fill-opacity='.016'><rect x='14.75' y='15' width='4.5' height='8' rx='2.25'/><rect x='21.75' y='11' width='4.5' height='16' rx='2.25'/><rect x='28.75' y='15' width='4.5' height='8' rx='2.25'/></g></svg>");
  /* mensagens ancoradas nas bordas do painel (padrão WhatsApp Web): visitante
     à esquerda, atendente à direita. A coluna central de 800px morreu em
     20/08: em tela de notebook ela flutuava sem âncora (decisão do dono). */
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
}
.msg {
  /* teto em px além do percentual: texto longo continua legível em painel largo */
  max-width: min(62%, 640px);
  padding: 8px 12px;
  border-radius: var(--r-l);
  margin: 2px 0;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  animation: entra .15s ease-out;
}
@keyframes entra { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.seguida { margin-top: 1px; }
/* avatar do participante ao lado da bolha, só na primeira mensagem do grupo;
   a margem vale para o grupo inteiro para as bolhas seguintes alinharem */
.msg.visitante, .msg.atendente { position: relative; }
.msg.visitante { margin-left: 36px; }
.msg.atendente { margin-right: 36px; }
.msg-avatar {
  position: absolute;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--r-avatar);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  overflow: hidden;
  background: var(--graf-700);
  color: #fff;
}
.msg.visitante .msg-avatar { left: -36px; }
.msg.atendente .msg-avatar { right: -36px; }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg-avatar.inicial { font-size: 12px; font-weight: 700; }
.msg .hora { display: block; font-size: 10px; opacity: .55; margin-top: 3px; text-align: right; font-variant-numeric: tabular-nums; }
.ticks { font-style: normal; opacity: .7; }
.ticks.lida { opacity: 1; color: #7ef5c1; }
.msg.visitante {
  align-self: flex-start;
  background: var(--superficie);
  color: var(--texto);
  border: 1px solid var(--borda);
  border-bottom-left-radius: 4px;
  box-shadow: var(--sombra-1);
}
.msg.atendente {
  align-self: flex-end;
  /* um tom abaixo do gradiente da marca: branco sobre 600 dava 3.74 (< 4.5 AA) */
  background: linear-gradient(135deg, #047857, #0f766e);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.sistema {
  align-self: center;
  background: var(--sistema-bg);
  color: var(--texto-2);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  margin: 8px 0;
  animation: none;
  /* o texto e a data ficam na MESMA pílula, lado a lado */
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  max-width: 90%;
}
.sis-quando {
  color: var(--texto-3);
  font-size: 10px;
  white-space: nowrap; /* "13/09/26 20:41" é um dado só, não quebra */
  flex-shrink: 0;
}
.separador {
  align-self: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--texto-2);
  background: var(--sistema-bg);
  padding: 2px 9px;
  border-radius: 999px;
  margin: 10px 0 4px;
  text-transform: uppercase;
  letter-spacing: .06em;
  animation: none;
}
.msg.interna {
  align-self: flex-end;
  background: var(--ambar-100);
  color: var(--ambar-700);
  border: 1px dashed #ecc463;
  border-bottom-right-radius: 4px;
  font-size: 12.5px;
}
.msg.interna .rotulo-interna {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .8;
  margin-bottom: 3px;
}
.anexo-img {
  /* cresce com o espaço: miniatura fixa em 260px virava selo em coluna larga */
  max-width: min(440px, 100%);
  max-height: 320px;
  width: auto;
  height: auto;
  border-radius: var(--r-m);
  display: block;
  cursor: zoom-in;
  margin-top: 2px;
}
.anexo-arq { display: inline-block; color: inherit; font-weight: 600; text-decoration: underline; word-break: break-all; }
/* lightbox de anexos: imagem inteira na própria tela, com download */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(5, 7, 10, .84);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox img {
  display: block;
  max-width: 92vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  flex: none; /* item flex encolhe só a largura e distorce; proporção é sagrada */
  border-radius: var(--r-m);
  box-shadow: var(--sombra-2);
}
.lb-acoes { position: absolute; top: 14px; right: 16px; display: flex; gap: 8px; }
.lb-btn {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  border: 0;
  border-radius: var(--r-m);
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.lb-btn:hover { background: rgba(255, 255, 255, .26); }

#chat-digitando { padding: 2px 28px 4px; font-size: 12px; color: var(--texto-3); font-style: italic; }

#chat-envio {
  display: flex;
  gap: 8px;
  padding: 10px;
  /* borda a borda, como as mensagens: as âncoras do olho são as do painel */
  margin: 6px 16px 14px;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--r-painel);
  box-shadow: var(--sombra-1);
  position: relative;
  align-items: flex-end;
}
#texto-caixa {
  position: relative;
  flex: 1;
  min-width: 140px; /* flex não deixa o campo colapsar numa coluna de 3 letras */
  display: flex;
}
/* Métrica que o campo e o espelho da revisão TÊM que dividir: o sublinhado é
   desenhado numa camada por cima do textarea, e um pixel de diferença em
   fonte, entrelinha ou recuo tira o traço de baixo da palavra. */
#texto, #texto-marcas {
  box-sizing: border-box;
  border-radius: var(--r-m);
  border: 1px solid transparent;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
#texto {
  flex: 1;
  min-width: 0;
  border-color: var(--borda);
  background: var(--fundo);
  color: var(--texto);
  resize: none;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
#texto-marcas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none; /* a camada é decoração: clique, cursor e seleção são do campo */
  color: transparent;   /* do espelho só o traço aparece */
  z-index: 2;
}
.ort-marca {
  text-decoration: underline wavy var(--sublinhado-erro);
  text-decoration-skip-ink: none;
  text-underline-offset: 3px;
}

/* sugestão logo abaixo da palavra sublinhada */
#ort-sugestao {
  position: absolute;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--r-m);
  box-shadow: var(--sombra-2);
  white-space: nowrap;
}
.ort-aplicar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  border-radius: var(--r-s);
  padding: 5px 9px;
  color: var(--verde-texto);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ort-aplicar:hover { background: var(--verde-tinta); }
.ort-ignorar {
  border: 0;
  background: transparent;
  border-radius: var(--r-s);
  padding: 5px 8px;
  color: var(--texto-2);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.ort-ignorar:hover { color: var(--texto); }
#texto:focus {
  background: var(--superficie);
  border-color: var(--verde-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .1);
}
#chat-envio button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* mesmo tom rebaixado da bolha do atendente (rótulo branco precisa de 4.5) */
  background: linear-gradient(135deg, #047857, #0f766e);
  color: #fff;
  border: 0;
  border-radius: var(--r-m);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
#chat-envio button[type="submit"]:hover { background: var(--verde-700); }

#anexar {
  align-self: center;
  border: 1px solid var(--borda);
  background: var(--superficie);
  color: var(--texto-3);
  border-radius: var(--r-m);
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, border-color .15s;
}
#anexar:hover { color: var(--verde-600); border-color: var(--verde-500); }

/* mesmo botão-quadrado do clipe, para os dois ficarem irmãos no composer */
#emoji-abrir {
  align-self: center;
  border: 1px solid var(--borda);
  background: var(--superficie);
  color: var(--texto-3);
  border-radius: var(--r-m);
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, border-color .15s;
}
#emoji-abrir:hover { color: var(--verde-600); border-color: var(--verde-500); }
