/* ═══════════════════════════════════════════════════════════
   SUPPORT — chat de suporte (cliente) + caixa de entrada
   (conta de atendimento). Tudo em var() para seguir o Tema.
   ═══════════════════════════════════════════════════════════ */

/* ── chat (compartilhado) ── */
.sup-chat {
  display: flex; flex-direction: column;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 14px;
  overflow: hidden; height: min(62vh, 560px);
}
.sup-msgs { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.sup-msg { max-width: 78%; padding: 9px 13px; border-radius: 13px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.sup-msg-user    { align-self: flex-end; background: var(--or); color: #fff; border-bottom-right-radius: 4px; }
.sup-msg-support { align-self: flex-start; background: var(--s2); color: var(--tx); border: 1px solid var(--bd); border-bottom-left-radius: 4px; }
/* na caixa do suporte os lados invertem (a msg do cliente fica à esquerda) */
.sup-invert .sup-msg-user    { align-self: flex-start; background: var(--s2); color: var(--tx); border: 1px solid var(--bd); border-radius: 13px 13px 13px 4px; }
.sup-invert .sup-msg-support { align-self: flex-end; background: var(--or); color: #fff; border: none; border-radius: 13px 13px 4px 13px; }
.sup-msg-meta { font-size: 10px; opacity: .7; margin-top: 4px; }
/* envio otimista: a mensagem aparece na hora, translúcida, até o servidor confirmar */
.sup-pendente { opacity: .55; }
.sup-day { align-self: center; font-size: 10.5px; color: var(--mu); background: var(--s2); border-radius: 999px; padding: 3px 10px; margin: 4px 0; }

.sup-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--bd); background: var(--s2); }
.sup-input textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 120px;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 10px;
  color: var(--tx); font-family: 'Inter', sans-serif; font-size: 13px; padding: 10px 12px; outline: none;
}
.sup-input textarea:focus { border-color: var(--or); }
.sup-input textarea:disabled { opacity: .55; cursor: not-allowed; }
.sup-attach:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.sup-send {
  align-self: flex-end; height: 42px; padding: 0 18px; border: none; border-radius: 10px;
  background: var(--or); color: #fff; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; gap: 7px;
}
.sup-send:hover { opacity: .9; }
.sup-send:disabled { opacity: .45; cursor: not-allowed; }

.sup-empty { margin: auto; text-align: center; color: var(--mu); font-size: 12.5px; padding: 24px; line-height: 1.6; }
.sup-empty svg { width: 44px; height: 44px; color: var(--or); margin-bottom: 10px; }

.sup-hint { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--mu); margin: 10px 2px 0; }
.sup-hint svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--green); }

