/* ============================================================
   chat.css — A Conversa Privada (1-a-1)

   Janela flutuante no canto inferior direito. Paleta e fontes do
   design-system (--purple-main, --blue-mana, --font-section…).
   Presença reaproveita as classes .pr-online etc. de
   hunter-publico.css (não redefinidas aqui).
   ============================================================ */

.ch-janela {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 4200;

  width: 340px;
  max-width: calc(100vw - 24px);
  height: 460px;
  max-height: calc(100vh - 40px);

  display: flex;
  flex-direction: column;
  overflow: hidden;

  border-radius: 16px;
  background:
    radial-gradient(120% 80% at 12% 0%,
      color-mix(in srgb, var(--purple-main) 16%, transparent), transparent 60%),
    linear-gradient(165deg, #16101f 0%, #0a0710 72%);
  border: 1px solid color-mix(in srgb, var(--purple-main) 42%, transparent);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, .7),
    0 0 34px color-mix(in srgb, var(--purple-main) 16%, transparent);
  animation: ch-surgir .24s cubic-bezier(.34, 1.3, .64, 1) both;
}

/* O atributo hidden nativo é atropelado pelo display: flex da .ch-janela, forçamos o sumiço */
.ch-janela[hidden] {
  display: none !important;
}

/* Navegadores sem color-mix continuam com uma janela apresentável */
@supports not (color: color-mix(in srgb, red, blue)) {
  .ch-janela {
    background: linear-gradient(165deg, #16101f, #0a0710);
    border-color: rgba(124, 58, 237, .4);
  }
}
@keyframes ch-surgir {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-janela { animation: none; }
}

/* ── Cabeçalho ────────────────────────────────────────────── */
/* Cabeçalho é a alça de arrasto. */
.ch-cabecalho { cursor: move; }
.ch-cabecalho button { cursor: pointer; }   /* botões voltam ao cursor normal */
.ch-janela.ch-arrastando { animation: none; user-select: none; transition: none; }

.ch-cabecalho {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .85rem;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  background: linear-gradient(180deg, rgba(124, 58, 237, .12), transparent);
}
.ch-av {
  position: relative;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-section);
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--purple-main), var(--blue-mana));
}
.ch-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.ch-ponto {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #0a0710;
  background: var(--presenca-cor, #64748b);
}
.ch-av.pr-online .ch-ponto {
  animation: ch-pulso 2s ease-in-out infinite;
}
@keyframes ch-pulso {
  0%, 100% { opacity: 1;  transform: scale(1); }
  50%      { opacity: .5; transform: scale(.82); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-av.pr-online .ch-ponto { animation: none; }
}

.ch-ident { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-nome {
  font-family: var(--font-section);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-presenca {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-family: var(--font-section);
  font-size: .62rem;
  letter-spacing: .05em;
  color: var(--presenca-cor, #64748b);
}
.ch-ponto-txt {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--presenca-cor, #64748b);
  box-shadow: 0 0 6px var(--presenca-cor, #64748b);
}

.ch-fechar {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: .3rem .35rem;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.ch-fechar:hover { color: #fff; background: rgba(255, 255, 255, .06); }

/* Botão limpar conversa — mesmo estilo do fechar, ao lado dele. */
.ch-limpar {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  font-size: .95rem; line-height: 1;
  padding: .3rem .35rem; border-radius: 8px;
  opacity: .7; transition: opacity .15s, background .15s;
}
.ch-limpar:hover { opacity: 1; background: rgba(255, 255, 255, .06); }

/* ── Corpo rolável ────────────────────────────────────────── */
.ch-corpo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: .8rem .7rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, .4) transparent;
}
.ch-corpo::-webkit-scrollbar { width: 8px; }
.ch-corpo::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, .4);
  border-radius: 100px;
}

.ch-mais {
  align-self: center;
  flex-shrink: 0;
  margin-bottom: .4rem;
  font-family: var(--font-section);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  padding: .35rem .85rem;
  border-radius: 100px;
  cursor: pointer;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(148, 163, 184, .2);
  transition: all .15s;
}
.ch-mais:hover { color: #fff; border-color: var(--purple-glow); }
.ch-mais:disabled { opacity: .6; cursor: default; }

.ch-lista {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.ch-placeholder {
  margin: auto;
  padding: 1.4rem .8rem;
  text-align: center;
  font-family: var(--font-section);
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Bolhas ───────────────────────────────────────────────── */
.ch-bolha {
  position: relative;
  max-width: 82%;
  padding: .45rem .7rem .3rem;
  border-radius: 14px;
  animation: ch-bolha-surgir .18s ease both;
}

/* Gatilho ⋮ do menu de exclusão: discreto, aparece ao passar o mouse. */
.ch-msg-menu {
  position: absolute; top: 2px;
  width: 20px; height: 20px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; cursor: pointer;
  font-size: .95rem; line-height: 1;
  color: var(--text-primary);
  background: rgba(0, 0, 0, .35);
  opacity: 0; transition: opacity .15s;
}
.ch-minha .ch-msg-menu { left: -26px; }   /* fora da bolha, à esquerda */
.ch-dele  .ch-msg-menu { right: -26px; }  /* fora da bolha, à direita */
.ch-bolha:hover .ch-msg-menu { opacity: .85; }
.ch-msg-menu:hover { opacity: 1 !important; background: rgba(0, 0, 0, .6); }

/* Lápide: mensagem apagada para todos. */
.ch-apagada .ch-texto-apagada {
  font-style: italic;
  color: var(--text-dim);
  opacity: .8;
}
.ch-apagada.ch-minha { background: rgba(124, 58, 237, .12); }
.ch-apagada.ch-dele  { background: rgba(255, 255, 255, .03); }

/* Menu flutuante da bolha (ancorado no body). */
.ch-menu-msg {
  position: fixed; z-index: 4300;
  min-width: 168px; padding: .3rem;
  border-radius: 11px;
  background: linear-gradient(165deg, #17111f, #0b0810);
  border: 1px solid rgba(148, 163, 184, .2);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .6);
  animation: ch-menu-surgir .14s ease both;
}
@keyframes ch-menu-surgir { from { opacity: 0; transform: translateY(-4px); } }
.ch-menu-item {
  display: block; width: 100%; text-align: left;
  padding: .55rem .7rem; border: none; border-radius: 8px; cursor: pointer;
  background: none; color: var(--text-secondary);
  font-family: var(--font-section); font-size: .78rem;
  transition: background .15s, color .15s;
}
.ch-menu-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.ch-menu-item.perigo { color: #fca5a5; }
.ch-menu-item.perigo:hover { background: rgba(239, 68, 68, .18); color: #fff; }
@media (prefers-reduced-motion: reduce) { .ch-menu-msg { animation: none; } }
@keyframes ch-bolha-surgir {
  from { opacity: 0; transform: translateY(4px); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-bolha { animation: none; }
}

/* As minhas: à direita, com o roxo de destaque. */
.ch-minha {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, var(--purple-main), var(--purple-glow));
  border: 1px solid color-mix(in srgb, var(--purple-glow) 60%, transparent);
  border-bottom-right-radius: 4px;
}
/* As dele: à esquerda, tom sóbrio. */
.ch-dele {
  align-self: flex-start;
  color: var(--text-primary);
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(148, 163, 184, .16);
  border-bottom-left-radius: 4px;
}

.ch-texto {
  font-family: var(--font-body);
  font-size: .84rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.ch-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: .15rem;
}
.ch-hora {
  font-family: var(--font-section);
  font-size: .56rem;
  letter-spacing: .05em;
  opacity: .7;
}

/* Estados da bolha otimista */
.ch-pendente { opacity: .6; }
.ch-falhou {
  background: linear-gradient(135deg, var(--red-dark), #7f1d1d);
  border-color: color-mix(in srgb, var(--red-crit) 60%, transparent);
}
.ch-falhou .ch-hora::after {
  content: ' · falhou';
  color: #fecaca;
}

/* ── Aviso (ex.: 403 não são amigos) ──────────────────────── */
.ch-aviso {
  flex-shrink: 0;
  margin: 0 .7rem;
  padding: .5rem .7rem;
  border-radius: 10px;
  font-family: var(--font-section);
  font-size: .72rem;
  color: #fecaca;
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .35);
}

/* ── Indicador "digitando…" ───────────────────────────────── */
.ch-digitando {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .1rem .85rem .35rem;
  font-family: var(--font-section);
  font-size: .66rem;
  letter-spacing: .05em;
  color: var(--text-muted);
}
/* .ch-digitando declara display:flex; a regra [hidden] do UA (mesma
   especificidade) perderia para o autor — reforçamos aqui. */
.ch-digitando[hidden] { display: none; }
.ch-dig-pontos {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
}
.ch-dig-pontos i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--purple-glow, #a855f7);
  opacity: .4;
  animation: ch-dig-salto 1.2s ease-in-out infinite;
}
.ch-dig-pontos i:nth-child(2) { animation-delay: .18s; }
.ch-dig-pontos i:nth-child(3) { animation-delay: .36s; }
@keyframes ch-dig-salto {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40%           { opacity: 1;   transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-dig-pontos i { animation: none; opacity: .7; }
}

/* ── Rodapé: escrever + enviar ────────────────────────────── */
.ch-rodape {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .6rem .7rem;
  border-top: 1px solid rgba(148, 163, 184, .14);
  background: rgba(0, 0, 0, .25);
}
.ch-input {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 120px;
  padding: .5rem .7rem;
  border-radius: 12px;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-section);
  font-size: .82rem;
  line-height: 1.4;
  background: rgba(0, 0, 0, .4);
  border: 1px solid rgba(148, 163, 184, .2);
  transition: border-color .2s, box-shadow .2s;
}
.ch-input::placeholder { color: var(--text-dim); }
.ch-input:focus {
  border-color: var(--purple-glow);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .14);
}
.ch-enviar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  font-size: .95rem;
  background: linear-gradient(100deg, #6d28d9, #a855f7);
  border: 1px solid var(--purple-glow);
  box-shadow: 0 0 16px rgba(124, 58, 237, .3);
  transition: transform .15s, box-shadow .15s;
}
.ch-enviar:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 26px rgba(168, 85, 247, .5);
}

@media (max-width: 480px) {
  .ch-janela {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 70vh;
    border-radius: 16px 16px 0 0;
  }
}
