/* Chat do encontro — lista de conversas + sala (ativo/encerrado) */

.chat-shell {
  display: flex;
  height: 100vh;
  /* Transparente de propósito: deixa passar o creme + orbs da .app-shell. */
  background: transparent;
}

/* ── Lista de conversas ── */
.chat-list {
  width: 340px;
  flex-shrink: 0;
  /* Janela para a camada animada única (.app-shell::before) — igual à sidebar. */
  background: rgba(255, 255, 255, 0.32);
  -webkit-backdrop-filter: saturate(1.8);
  backdrop-filter: saturate(1.8);
  border-right: 1px solid rgba(221, 177, 247, 0.30);
  display: flex;
  flex-direction: column;
}
.chat-list-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 14px;
}
.chat-convs { flex: 1; overflow-y: auto; padding: 0 10px 10px; }

.chat-conv {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 14px;
  border: none;
  background: none;
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 2px;
  font-family: var(--font-body);
}
.chat-conv:hover { background: rgba(255, 255, 255, 0.7); }
.chat-conv.sel { background: var(--color-orange-light); }
.chat-conv-cover { width: 50px; height: 50px; border-radius: 16px; }
.chat-conv-dot {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2.5px solid #fff;
}
.chat-conv-name {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700;
  color: var(--color-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-conv-time { font-size: 11px; color: var(--color-text-muted); flex-shrink: 0; }
.chat-conv-preview {
  flex: 1;
  min-width: 0;
  font-size: 13px; color: var(--color-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-badge {
  flex-shrink: 0;
  background: var(--color-orange);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ── Sala ── */
.chat-room {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Transparente: os orbs/creme da .app-shell aparecem atrás das mensagens. */
  background: transparent;
}
.chat-vazio {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.chat-room-head {
  /* Janela para a camada animada (nada rola por baixo daqui — as mensagens têm scroll próprio). */
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: saturate(1.8);
  backdrop-filter: saturate(1.8);
  border-bottom: 1px solid rgba(221, 177, 247, 0.28);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 13px;
}
.chat-room-cover { width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0; }
.chat-back { display: none; }

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}
.chat-msgs::-webkit-scrollbar { width: 6px; }
.chat-msgs::-webkit-scrollbar-thumb { background: rgba(132, 153, 183, 0.3); border-radius: 50px; }

/* Recibo de leitura: ✓ enviada · ✓✓ alguém leu · ✓✓ azul todas leram (o title diz quem). */
.chat-recibo {
  margin-left: 4px;
  font-size: 11px;
  letter-spacing: -1px;
  color: var(--color-text-muted);
  cursor: default;
}
.chat-recibo.todas { color: #4a90d9; }

/* "Fulana está digitando" — avatares empilhados + bolinhas, alinhado como bolha recebida. */
.chat-digitando {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  flex-shrink: 0;
  padding-top: 2px;
}
.chat-digitando-avatares {
  display: flex;
  flex-shrink: 0;
}
/* Empilhamento do design system: sobrepõe e separa com borda branca. */
.chat-digitando-avatares .avatar + .avatar {
  margin-left: -8px;
}
.chat-digitando-avatares .avatar {
  border: 2px solid #fff;
  box-sizing: content-box;
}
.chat-digitando-bolha {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}
.chat-digitando-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-slate);
  animation: rgcDigitando 1.3s infinite ease-in-out;
}
.chat-digitando-dot:nth-child(2) { animation-delay: .18s; }
.chat-digitando-dot:nth-child(3) { animation-delay: .36s; }
.chat-digitando-txt {
  font-size: 11px;
  color: var(--color-text-muted);
  font-style: italic;
}

@keyframes rgcDigitando {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* Respeita quem pediu menos animação no SO. */
@media (prefers-reduced-motion: reduce) {
  .chat-digitando-dot { animation: none; opacity: .6; }
}

/* "Carregar mensagens anteriores" — topo da lista, sem encostar no separador de data. */
.chat-mais {
  display: flex;
  justify-content: center;
  padding: 4px 0 8px;
  flex-shrink: 0;
}

.chat-sep {
  align-self: center;
  background: rgba(132, 153, 183, 0.15);
  color: var(--color-text-muted);
  border-radius: 50px;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 500;
  margin: 4px 0;
}

.chat-bubble-wrap { display: flex; max-width: 74%; gap: 8px; align-items: flex-end; }
.chat-bubble-wrap.enviada { align-self: flex-end; }
.chat-bubble-wrap.recebida { align-self: flex-start; gap: 9px; }

/* Botão de responder (aparece no hover; sempre visível no mobile) */
.chat-reply-btn {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  align-self: center;
}
.chat-bubble-wrap:hover .chat-reply-btn { opacity: 1; }
.chat-reply-btn:hover { background: var(--color-cream); }

/* Ações da bolha (responder + reagir), empilhadas ao lado dela. */
.chat-acoes {
  flex-shrink: 0;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Aparelho de toque não tem hover: sem isto, responder/reagir ficariam invisíveis no celular. */
@media (hover: none) {
  .chat-reply-btn { opacity: 1; }
}

/* Seletor rápido de reação (abre sob a bolha, uma mensagem por vez) */
.chat-reacao-picker {
  display: flex;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  margin-top: 6px;
  padding: 4px 6px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  box-shadow: var(--shadow-card);
  scrollbar-width: none;
}
.chat-reacao-picker::-webkit-scrollbar { display: none; }
.chat-reacao-picker.enviada { margin-left: auto; }
.chat-reacao-op {
  flex-shrink: 0;
  min-width: 36px;
  min-height: 36px;
  padding: 4px;
  font-size: 18px;
  line-height: 1;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.chat-reacao-op:hover { background: var(--color-cream); transform: scale(1.15); }
@media (hover: none) {
  .chat-reacao-op { min-width: 44px; min-height: 44px; } /* hit target de toque */
}

/* Chips de reação já dadas (Components/ReacoesChat.razor) */
.chat-reacoes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.chat-bubble-wrap.enviada .chat-reacoes { justify-content: flex-end; }
.chat-reacao {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chat-reacao:hover:not(:disabled) { background: var(--color-cream); }
.chat-reacao:disabled { cursor: default; }
.chat-reacao.minha {
  background: var(--color-orange-light);
  border-color: var(--color-orange);
}
.chat-reacao-emoji { font-size: 13px; line-height: 1.4; }
.chat-reacao-n {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.chat-reacao.minha .chat-reacao-n { color: #d45800; }

/* Citação dentro da bolha */
.chat-quote {
  border-left: 3px solid;
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 6px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.chat-quote.recv { background: var(--color-lavender-light); border-color: var(--color-lavender); }
.chat-quote.recv .chat-quote-autor { color: #9b59d6; font-weight: 600; }
.chat-quote.recv .chat-quote-trecho { color: var(--color-text-secondary); }
.chat-quote.sent { background: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.75); }
.chat-quote.sent .chat-quote-autor { color: #fff; font-weight: 600; }
.chat-quote.sent .chat-quote-trecho { color: rgba(255, 255, 255, 0.9); }
.chat-quote-trecho { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }

.chat-bubble-name { font-size: 11px; color: var(--color-text-muted); margin: 0 0 3px 4px; }
.chat-bubble-recv {
  background: #fff;
  border-radius: 16px 16px 16px 4px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--color-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-bubble-sent {
  background: var(--color-orange);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  font-size: 14px;
  color: #fff;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-bubble-time { font-size: 10px; color: var(--color-disabled-text); margin: 3px 0 0 4px; }

/* ── Input ── */
.chat-compose {
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.chat-reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 0;
}
.chat-reply-preview-autor {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-orange);
}
.chat-reply-preview-trecho {
  font-size: 13px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-reply-cancel {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--color-cream);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-reply-cancel:hover { background: var(--color-disabled-bg); }

.chat-input-bar {
  padding: 13px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Botão que abre o seletor de emojis (Components/SeletorEmoji.razor) */
.chat-emoji-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.chat-emoji-btn:hover { color: var(--color-orange); background: var(--color-orange-light); }
.chat-emoji-btn.on { color: var(--color-orange); background: var(--color-orange-light); }

/* Painel do seletor — fica ACIMA da barra de input, dentro do .chat-compose (no fluxo,
   não flutuando: assim ele empurra as mensagens em vez de tampar as últimas). */
.emoji-pop {
  border-top: 1px solid var(--color-border);
  background: #fff;
}
.emoji-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab {
  flex-shrink: 0;
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.emoji-tab:hover { background: var(--color-cream); }
.emoji-tab.on {
  background: var(--color-orange-light);
  color: #d45800;
  font-weight: 700;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 2px;
  max-height: 190px;
  overflow-y: auto;
  padding: 8px 12px 10px;
  scrollbar-width: thin;
}
.emoji-grid::-webkit-scrollbar { width: 6px; }
.emoji-grid::-webkit-scrollbar-thumb { background: rgba(132, 153, 183, 0.3); border-radius: 50px; }
.emoji-item {
  height: 40px;
  font-size: 21px;
  line-height: 1;
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.emoji-item:hover { background: var(--color-cream); transform: scale(1.18); }

/* ══════════ Seletor de GIF ══════════ */
/* Mesmo molde do .emoji-pop: painel que abre acima da barra de input. */
.gif-pop {
  border-top: 1px solid var(--color-border);
  background: #fff;
}
.gif-busca { padding: 10px 12px 6px; }
.gif-input {
  width: 100%;
  background: var(--color-cream);
  border: 1.5px solid transparent;
  border-radius: 50px;
  padding: 9px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--color-text);
  outline: none;
}
.gif-input:focus { background: #fff; border-color: var(--color-orange); }
/* Grid quadrado com recorte, e não multi-coluna: `columns` + altura fixa faz o conteúdo
   transbordar em NOVAS COLUNAS para o lado em vez de rolar na vertical — medido, um item saía
   da tela. Recortar a miniatura é o que os seletores de GIF fazem mesmo; a proporção real é
   preservada onde importa, que é na bolha. */
.gif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
  max-height: 230px;
  overflow-y: auto;
  padding: 4px 12px 10px;
  scrollbar-width: thin;
}
.gif-grid::-webkit-scrollbar { width: 6px; }
.gif-grid::-webkit-scrollbar-thumb { background: rgba(132, 153, 183, 0.3); border-radius: 50px; }
.gif-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: var(--color-cream);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  line-height: 0;
}
.gif-item img {
  width: 100%;
  height: 100%;
  display: block;
  aspect-ratio: 1;
  object-fit: cover;
}
.gif-item:hover { outline: 2px solid var(--color-orange); outline-offset: -2px; }
.gif-aviso {
  padding: 18px 14px 22px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
}
.gif-mais {
  display: block;
  width: calc(100% - 24px);
  margin: 0 12px 10px;
  padding: 8px;
  background: var(--color-cream);
  border: none;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.gif-mais:hover { background: var(--color-orange-light); color: #d45800; }

/* Atribuição exigida pelo provedor para a chave de produção. */
.gif-credito {
  padding: 0 12px 8px;
  text-align: right;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

/* Botão GIF na barra, irmão do de emoji — texto em vez de ícone, é o rótulo universal. */
.chat-gif-btn {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* GIF dentro da bolha. A bolha tem padding pensado para texto; com mídia ele sai e o raio
   é herdado pelo recorte, senão a imagem vaza os cantos arredondados. */
.chat-bubble-sent.midia,
.chat-bubble-recv.midia { padding: 4px; }
.chat-gif {
  display: block;
  width: 100%;
  max-width: 220px;
  height: auto;
  border-radius: 12px;
  background: rgba(132, 153, 183, 0.12);   /* placeholder enquanto carrega */
}
.chat-input {
  flex: 1;
  background: var(--color-cream);
  border: 1.5px solid transparent;
  border-radius: 50px;
  padding: 12px 18px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
  outline: none;
}
.chat-input:focus { border-color: var(--color-orange); }
.chat-send {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--color-orange);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(255, 110, 31, 0.35);
  transition: opacity .15s;
}
.chat-send:hover { opacity: .92; }
.chat-send:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.chat-closed {
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}
.chat-closed span { font-size: 13.5px; color: var(--color-text-muted); }

/* ── Mobile: alterna lista/sala ── */
@media (max-width: 820px) {
  .chat-list { width: 100%; }
  .chat-back { display: flex; }

  /* Lista: preenche a tela abaixo da top bar. Sala aberta: tela cheia (a top bar some via body.sala-aberta). */
  .chat-shell { height: calc(100vh - var(--app-topbar-h)); }
  .chat-shell.com-sala { height: 100vh; }

  /* Sem encontro selecionado: mostra só a lista. Com encontro: mostra só a sala. */
  .chat-shell:not(.com-sala) .chat-room { display: none; }
  .chat-shell.com-sala .chat-list { display: none; }
  .chat-shell.com-sala .chat-room { width: 100%; }

  /* Sem hover no toque: botão de responder sempre visível (discreto). */
  .chat-reply-btn { opacity: .55; }
}