/* ── caixa de entrada (conta suporte) ── */
.atd-layout { display: flex; gap: 14px; align-items: stretch; height: min(70vh, 640px); }
.atd-list {
  width: 300px; flex-shrink: 0; overflow-y: auto;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 14px; padding: 8px;
}
.atd-item {
  width: 100%; text-align: left; cursor: pointer; border: 1px solid transparent;
  background: none; border-radius: 10px; padding: 10px 11px; color: var(--tx);
  font-family: 'Inter', sans-serif; display: block; margin-bottom: 4px;
}
.atd-item:hover { background: var(--s2); }
.atd-item.active { background: var(--s2); border-color: var(--or); }
.atd-item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.atd-item-nome { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atd-unread {
  min-width: 19px; height: 19px; border-radius: 999px; flex-shrink: 0;
  background: var(--or); color: #fff; font-size: 10.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.atd-item-prev { font-size: 11.5px; color: var(--mu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atd-item-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.atd-status { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 999px; padding: 2px 8px; }
.atd-status--aberto    { color: var(--amber); background: rgba(245,158,11,.12); }
.atd-status--resolvido { color: var(--green); background: rgba(34,197,94,.12); }
.atd-item-quando { font-size: 10px; color: var(--mu); }

.atd-chatwrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.atd-chathead {
  display: flex; align-items: center; gap: 10px;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 12px; padding: 10px 14px;
}
.atd-chathead-nome { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atd-chathead-email { font-size: 11px; color: var(--mu); }
.atd-chatwrap .sup-chat { flex: 1; height: auto; }

.atd-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--mu); font-size: 13px; background: var(--s1); border: 1px dashed var(--bd); border-radius: 14px;
}

/* ── anexos (imagem inline / chip de arquivo) ── */
.sup-attach {
  align-self: flex-end; width: 42px; height: 42px; flex-shrink: 0;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 10px;
  color: var(--mu); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.sup-attach:hover { color: var(--or); border-color: var(--or); }
.sup-img { display: block; max-width: 230px; max-height: 170px; border-radius: 9px; margin-bottom: 4px; }
.sup-file {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 4px;
  font-size: 12px; font-weight: 600; color: inherit; text-decoration: underline; word-break: break-all;
}
.sup-file svg { flex-shrink: 0; }

/* ── avaliação (estrelas do cliente) ── */
.sup-stars { display: flex; gap: 6px; justify-content: center; }
.sup-star {
  background: none; border: none; font-size: 28px; line-height: 1; cursor: pointer;
  padding: 2px; color: var(--mu); transition: color .12s, transform .12s;
}
.sup-star:hover, .sup-star.on { color: var(--amber); transform: scale(1.15); }
.sup-stars-txt, .atd-stars { color: var(--amber); letter-spacing: 1.5px; font-size: 12px; white-space: nowrap; }

/* bolinha de status dos serviços (online/instável) */
.atd-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.atd-dot--ok { background: var(--green); }
.atd-dot--bad { background: var(--red); }

/* ── SLA (contadores no cabeçalho da conversa) ── */
.atd-sla { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.atd-sla span {
  font-size: 10.5px; color: var(--mu);
  background: var(--s2); border: 1px solid var(--bd); border-radius: 999px; padding: 2px 9px;
}
.atd-sla b { color: var(--tx); font-weight: 700; }
.atd-media { font-size: 12px; color: var(--mu); font-weight: 600; }

/* status derivados (além de aberto/resolvido) */
.atd-status--novo { color: var(--blue); background: rgba(59,130,246,.12); }
.atd-status--aguarda-voce { color: var(--amber); background: rgba(245,158,11,.12); }
.atd-status--aguarda-cliente { color: var(--mu); background: var(--s3); }

/* ── respostas rápidas (menu sobre a caixa de resposta) ── */
.qr-wrap { position: relative; }
.qr-menu {
  position: absolute; bottom: calc(100% - 4px); left: 10px; right: 10px; z-index: 6;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 10px;
  overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.qr-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  color: var(--tx); font-family: 'Inter', sans-serif; font-size: 12px; padding: 9px 12px;
}
.qr-item:hover { background: var(--s2); }
.qr-item b { color: var(--or); font-size: 11px; }

/* ── categorias do chamado (cliente escolhe antes de abrir) ── */
.sup-cats { padding: 10px 12px; border-top: 1px solid var(--bd); background: var(--s2); }
.sup-cats-lbl { font-size: 11px; font-weight: 600; color: var(--mu); margin-bottom: 7px; }
.sup-cats-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.sup-cat-chip {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 999px;
  color: var(--tx); font-family: 'Inter', sans-serif; font-size: 11.5px;
  padding: 5px 12px; cursor: pointer;
}
.sup-cat-chip:hover { border-color: var(--or); }
.sup-cat-chip.on { background: var(--or); border-color: var(--or); color: #fff; font-weight: 700; }

/* chip de categoria na lista do atendimento */
.atd-cat {
  font-size: 9.5px; font-weight: 700; color: var(--or);
  background: var(--accent-soft); border-radius: 999px; padding: 2px 8px;
  white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}

/* ── painel de diagnóstico e base de conhecimento (ficha técnica) ── */
.atd-tech {
  background: var(--s1); border: 1px solid var(--bd); border-radius: 12px;
  padding: 14px 16px; max-height: 340px; overflow-y: auto; flex-shrink: 0;
}
.atd-tech-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--bd);
}
.atd-tech-title { font-size: 14px; font-weight: 700; color: var(--tx); }
.atd-tech-sec { padding: 12px 0; border-bottom: 1px solid var(--bd); }
.atd-tech-sec:last-child { border-bottom: none; padding-bottom: 2px; }
.atd-tech-ttl {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em;
  color: var(--mu); margin-bottom: 9px;
}
.atd-tech-sub { text-transform: none; font-weight: 400; letter-spacing: 0; opacity: .8; }

/* rótulo em cima (pequeno/maiúsculo), valor embaixo (forte) */
.atd-kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 18px; }
.atd-kv { min-width: 0; }
.atd-kv-l {
  display: block; font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--mu); margin-bottom: 2px;
}
.atd-kv-v { display: block; font-size: 13px; font-weight: 600; color: var(--tx); word-break: break-word; }
.atd-kv-v .atd-cat { font-size: 10.5px; }
.atd-ok { color: var(--green); font-weight: 700; }
.atd-bad { color: var(--red); font-weight: 700; }

