/* Equipe › Chat: a conversa com o Agente de IA. Cores só por variáveis de styles.css (o tema escuro vem de graça). */

.chat-aviso { max-width: 720px; margin: 0 auto; }

/* No Chat a página usa a largura toda e desce até embaixo, como nos apps de chat. */
.tela.tela-chat { max-width: none; padding: 12px 20px 0; }
.tela.tela-chat .sub-abas { margin-bottom: 12px; }

/* Duas colunas num painel só: as conversas à esquerda, a conversa à direita. A altura vem do JS
   (a janela menos o que está acima); o valor aqui é só o de partida. */
.chat {
  position: relative;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: calc(100dvh - 200px);
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--raio);
  background: var(--surface);
}

.chat-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 14px 10px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.chat-veu { display: none; }
.chat-lista-topo { display: flex; gap: 8px; align-items: center; }
.chat-lista-topo .botao-primario { flex: 1; }
.chat-fechar-gaveta { display: none; }
.chat-vazio { font-size: calc(0.875rem * var(--escala-texto)); margin: 6px 4px; }

.chat-itens { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.chat-item-linha { display: flex; align-items: center; gap: 2px; border-radius: var(--raio-campo); }
.chat-item-linha:hover { background: var(--paper); }
.chat-item.ativa .chat-item-linha { background: var(--accent-soft); }
.chat-item-abrir {
  flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left;
  padding: 8px 10px; background: none; border: 0; border-radius: var(--raio-campo);
  font: inherit; color: var(--ink); cursor: pointer;
}
.chat-item-abrir[aria-current="true"] { font-weight: 600; color: var(--accent); }
.chat-item-titulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-quando { font-size: calc(0.8125rem * var(--escala-texto)); color: var(--ink-faint); }
.chat-item-mais {
  flex: none; min-width: 32px; min-height: 32px; margin-right: 2px;
  background: none; border: 0; border-radius: var(--raio-pilula);
  font: inherit; color: var(--ink-soft); cursor: pointer;
}
.chat-item-mais:hover { color: var(--ink); background: var(--surface-2); }
.chat-menu {
  display: grid; gap: 2px; margin: 2px 0 6px; padding: 4px;
  border: 1px solid var(--line); border-radius: var(--raio-campo);
  background: var(--surface); box-shadow: var(--sombra);
}
.chat-menu button {
  padding: 8px 10px; text-align: left; background: none; border: 0; border-radius: 6px;
  font: inherit; color: var(--ink); cursor: pointer;
}
.chat-menu button:hover { background: var(--paper); }

/* A conversa: cabeçalho, mensagens (rolam), status e caixa de texto fixa embaixo. */
.chat-conversa {
  /* A coluna de leitura fica no meio, com largura confortável, como no Claude e no ChatGPT. */
  --coluna-chat: 820px;
  --margem-chat: max(20px, calc((100% - var(--coluna-chat)) / 2));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}
.chat-cabecalho {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.chat-titulo {
  flex: 1; min-width: 0; margin: 0;
  font-size: calc(1rem * var(--escala-texto)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-abrir-lista { display: none; }

.chat-fio {
  display: flex; flex-direction: column; gap: 20px;
  min-height: 0; padding: 24px var(--margem-chat); overflow-y: auto;
}
.chat-boas-vindas {
  display: grid; gap: 14px; justify-items: center; text-align: center;
  max-width: 560px; margin: auto; padding: 24px 8px;
}
.chat-boas-vindas h3 { margin: 0; font-size: calc(1.25rem * var(--escala-texto)); }
.chat-boas-vindas p { margin: 0; }
.chat-sugestoes { display: grid; gap: 8px; width: 100%; }
.chat-sugestao {
  padding: 10px 16px; border: 1px solid var(--borda-controle); border-radius: var(--raio-pilula);
  background: var(--surface); color: var(--ink); font: inherit; text-align: center; cursor: pointer;
}
.chat-sugestao:hover { border-color: var(--accent); color: var(--accent); }

.chat-msg { display: grid; gap: 6px; max-width: 88%; }
.chat-msg.de-pessoa { justify-self: end; justify-items: end; }
.chat-msg.do-agente { justify-self: start; justify-items: start; max-width: 100%; }
/* A resposta do agente não fica num balão: é texto corrido na coluna, como nos apps de chat. */
.chat-msg.do-agente .chat-balao { padding: 0; border: 0; background: none; }
.chat-quem { font-size: calc(0.8125rem * var(--escala-texto)); color: var(--ink-soft); }
.chat-balao {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); line-height: 1.55; overflow-wrap: anywhere;
}
.chat-msg.de-pessoa .chat-balao { background: var(--accent-soft); border-color: var(--accent-borda); }
.chat-texto-pessoa { margin: 0; white-space: pre-wrap; }
.chat-texto p { margin: 0 0 0.6em; }
.chat-texto p:last-child { margin-bottom: 0; }
.chat-texto ul { margin: 0 0 0.6em; padding-left: 1.25em; }
.chat-texto code {
  padding: 1px 5px; border-radius: 4px; background: var(--surface-2);
  font-family: var(--fonte-mono); font-size: 0.9em;
}
.chat-ferramentas { margin: 0 4px; font-size: calc(0.8125rem * var(--escala-texto)); color: var(--ink-faint); }
.chat-link { color: var(--accent); font-weight: 600; text-decoration: underline; }

.chat-proposta {
  display: grid; gap: 6px; width: 100%; max-width: 480px; padding: 12px 14px;
  border: 1px solid var(--accent-borda); border-radius: var(--raio-campo); background: var(--surface);
}
.chat-proposta p { margin: 0; }
.chat-proposta-titulo { font-weight: 600; }
.chat-proposta-feita { font-size: calc(0.875rem * var(--escala-texto)); }

.chat-falha {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: calc(0.875rem * var(--escala-texto)); color: var(--erro);
}

.chat-status { min-height: 1.6em; margin: 0; padding: 0 var(--margem-chat); font-size: calc(0.875rem * var(--escala-texto)); color: var(--ink-faint); }
.chat-status:empty { min-height: 0; }

/* A caixa de texto é uma "pílula" no pé da coluna, com o botão dentro do mesmo contorno. */
.chat-entrada {
  display: flex; gap: 8px; align-items: flex-end;
  margin: 0 var(--margem-chat) 16px; padding: 8px 8px 8px 16px;
  border: 1px solid var(--borda-controle); border-radius: 24px; background: var(--surface);
  box-shadow: var(--sombra);
}
.chat-entrada:focus-within { border-color: var(--accent); }
.chat-campo {
  flex: 1; min-width: 0; min-height: 2.5rem; max-height: calc(8 * 1.5em + 20px);
  resize: none; overflow-y: auto; line-height: 1.5;
  border: 0; background: transparent; padding: 8px 0; box-shadow: none;
}
.chat-campo:focus { outline: none; box-shadow: none; }
.chat-entrada .botao-primario { border-radius: var(--raio-pilula); }

/* Diálogo "Levar à equipe": o seletor de participantes. */
.chat-participantes { display: grid; gap: 8px; }
.chat-participantes > label { font-size: calc(0.875rem * var(--escala-texto)); font-weight: 500; color: var(--ink-soft); }
.chat-busca { width: 100%; }
.chat-participantes .dica { margin: 0; }
.chat-resultados {
  list-style: none; margin: 0; padding: 0; max-height: 180px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--raio-campo);
}
.chat-resultados:empty { display: none; }
.chat-resultado {
  width: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; text-align: left;
  padding: 8px 10px; background: none; border: 0; font: inherit; color: var(--ink); cursor: pointer;
}
.chat-resultado:hover { background: var(--paper); }
.chat-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chat-chips[hidden] { display: none; }
.chat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 12px; border: 1px solid var(--accent-borda); border-radius: var(--raio-pilula);
  background: var(--accent-soft); font-size: calc(0.875rem * var(--escala-texto));
}
.chat-chip-x {
  min-width: 28px; min-height: 28px; border: 0; border-radius: 50%;
  background: none; color: var(--ink); font: inherit; cursor: pointer;
}
.chat-chip-x:hover { background: var(--surface-2); }

/* Celular: a lista vira uma gaveta, aberta pelo botão "Conversas". Nada de rolagem horizontal. */
@media (max-width: 767px) {
  .tela.tela-chat { padding: 8px var(--espaco-mobile, 16px) 0; }
  .chat { grid-template-columns: minmax(0, 1fr); min-height: 360px; }
  .chat-conversa { --margem-chat: 12px; }
  .chat-abrir-lista { display: inline-flex; }
  .chat-fechar-gaveta { display: inline-flex; }
  .chat-lista {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
    width: min(320px, 86vw); border-radius: 0 var(--raio) var(--raio) 0; box-shadow: var(--sombra);
    transform: translateX(-102%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }
  .chat.gaveta-aberta .chat-lista { transform: none; visibility: visible; }
  .chat.gaveta-aberta .chat-veu { display: block; position: fixed; inset: 0; z-index: 55; background: rgb(10 20 18 / 45%); }
  .chat-msg { max-width: 92%; }
  .chat-fio { padding: 12px var(--margem-chat); }
  .chat-entrada { margin-bottom: 10px; }
  .chat-cabecalho { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-lista { transition: none; }
}
