/* =============================================================
   NEGOCIACOES.CSS — Negociações (chat)
   Base visual (cabeçalho, menu, cards, modal) em painel.css.
   Aqui ficam só o layout e os elementos do chat.
   ============================================================= */

.chat-container {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  height: clamp(480px, calc(100vh - var(--topo-h) - 120px), 720px);
  overflow: hidden;
  border-radius: 24px;
  background: var(--mp-superficie);
  border: 1px solid var(--mp-linha);
  box-shadow: var(--mp-sombra-card);
}

/* ── Lista de conversas ──────────────────────────────────── */
.lista-conversas {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--mp-linha);
  background: var(--mp-superficie-2);
}

.lista-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--mp-linha);
}

.lista-header h2 {
  font-family: var(--fonte-display);
  font-size: 1.2rem;
}

#listaConversas {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversa-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--mp-texto);
  text-align: left;
  transition: background-color .2s ease, transform .25s var(--ease);
}

.conversa-item + .conversa-item {
  margin-top: 2px;
}

.conversa-item:hover {
  background: var(--mp-nevoa);
}

.conversa-item.ativa {
  background: var(--mp-superficie);
  box-shadow: inset 3px 0 0 var(--mp-destaque), var(--mp-sombra-card);
}

.conversa-item .avatar {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.conversa-info {
  min-width: 0;
}

.conversa-info strong {
  display: block;
  overflow: hidden;
  color: var(--mp-titulo);
  font-size: 14.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversa-info small {
  display: block;
  color: var(--mp-suave);
  font-size: 12.5px;
}

.lista-conversas .empty-state {
  padding: 32px 16px;
}

/* ── Janela do chat ──────────────────────────────────────── */
.chat-box {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--mp-linha);
  background: var(--mp-superficie);
}

.chat-usuario {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar.grande {
  width: 46px;
  height: 46px;
  font-size: 17px;
}

.chat-usuario h3 {
  font-size: 1.02rem;
}

.chat-usuario small {
  color: var(--mp-suave);
  font-size: 12.5px;
}

.chat-mensagens {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  overflow-y: auto;
  background:
    var(--curvas-verdes),
    var(--mp-fundo);
  background-size: 600px 400px, auto;
}

.empty-chat {
  margin: auto;
}

.mensagem {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(72%, 520px);
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  box-shadow: var(--mp-sombra-card);
  animation: subir .3s var(--ease) both;
}

.mensagem span {
  align-self: flex-end;
  font-size: 11px;
  opacity: .7;
}

.mensagem.recebida {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  background: var(--mp-superficie);
  border: 1px solid var(--mp-linha);
  color: var(--mp-texto);
}

.mensagem.enviada {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: var(--verde);
  color: #fff;
}

body.dark .mensagem.enviada {
  background: var(--verde-medio);
}

/* ── Campo de mensagem ───────────────────────────────────── */
.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--mp-linha);
  background: var(--mp-superficie);
}

.chat-input input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 18px;
  border: 1.5px solid var(--mp-linha);
  border-radius: var(--radius-pill);
  background: var(--mp-campo);
  color: var(--mp-texto);
  transition: border-color .25s, box-shadow .25s;
}

.chat-input input:focus {
  outline: 0;
  border-color: var(--mp-destaque);
  box-shadow: 0 0 0 4px rgba(79, 119, 45, .14);
}

.chat-input button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--mp-linha);
  border-radius: 50%;
  background: var(--mp-superficie);
  color: var(--mp-suave);
  font-size: 17px;
  transition: background-color .2s, color .2s, transform .25s var(--ease);
}

.chat-input button:hover {
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
}

#btnEnviar {
  border-color: transparent;
  background: var(--verde);
  color: #fff;
}

#btnEnviar:hover {
  background: var(--verde-escuro);
  transform: translateX(2px) rotate(-8deg);
}

#btnEnviar:active {
  transform: scale(.92);
}

body.dark #btnEnviar {
  background: var(--verde-medio);
}

/* ── Modal de proposta ───────────────────────────────────── */
#modalProposta .modal-box {
  width: min(480px, 100%);
}

/* ── Responsivo ──────────────────────────────────────────── */
@media (max-width: 860px) {
  .chat-container {
    grid-template-columns: 1fr;
    height: auto;
  }

  .lista-conversas {
    max-height: 280px;
    border-right: 0;
    border-bottom: 1px solid var(--mp-linha);
  }

  .chat-box {
    height: 520px;
  }

  .mensagem {
    max-width: 85%;
  }
}

/* ── Itens da conversa vindos do backend (prévia, produto, não lidas) ── */
.conversa-info {
  flex: 1;
}

.conversa-topo,
.conversa-rodape {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversa-topo strong {
  min-width: 0;
}

.conversa-topo time {
  flex-shrink: 0;
  color: var(--mp-suave);
  font-size: 11px;
}

.conversa-produto,
.conversa-previa {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversa-produto {
  font-size: 12px;
}

.badge-nao-lidas {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--verde);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.tag-concluida {
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
  font-size: 11px;
  font-weight: 700;
}

/* ── Mensagens de proposta ───────────────────────────────── */
.mensagem p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.proposta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--mp-nevoa);
}

.proposta small {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.proposta strong {
  font-size: 20px;
}

.mensagem.enviada .proposta {
  background: rgba(255, 255, 255, .18);
}

.proposta-produto {
  margin-bottom: 16px;
  color: var(--mp-suave);
  font-size: 14px;
}

body.dark .badge-nao-lidas {
  background: var(--verde-medio);
}