.atd-svc-row { display: flex; flex-wrap: wrap; gap: 8px; }
.atd-svc {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--tx);
  background: var(--s2); border: 1px solid var(--bd); border-radius: 999px; padding: 5px 12px;
}
.atd-tech-nota { font-size: 12px; color: var(--mu); }

/* ── Análise da Jessie (diagnóstico pronto) ── */
.atd-jessie {
  border: 1px solid var(--bd); border-left-width: 3px; border-radius: 10px;
  background: var(--s2); padding: 12px 14px; margin: 12px 0;
}
.atd-jessie--info    { border-left-color: var(--blue); }
.atd-jessie--atencao { border-left-color: var(--amber); }
.atd-jessie--alerta  { border-left-color: var(--red); }
.atd-jessie-head {
  display: flex; align-items: center; gap: 7px; margin-bottom: 7px;
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--or);
}
.atd-jessie-titulo { font-size: 13.5px; font-weight: 700; color: var(--tx); margin-bottom: 8px; }
.atd-jessie-linha { font-size: 12px; color: var(--tx); line-height: 1.5; margin-bottom: 6px; }
.atd-jessie-rot {
  display: block; font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--mu); margin-bottom: 1px;
}
.atd-jessie-art {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--bd);
  font-size: 12px; color: var(--mu);
}
.atd-jessie-art b { color: var(--tx); }

/* ── banner de incidente geral (vários chamados na mesma categoria) ── */
.atd-incidente {
  display: flex; align-items: flex-start; gap: 9px; margin: 12px 0;
  background: rgba(245,158,11,.10); border: 1px solid rgba(245,158,11,.35);
  border-radius: 10px; padding: 10px 13px; font-size: 12px; line-height: 1.5; color: var(--tx);
}
.atd-incidente svg { color: var(--amber); flex-shrink: 0; margin-top: 1px; }
.atd-incidente b { font-weight: 700; }
.atd-err-line {
  font-size: 11.5px; color: var(--mu); line-height: 1.45;
  background: var(--s2); border-left: 2px solid var(--red); border-radius: 0 6px 6px 0;
  padding: 6px 10px; margin: 6px 0;
}
.atd-err-line b { color: var(--tx); }

.kb-search {
  width: 100%; background: var(--s2); border: 1px solid var(--bd); border-radius: 8px;
  color: var(--tx); font-family: 'Inter', sans-serif; font-size: 12px;
  padding: 8px 10px; outline: none; margin-bottom: 6px;
}
.kb-search:focus { border-color: var(--or); }
.kb-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--bd); }
.kb-row:last-child { border-bottom: none; }
.kb-titulo { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--tx); cursor: help; }

/* badge de não-lidas no menu lateral (Suporte/Atendimento) */
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; border-radius: 999px;
  background: var(--or); color: #fff; font-size: 10px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ── painel "Peças" (busca no atendimento, sem sair da conversa) ── */
