/* Histórico do cartão do CRM com cara de conversa (crm.html e gerenciador.html).
   O HTML vem de CrmHistorico.htmlConversa (js/crm-historico.js).
   .hist-chat é a moldura com o fundo; dentro dela fica a área que rola, com .hist-conversa. */
.hist-chat {
  --wa-fundo: #efeae2;
  --wa-balao: #d9fdd3;
  --wa-texto: #111b21;
  --wa-hora: #667781;
  --wa-aviso: #ffffff;
  --wa-aviso-cor: #54656f;
  --wa-amarelo: #ffeecd;
  --wa-amarelo-cor: #54656f;
  --wa-sombra: 0 1px .5px rgba(11, 20, 26, .13);
  position: relative;
  isolation: isolate;
  background: var(--wa-fundo);
}
body.dark .hist-chat {
  --wa-fundo: #0b141a;
  --wa-balao: #005c4b;
  --wa-texto: #e9edef;
  --wa-hora: rgba(233, 237, 239, .6);
  --wa-aviso: #182229;
  --wa-aviso-cor: #8696a0;
  --wa-amarelo: #182229;
  --wa-amarelo-cor: #ffd279;
  --wa-sombra: 0 1px .5px rgba(0, 0, 0, .4);
}
/* Desenho de fundo (img/historico-fundo.svg, traço preto): fica parado enquanto a conversa rola */
.hist-chat::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url('../img/historico-fundo.svg') 0 0 / 320px 320px repeat;
  opacity: .08;
}
body.dark .hist-chat::before { filter: invert(1); opacity: .05; }

.hist-conversa {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;   /* poucas mensagens ficam embaixo, perto de onde se escreve */
  min-height: 100%;
  padding: 8px 14px 12px;
  color: var(--wa-texto);
}

/* Etiqueta do dia: Hoje, Ontem, Sexta-feira, 15/11 */
.hist-dia { display: flex; justify-content: center; margin: 12px 0 6px; }
.hist-dia span {
  padding: 5px 12px 6px; border-radius: 7.5px;
  background: var(--wa-aviso); color: var(--wa-aviso-cor); box-shadow: var(--wa-sombra);
  font-size: 12.5px; line-height: 1.2;
}

/* Mudança feita no cartão (etapa, temperatura, edições): aviso no meio */
.hist-aviso {
  align-self: center; max-width: 92%; margin: 3px 0;
  padding: 5px 10px 6px; border-radius: 7.5px;
  background: var(--wa-aviso); color: var(--wa-aviso-cor); box-shadow: var(--wa-sombra);
  font-size: 12.5px; line-height: 1.4; text-align: center; overflow-wrap: anywhere;
}
.hist-aviso .ico { width: 13px; height: 13px; margin-right: 4px; vertical-align: -2px; }
.hist-aviso .hist-hora { margin-left: 6px; font-size: 11px; color: var(--wa-hora); white-space: nowrap; }
.hist-aviso .hist-autor { color: var(--wa-hora); font-size: 11px; }

/* O que o corretor registrou: balão verde à direita, com bico no primeiro da sequência */
.hist-balao {
  position: relative; align-self: flex-end; max-width: 85%;
  margin: 8px 8px 0 0; padding: 6px 9px 8px;
  border-radius: 7.5px 0 7.5px 7.5px;
  background: var(--wa-balao); color: var(--wa-texto); box-shadow: var(--wa-sombra);
  font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere;
}
.hist-balao::after {
  content: ''; position: absolute; top: 0; right: -8px; width: 8px; height: 13px;
  background: var(--wa-balao); clip-path: polygon(0 0, 100% 0, 0 100%);
}
.hist-balao.seguido { margin-top: 2px; border-radius: 7.5px; }
.hist-balao.seguido::after { display: none; }
.hist-balao .hist-texto { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.hist-balao .hist-texto .ico { width: 14px; height: 14px; flex-shrink: 0; opacity: .7; }
.hist-balao .hist-nota { white-space: pre-wrap; }
.hist-balao .hist-texto + .hist-nota { margin-top: 2px; }
.hist-balao .hist-autor { margin-bottom: 2px; font-size: 12px; font-weight: 700; color: #027eb5; }
body.dark .hist-balao .hist-autor { color: #53bdeb; }
/* Hora no canto de baixo do balão; o espaço reservado no fim da última linha */
.hist-espaco { display: inline-block; width: 42px; height: 1px; flex-shrink: 0; }
.hist-meta { position: absolute; right: 7px; bottom: 3px; font-size: 11px; line-height: 15px; color: var(--wa-hora); }

/* Avisos da própria conversa: vazio, carregando, erro, cartão de antes do histórico */
.hist-vazio, .hist-inicio {
  align-self: center; max-width: 92%; margin: 10px 0;
  padding: 6px 12px; border-radius: 7.5px;
  background: var(--wa-amarelo); color: var(--wa-amarelo-cor); box-shadow: var(--wa-sombra);
  font-size: 12.5px; line-height: 1.45; text-align: center;
}
.hist-vazio.erro { color: #b91c1c; font-weight: 600; }
body.dark .hist-vazio.erro { color: #f87171; }
