/* "Chatwoot enxuto" (prompt mestre, Etapa 2): o atendente não percebe que está em outro sistema.
   Carregado pelo Chatwoot via DASHBOARD_SCRIPTS. Registro em docs/ALTERACOES-CHATWOOT.md.
   Esconder na tela não é controle de acesso: o filtro por setor é feito no servidor (atd_alteracoes.rb). */

/* Marca e troca de conta: o portal já mostra a escola no topo */
#sidebar-account-switcher,
aside section > div:has(#sidebar-account-switcher) { display: none !important; }

/* Menu lateral: só as conversas (todas do setor, minhas, sem responsável) e a busca */
aside li:has(> a[name="Inbox"]),
aside li[name="Mentions"],
aside li[name="Participating"],
aside li[name="Unattended"],
aside li:has(> a[name="Contacts"]),
aside li:has(> a[name="Companies"]),
aside li:has(> a[name="Portals"]),
aside li:has(> a[name="Settings"]),
aside li:has(> a[name="Captain"]),
aside li:has(> a[name="Reports"]),
aside li:has(> a[name="Campaigns"]) { display: none !important; }

/* Código do canal ao lado do nome (identificador da API pública) e ícone técnico do canal */
[data-test-id="channel-identifier"],
span[aria-hidden="true"]:has(+ [data-test-id="channel-identifier"]) { display: none !important; }
.i-woot-api { display: none !important; }

/* Caixa de resposta: sem o botão de assinatura do Chatwoot (a assinatura é a da Evolution, regra 10)
   e sem o botão de IA */
button:has(.i-ph-signature),
button:has(.i-ph-sparkle-fill) { display: none !important; }

/* Painel da conversa (04/11): nome do setor e do responsável inteiro, quebrando a linha, na lista de escolha e no
   campo escolhido (nomes longos como "Coordenação Anos Finais e Ensino Médio" eram cortados) */
.conversation--actions button:has(span.text-ellipsis) { height: auto !important; min-height: 2.25rem; padding-top: 0.375rem !important; padding-bottom: 0.375rem !important; }
.conversation--actions button span.text-ellipsis { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; text-align: left; }

/* Itens que o JavaScript marca para esconder (menus com texto, grupos sem atributo) */
[data-atd-oculto] { display: none !important; }

/* Texto de ajuda da caixa de resposta (sem "Resposta Pronta": respostas prontas estão fora do escopo) */
.reply-box .ProseMirror p.empty-node:first-child::before { content: "Escreva a resposta. Shift + Enter pula linha." !important; }
.reply-box.is-private .ProseMirror p.empty-node:first-child::before { content: "Anotação interna: o contato não recebe. Só a equipe vê." !important; }

/* Itens "Todas do meu setor" (colaborador) e "Todas as conversas" (admin): quebram a linha em vez de cortar o texto */
[data-atd-quebra] {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.25 !important;
}
[data-atd-quebra-item] {
  height: auto !important;
  min-height: 2rem !important;
  padding-top: 0.375rem !important;
  padding-bottom: 0.375rem !important;
}

/* Setores no menu (04/11): o nome inteiro, quebrando a linha (com todos os setores para o administrador, os nomes
   longos ficavam iguais: "Coordenação An...") */
aside a[href*="/team/"] { height: auto !important; min-height: 2rem !important; padding-top: 0.375rem !important; padding-bottom: 0.375rem !important; }
aside a[href*="/team/"] * { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; line-height: 1.25 !important; }

/* Nenhum link para as configurações do Chatwoot (a configuração é pelo portal) */
a[href*="/settings"] {
  display: none !important;
}

/* Estado vazio nosso no lugar da tela de boas-vindas do Chatwoot */
[data-atd-vazio] {
  max-width: 30rem;
  margin: 18vh auto 0;
  padding: 0 1.5rem;
  text-align: center;
}
.atd-vazio-titulo {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}
.atd-vazio-texto {
  font-size: 0.95rem;
  line-height: 1.5;
  opacity: 0.75;
  margin: 0 0 1.25rem;
}
.atd-vazio-botao {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  text-decoration: none;
  background: #1f6fe0;
  color: #fff !important;
}

/* Botão "Conectar o WhatsApp" na lista vazia: só no celular (no computador ele já está ao lado) */
[data-atd-botao-lista] {
  margin: 0.75rem auto 0;
  display: table !important;
  line-height: 2.75rem;
}
@media (min-width: 768px) {
  [data-atd-botao-lista] {
    display: none !important;
  }
}

/* Mensagem digitada direto no celular da escola, fora do sistema (PRD 4.15) */
[id^="message"]:has(> [data-atd-celular]) {
  flex-wrap: wrap !important;
}
[data-atd-celular] {
  order: 99;
  width: 100%;
  flex-basis: 100%;
  margin: 0.125rem 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #b45309;
  text-align: right;
}
/* Alteração 5: botão "Ver CPF completo" (administradores) */
[data-atd-cpf] { display: inline-flex; flex: 0 0 auto; align-self: center; height: 32px; align-items: center; margin: 0 8px; padding: 0 10px; border: 1px solid currentColor; white-space: nowrap;
  border-radius: 8px; background: transparent; font-size: 13px; font-weight: 600; cursor: pointer; opacity: .85; }
[data-atd-cpf]:hover { opacity: 1; }
/* Etapa 4A: cartão de quem escreve, logo abaixo do cabeçalho da conversa */
[data-atd-cartao] { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 12px; border-bottom: 1px solid rgb(var(--border-weak, 228 228 231));
  background: rgba(59, 130, 246, .06); font-size: 13px; line-height: 1.4; }
[data-atd-cartao] strong { font-weight: 600; }
.atd-cartao-fraco { opacity: .75; }
.atd-cartao-filhos { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.atd-cartao-filho { display: inline-flex; padding: 1px 8px; border: 1px solid rgba(100, 116, 139, .35); border-radius: 999px; }
.atd-cartao-escolhido { border-color: currentColor; font-weight: 600; }
.atd-cartao-link { margin-left: auto; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
/* Etapa 4C: arquivo a classificar no cartão e aviso de anexo que foi para o Drive */
.atd-cartao-arquivo { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; font-weight: 600; }
.atd-cartao-arquivo button { min-height: 32px; padding: 0 12px; border: 1px solid currentColor; border-radius: 8px; background: transparent; font-weight: 600; cursor: pointer; }
/* PRD 3.18: alertas do dia e últimos comunicados no cartão */
.atd-cartao-alerta { width: 100%; font-weight: 600; color: #b54708; }
.dark .atd-cartao-alerta { color: #fdb022; }
.atd-cartao-comunicados { display: flex; flex-wrap: wrap; gap: 2px 10px; width: 100%; }
.atd-cartao-comunicado { overflow-wrap: anywhere; }
[id^="message"]:has(> [data-atd-drive]) { flex-wrap: wrap !important; }
[data-atd-drive] { order: 99; width: 100%; flex-basis: 100%; margin: 0.125rem 0 0.25rem; font-size: 0.75rem; font-weight: 600; color: #047857; }

/* Nova conversa (ajuste do Matheus, 30/09): sem o lápis ao lado de "Pesquisar..." e sem "Nova mensagem" no painel do
   contato, para todos os perfis. O servidor também recusa a criação de conversa pela equipe (atd_alteracoes.rb) */
aside button:has(.i-lucide-pen-line),
button:has(.i-ph-chat-circle-dots) { display: none !important; }

/* Nova conversa (05/11): janela no estilo das do sistema de conversas */
.atd-modal-fundo { position: fixed; inset: 0; z-index: 10000; background: rgba(15, 23, 42, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.atd-modal { width: 100%; max-width: 480px; max-height: 80vh; overflow: auto; background: #fff; color: #1c2024; border-radius: 12px; box-shadow: 0 16px 48px rgba(0,0,0,0.2); padding: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.atd-modal-topo { display: flex; align-items: center; justify-content: space-between; }
.atd-modal-topo h2 { font-size: 16px; font-weight: 600; margin: 0; }
.atd-modal-fechar { width: 28px; height: 28px; border-radius: 8px; font-size: 20px; line-height: 1; color: #60646c; }
.atd-modal-fechar:hover { background: #f0f0f3; }
.atd-modal-ajuda { color: #60646c; margin: 0 0 4px; }
.atd-modal-rotulo { font-weight: 500; margin-top: 6px; }
.atd-modal-campo { width: 100%; border: 1px solid #d9d9e0; border-radius: 8px; padding: 8px 10px; font: inherit; color: inherit; background: #fff; }
.atd-modal-campo:focus { outline: 2px solid #8da4ef; outline-offset: 0; }
.atd-modal-lista { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow: auto; }
.atd-modal-opcao { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; border: 1px solid #e8e8ec; border-radius: 8px; padding: 8px 10px; }
.atd-modal-opcao span { color: #60646c; font-size: 13px; }
.atd-modal-opcao:hover { background: #f9f9fb; }
.atd-modal-opcao[aria-selected="true"] { border-color: #3e63dd; background: #edf2fe; }
.atd-modal-vazio { color: #60646c; margin: 4px 0; }
.atd-modal-erro { color: #ce2c31; margin: 4px 0 0; }
.atd-modal-acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.atd-modal-secundario, .atd-modal-primario { min-height: 36px; padding: 0 14px; border-radius: 8px; font-weight: 500; }
.atd-modal-secundario { background: #f0f0f3; color: #1c2024; }
.atd-modal-primario { background: #3e63dd; color: #fff; }
.atd-modal-primario:disabled { opacity: 0.6; }
@media (prefers-color-scheme: dark) {
  .dark .atd-modal { background: #18191b; color: #edeef0; }
  .dark .atd-modal-campo { background: #111113; border-color: #363a3f; }
  .dark .atd-modal-opcao { border-color: #2e3135; }
}

/* Aba "Resolvidas" (05/11) e telas menores (06/11): as quatro abas cabem sem rolar de lado (regra 14) e a conversa
   aberta não fica espremida em notebook (1280, 1366 ou zoom de 125%). A lista só fica mais larga em tela grande */
.conversations-list-wrap ul { padding-left: 0 !important; padding-right: 0 !important; }
.conversations-list-wrap ul > li:first-child { margin-left: 0 !important; }
.conversations-list-wrap ul > li { margin-left: 3px !important; margin-right: 3px !important; font-size: 13px; }
.conversations-list-wrap ul > li a > div { margin-left: 3px !important; padding-left: 5px !important; padding-right: 5px !important; min-width: 18px !important; }
@media (min-width: 768px) {
  .conversations-list-wrap.w-\[340px\] { width: 380px !important; }
}
@media (min-width: 1440px) {
  .conversations-list-wrap.w-\[340px\] { width: 400px !important; }
  .conversations-list-wrap ul > li { margin-left: 5px !important; margin-right: 5px !important; font-size: 13.5px; }
}
@media (min-width: 1600px) {
  .conversations-list-wrap.w-\[340px\] { width: 440px !important; }
}


/* Aguardando retorno (08/11) */
[data-atd-aguardando] { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 16px; font-size: 13px; border-bottom: 1px solid rgb(var(--slate-4, 226 232 240)); }
[data-atd-aguardando] button { min-height: 32px; padding: 0 10px; border: 1px solid currentColor; border-radius: 6px; font-weight: 600; background: transparent; cursor: pointer; }
/* Resposta errada da assistente (08/11) */
[data-atd-errada] { display: block; margin: 2px 0 0 auto; padding: 2px 8px; font-size: 12px; font-weight: 600; color: #b42318; background: transparent; border: 0; cursor: pointer; text-decoration: underline; }
[data-atd-errada]:disabled { color: #667085; text-decoration: none; cursor: default; }