.atd-pecas {
  width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 14px; padding: 12px; overflow-y: auto;
  transition: width .15s ease;
}
.pecas-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pecas-hd-t { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--mu); }
.pecas-hd-t svg { color: var(--or); }
.pecas-collapse, .pecas-expand {
  flex-shrink: 0; width: 28px; height: 28px; border: 1px solid var(--bd); background: var(--s2);
  color: var(--mu); border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.pecas-collapse:hover, .pecas-expand:hover { color: var(--or); border-color: var(--or); }
.pecas-expand { display: none; }

/* recolhido: vira um trilho fino, só com o ícone de abrir a busca */
.atd-pecas.collapsed { width: 48px; padding: 10px 0; align-items: center; overflow: hidden; }
.atd-pecas.collapsed .pecas-hd,
.atd-pecas.collapsed .pecas-search,
.atd-pecas.collapsed .pecas-hint,
.atd-pecas.collapsed .pecas-res { display: none; }
.atd-pecas.collapsed .pecas-expand { display: inline-flex; }
.pecas-search { display: flex; gap: 6px; }
.pecas-search input {
  flex: 1; min-width: 0; background: var(--s2); border: 1px solid var(--bd); border-radius: 7px;
  color: var(--tx); font-family: 'Inter', sans-serif; font-size: 12.5px; padding: 7px 9px; outline: none;
}
.pecas-search input:focus { border-color: var(--or); }
.pecas-hint { font-size: 11.5px; color: var(--tx); }
.pecas-hint b { color: var(--or); }
.pecas-res { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.peca-card { background: var(--s2); border: 1px solid var(--bd); border-radius: 10px; padding: 9px 10px; }
.peca-nome { font-size: 12.5px; font-weight: 600; color: var(--tx); margin-bottom: 5px; line-height: 1.3; }
.peca-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 7px; }
.peca-estoque { font-size: 10px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.peca-estoque--ok { color: var(--green); background: rgba(34,197,94,.12); }
.peca-estoque--no { color: var(--red); background: rgba(220,50,50,.12); }
.peca-cod { font-size: 10.5px; color: var(--mu); }
.peca-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.peca-acts .btn-sm { font-size: 10.5px; padding: 5px 8px; }
.peca-semanuncio { font-size: 10.5px; color: var(--mu); font-style: italic; }

/* caixa de resposta do Atendimento ML — mais alta e confortável de escrever */
#atmTexto { min-height: 84px; max-height: 240px; line-height: 1.5; }

/* ── respostas rápidas (botão + menu na caixa de resposta) ── */
.sup-qrbtn {
  align-self: flex-end; height: 42px; width: 42px; flex-shrink: 0;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 10px;
  color: var(--mu); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: color .15s, border-color .15s;
}
.sup-qrbtn:hover { color: var(--or); border-color: var(--or); }
#atmQr { display: none; left: 0; right: auto; width: min(320px, 78vw); max-height: 300px; overflow-y: auto; bottom: calc(100% + 6px); }
#atmQr.on { display: block; }
.qr-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--bd); }
.qr-row:last-of-type { border-bottom: none; }
.qr-ins {
  flex: 1; min-width: 0; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--tx); font-family: 'Inter', sans-serif; font-size: 12px; line-height: 1.4; padding: 9px 11px;
  white-space: normal; word-break: break-word;
}
.qr-ins:hover { background: var(--s2); }
.qr-del {
  flex-shrink: 0; width: 30px; background: none; border: none; border-left: 1px solid var(--bd);
  color: var(--mu); font-size: 16px; line-height: 1; cursor: pointer;
}
.qr-del:hover { color: var(--red); background: var(--s2); }
.qr-add {
  display: block; width: 100%; text-align: left; background: var(--s2); border: none; border-top: 1px solid var(--bd);
  color: var(--or); font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 600; padding: 9px 11px; cursor: pointer;
}
.qr-add:hover { filter: brightness(1.12); }
.qr-vazio { padding: 10px 12px; font-size: 11.5px; color: var(--mu); }

/* ── polimento do layout do Atendimento ML (escopado à página) ── */
#page-atendimento-ml .err-tabs {
  display: inline-flex; gap: 3px; margin: 0;
  background: var(--s1); border: 1px solid var(--bd); border-radius: 10px; padding: 3px;
}
#page-atendimento-ml .err-tab {
  border: none; background: none; border-radius: 8px; cursor: pointer;
  color: var(--mu); font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 600; padding: 7px 15px; transition: background .15s, color .15s;
}
#page-atendimento-ml .err-tab:hover { color: var(--tx); }
#page-atendimento-ml .err-tab.active { background: var(--or); color: #fff; }
#page-atendimento-ml .atd-list,
#page-atendimento-ml .atd-chatwrap .sup-chat,
#page-atendimento-ml .atd-pecas { box-shadow: 0 1px 3px rgba(0,0,0,.06); }
#page-atendimento-ml .atd-chathead { box-shadow: 0 1px 3px rgba(0,0,0,.06); }

@media (max-width: 760px) {
  .atd-layout { flex-direction: column; height: auto; }
  .atd-list { width: 100%; max-height: 300px; }
  .atd-chatwrap .sup-chat { height: min(56vh, 480px); }
  .atd-pecas { width: 100%; max-height: 340px; }
  .atd-pecas.collapsed { width: 100%; max-height: none; padding: 8px; }
  .sup-msg { max-width: 88%; }
}
