/* Painel de atendimento — primeiro para celular, depois telas maiores. */
:root {
  --cor: #0f766e;
  --cor-escura: #115e59;
  --cor-clara: #ccfbf1;
  --fundo: #f4f6f8;
  --cartao: #ffffff;
  --texto: #1f2937;
  --suave: #6b7280;
  --borda: #e5e7eb;
  --erro: #b91c1c;
  --erro-fundo: #fef2f2;
  --ok: #166534;
  --ok-fundo: #f0fdf4;
  --raio: 14px;
  --cor-texto: #0f766e; /* cor da marca quando usada em texto */
  /* superfícies do modo conversas (mudam no tema escuro) */
  --painel: #ffffff;
  --painel-2: #f0f2f5;
  --campo: #ffffff;
  --papel: #efeae2;
  --papel-ponto: rgba(0,0,0,.045);
  --bolha-entrada: #ffffff;
  --bolha-saida: #d9fdd3;
  --hover: #f5f6f6;
  --selecionado: #e9edef;
  --chip-ativo: #ccfbf1;
  --chip-ativo-texto: #115e59;
  --info: #1e40af;
  --info-fundo: #eff6ff;
  --anuncio: #92400e;
  --anuncio-fundo: #fef3c7;
  --visor: rgba(0,0,0,.9);   /* fundo do visor de foto (igual nos dois temas) */
  --gravando: #dc2626;       /* bolinha "gravando" */
  color-scheme: light dark;
}

/* tema escuro: segue o tema do aparelho */
@media (prefers-color-scheme: dark) {
  :root {
    --cor: #0f766e;
    --cor-escura: #99f6e4;
    --cor-clara: #134e4a;
    --cor-texto: #2dd4bf;
    --fundo: #0b141a;
    --cartao: #111b21;
    --texto: #e9edef;
    --suave: #8696a0;
    --borda: #2a3942;
    --erro: #fca5a5;
    --erro-fundo: #3b1d1d;
    --ok: #86efac;
    --ok-fundo: #12291b;
    --painel: #111b21;
    --painel-2: #202c33;
    --campo: #2a3942;
    --papel: #0b141a;
    --papel-ponto: rgba(255,255,255,.035);
    --bolha-entrada: #202c33;
    --bolha-saida: #005c4b;
    --hover: #202c33;
    --selecionado: #2a3942;
    --chip-ativo: #0a332c;
    --chip-ativo-texto: #5eead4;
    --info: #93c5fd;
    --info-fundo: #172338;
    --anuncio: #fcd34d;
    --anuncio-fundo: #3a2e0b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }

/* topo */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--cor); color: #fff;
}
.topo-info { display: flex; flex-direction: column; min-width: 0; }
.topo-info strong { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-info span { font-size: .82rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-sair {
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px; padding: 8px 16px; font: inherit; font-size: .9rem; cursor: pointer; min-height: 40px;
}

/* conteúdo */
main { padding: 16px; max-width: 640px; margin: 0 auto; }
.carregando { text-align: center; color: var(--suave); padding: 40px 0; }

.cartao {
  background: var(--cartao); border-radius: var(--raio); padding: 20px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 16px;
}
.cartao h1, .cartao h2 { margin: 0 0 12px; }
.cartao h2 { font-size: 1.15rem; }
.sub { color: var(--suave); margin: 0 0 16px; }

.cartao-login { margin-top: 8vh; text-align: center; }
.cartao-login form { text-align: left; }
.logo {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px;
  background: var(--cor) url("/icone.svg") center / cover no-repeat;
}

form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; }
input, select {
  font: inherit; font-weight: 400; padding: 12px; border: 1px solid var(--borda); border-radius: 10px;
  background: var(--campo); color: var(--texto); min-height: 48px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--cor); outline-offset: 1px; border-color: var(--cor); }
.linha { display: flex; gap: 8px; }
.linha input { flex: 1; }

.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 12px 18px; min-height: 48px;
  background: var(--cor); color: #fff; cursor: pointer;
}
.btn:hover { background: var(--cor-escura); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-secundario { background: var(--cor-clara); color: var(--cor-escura); }
.btn-secundario:hover { background: #99f6e4; color: #115e59; }
.btn-link { background: none; border: 0; font: inherit; font-size: .9rem; color: var(--cor-texto); cursor: pointer; padding: 8px 4px; min-height: 40px; }
.btn-link.perigo { color: var(--erro); }

.aviso { padding: 10px 12px; border-radius: 10px; font-size: .92rem; margin: 0 0 12px; text-align: left; }
.aviso-erro { background: var(--erro-fundo); color: var(--erro); }
.aviso-ok { background: var(--ok-fundo); color: var(--ok); }
.dica { color: var(--suave); font-size: .85rem; margin: 0; }

.chave { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.chave input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--cor); }

/* início vazio */
.vazio { text-align: center; padding: 40px 16px; }
.vazio p { color: var(--suave); margin: 0; }
.vazio-icone {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%;
  background: var(--cor-clara) url("/icone.svg") center / 44px no-repeat;
}

/* equipe */
.lista-pessoas { list-style: none; margin: 0; padding: 0; }
.pessoa { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 1px solid var(--borda); }
.pessoa:first-child { border-top: 0; }
.pessoa.inativa { opacity: .55; }
.pessoa-info { display: flex; flex-direction: column; min-width: 0; }
.pessoa-info span { color: var(--suave); font-size: .9rem; overflow-wrap: anywhere; }
.pessoa-acoes { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.etiquetas { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.etiqueta { background: var(--cor-clara); color: var(--cor-escura) !important; font-size: .75rem !important; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.etiqueta-cinza { background: var(--borda); color: var(--suave) !important; }

/* abas de baixo (polegar alcança fácil no celular) */
.abas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--painel); border-top: 1px solid var(--borda);
  padding-bottom: env(safe-area-inset-bottom);
}
.abas a {
  flex: 1; text-align: center; padding: 14px 8px; color: var(--suave); text-decoration: none; font-weight: 600; min-height: 56px;
}
.abas a.ativa { color: var(--cor-texto); box-shadow: inset 0 3px 0 var(--cor-texto); }

/* telas maiores */
@media (min-width: 720px) {
  main { padding: 24px; }
  .pessoa { flex-direction: row; align-items: center; justify-content: space-between; }
  .pessoa-acoes { justify-content: flex-end; }
}

/* ---------- Fase 2: conversas ---------- */
.badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px;
  background: #16a34a; color: #fff; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.4;
}
.abas a { font-size: .9rem; padding: 14px 4px; }

.aviso-info { background: var(--info-fundo); color: var(--info); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; background: var(--fundo); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
textarea {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 10px;
  width: 100%; resize: vertical; background: var(--campo); color: var(--texto);
}
textarea:focus { outline: 2px solid var(--cor); outline-offset: 1px; border-color: var(--cor); }
textarea:disabled, input:disabled, button:disabled { opacity: .55; cursor: not-allowed; }
details summary { cursor: pointer; font-weight: 600; color: var(--cor-texto); padding: 8px 0; min-height: 40px; }
details[open] summary { margin-bottom: 8px; }

/* segmentos (Minhas / Todas / Fila) */
.segmentos { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.seg {
  flex: 1; text-align: center; padding: 10px 8px; border-radius: 10px; border: 1px solid var(--borda);
  background: var(--campo); color: var(--texto); text-decoration: none; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px;
}
.seg.ativo { background: var(--cor); color: #fff; border-color: var(--cor); }
.segmentos-pequenos .seg { padding: 6px 8px; font-size: .88rem; min-height: 38px; }
.seg-radio { flex: 1; flex-direction: row; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--borda); border-radius: 10px; padding: 8px; font-weight: 600; cursor: pointer; min-height: 44px; }
.seg-radio input { width: 18px; min-height: 18px; height: 18px; accent-color: var(--cor); }
.seg-radio:has(input:checked) { border-color: var(--cor); background: var(--cor-clara); color: var(--cor-escura); }

/* ---------- conversas em tela cheia (estilo app de mensagens) ---------- */
body.modo-chat {
  height: 100vh; height: 100dvh; min-height: 0; padding-bottom: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
body.modo-chat .topo, body.modo-chat .abas { position: static; flex-shrink: 0; }
body.modo-chat main { flex: 1; min-height: 0; max-width: none; width: 100%; margin: 0; padding: 0; }

.split { height: 100%; display: grid; grid-template-columns: 1fr; background: var(--painel); }
.painel-lista, .painel-chat { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.split.mostra-chat .painel-lista { display: none; }
.split:not(.mostra-chat) .painel-chat { display: none; }

.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--cor-clara); color: var(--cor-escura); font-weight: 700; font-size: 1.2rem;
}

/* lista de conversas */
.lista-topo { padding: 10px 14px 6px; background: var(--painel); }
.lista-topo .dica { margin: 0 0 8px; }
.lista-conversas { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; }
.conversa-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  color: var(--texto); text-decoration: none; border-bottom: 1px solid var(--painel-2);
}
.conversa-item:hover { background: var(--hover); }
.conversa-item.selecionada { background: var(--selecionado); }
.conversa-conteudo { flex: 1; min-width: 0; }
.conversa-item.nao-lida .conversa-nome, .conversa-item.nao-lida .conversa-previa { font-weight: 700; color: var(--texto); }
.conversa-item.nao-lida .conversa-hora { color: #16a34a; font-weight: 700; }
.conversa-linha { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.conversa-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.conversa-hora { color: var(--suave); font-size: .78rem; flex-shrink: 0; }
.conversa-previa { color: var(--suave); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.etiqueta-anuncio { background: var(--anuncio-fundo); color: var(--anuncio) !important; }
.vazio-lista { color: var(--suave); text-align: center; padding: 24px 8px; list-style: none; }

/* uma conversa */
.chat-topo {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--painel-2); border-bottom: 1px solid var(--borda); flex-shrink: 0;
}
.chat-topo-info { flex: 1; min-width: 0; }
.chat-topo-info > .dica { margin: 4px 0 0; }
.conversa-topo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.conversa-topo .avatar { width: 42px; height: 42px; font-size: 1.05rem; }
.conversa-topo-info { display: flex; flex-direction: column; min-width: 0; }
.conversa-topo-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversa-topo-info .dica { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voltar { font-size: 2rem; line-height: 1; color: var(--cor-texto); text-decoration: none; padding: 0 4px 4px 0; min-width: 28px; }
.btn-acoes {
  flex-shrink: 0; font: inherit; font-size: .88rem; font-weight: 600; color: var(--cor-escura);
  background: var(--campo); border: 1px solid var(--borda); border-radius: 999px; padding: 8px 14px; min-height: 40px; cursor: pointer;
}
.btn-acoes[aria-expanded="true"] { background: var(--cor-clara); border-color: var(--cor); }

.chat-corpo { flex: 1; min-height: 0; position: relative; }
.mensagens {
  list-style: none; margin: 0; height: 100%; overflow-y: auto; padding: 16px 12px;
  background: var(--papel); display: flex; flex-direction: column; gap: 4px;
}
.bolha { max-width: 85%; padding: 6px 9px 4px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11,20,26,.13); overflow-wrap: anywhere; }
.bolha-entrada { align-self: flex-start; background: var(--bolha-entrada); border-top-left-radius: 0; }
.bolha-saida { align-self: flex-end; background: var(--bolha-saida); border-top-right-radius: 0; }
.bolha-falhou { background: var(--erro-fundo); }
.bolha-texto { white-space: pre-wrap; }
.bolha-rodape { display: flex; gap: 8px; justify-content: flex-end; color: var(--suave); font-size: .7rem; margin-top: 2px; flex-wrap: wrap; }
.bolha-erro { color: var(--erro); font-size: .75rem; }
.bolha-como { color: var(--info); font-weight: 600; } /* gerente respondeu em nome do vendedor */
.assinar-como { font-size: .85rem; margin: 0 0 6px; min-height: 32px; }
.assinar-como input { width: 20px; min-height: 20px; height: 20px; }
.midia { font-style: italic; color: var(--suave); }

.painel-acoes {
  position: absolute; inset: 0 0 0 auto; width: min(400px, 100%); z-index: 5;
  overflow-y: auto; background: var(--fundo); padding: 12px; box-shadow: -2px 0 10px rgba(0,0,0,.12);
}
.painel-acoes-topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

.chat-rodape { background: var(--painel-2); padding: 8px 12px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.chat-rodape .aviso { margin: 0 0 8px; }
.chat-rodape .dica { margin: 0 0 6px; font-size: .78rem; }
.caixa-resposta { flex-direction: row; align-items: flex-end; gap: 8px; }
.caixa-resposta textarea {
  flex: 1; min-height: 44px; max-height: 140px; resize: none; border: 0; border-radius: 22px; padding: 11px 16px; line-height: 1.35;
}
.btn-enviar {
  flex-shrink: 0; width: 46px; height: 46px; min-height: 46px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.chat-vazio {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--painel-2); color: var(--suave); text-align: center; padding: 24px; border-bottom: 6px solid var(--cor);
}
.chat-vazio h2 { color: var(--texto); font-weight: 400; margin: 8px 0 0; }
.chat-vazio p { margin: 0; max-width: 360px; }

/* celular: dentro da conversa, esconde as abas de baixo para sobrar espaço */
@media (max-width: 899px), (max-height: 499px) {
  body.modo-chat.em-conversa .abas { display: none; }
  body.modo-chat.em-conversa .topo { display: none; } /* dentro da conversa o cabeçalho da conversa já basta */
  .chat-topo-info > .dica { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
/* computador: lista e conversa lado a lado */
@media (min-width: 900px) and (min-height: 500px) {
  .split { grid-template-columns: minmax(300px, 30%) 1fr; }
  .split .painel-lista, .split .painel-chat { display: flex; }
  .split.mostra-chat .painel-lista { display: flex; }
  .split:not(.mostra-chat) .painel-chat { display: flex; }
  .painel-lista { border-right: 1px solid var(--borda); }
  .voltar { display: none; }
  .mensagens { padding: 20px 7%; }
  .bolha { max-width: 65%; }
}

/* resumo */
.linha-quebra { flex-wrap: wrap; align-items: flex-end; }
.linha-quebra label { flex: 1; min-width: 130px; }
.tabela-rolagem { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--borda); text-align: right; white-space: nowrap; }
th[scope="row"], tr th:first-child { text-align: left; white-space: normal; min-width: 110px; }

/* equipe */
.acoes-botoes { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: flex-end; }
.senha-uma-vez code { font-size: 1.1rem; letter-spacing: .5px; }

/* ---------- abas com ícones ---------- */
.abas a, .aba-sair {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: inherit; font-size: .74rem; font-weight: 600; padding: 8px 4px; min-height: 58px;
  color: var(--suave); background: none; border: 0; cursor: pointer; text-decoration: none;
}
.abas a.ativa { color: var(--cor-texto); box-shadow: inset 0 3px 0 var(--cor-texto); }
.abas .badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; }
.aba-sair { display: none; } /* no celular o "Sair" fica no topo */

/* ---------- topo da lista: título, pesquisa e filtros ---------- */
.lista-titulo { font-size: 1.35rem; margin: 2px 0 10px; }
label.busca {
  flex-direction: row; align-items: center; gap: 10px; font-weight: 400; color: var(--suave);
  background: var(--painel-2); border-radius: 10px; padding: 0 12px;
}
label.busca:focus-within { outline: 2px solid var(--cor); }
label.busca input { border: 0; background: transparent; min-height: 40px; padding: 8px 0; color: var(--texto); }
label.busca input:focus { outline: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.chip {
  display: inline-flex; align-items: center; min-height: 34px; padding: 4px 14px; border-radius: 999px;
  background: var(--painel-2); color: var(--suave); border: 0; font: inherit; font-size: .9rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.chip:hover { color: var(--texto); }
.chip.ativo { background: var(--chip-ativo); color: var(--chip-ativo-texto); }
/* abas da lista: numa linha só, rolando na horizontal quando não cabem (celular, muitos vendedores) */
.chips-lista {
  flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
  max-width: 100%; min-width: 0; padding-bottom: 4px; -webkit-overflow-scrolling: touch;
}
.chips-lista .chip { flex: 0 0 auto; white-space: nowrap; }
.chip-fora:not(.ativo) { opacity: .65; } /* vendedor fora do rodízio: discreto, nome completo no title */
.so-leitor {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* fundo da conversa com textura leve */
.mensagens { background-color: var(--papel); background-image: radial-gradient(var(--papel-ponto) 1.2px, transparent 1.2px); background-size: 18px 18px; }
.bolha { color: var(--texto); }
.caixa-resposta textarea { background: var(--campo); }

/* ---------- computador: barra de ícones vertical à esquerda ---------- */
@media (min-width: 900px) and (min-height: 500px) {
  body.com-abas {
    display: grid; grid-template-columns: 68px minmax(0, 1fr); grid-template-rows: auto 1fr;
    padding-bottom: 0; min-height: 100vh;
  }
  body.com-abas .abas {
    grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 0; height: 100vh; height: 100dvh;
    flex-direction: column; align-items: center; gap: 6px; padding: 12px 0;
    border-top: 0; border-right: 1px solid var(--borda); background: var(--painel-2);
  }
  body.com-abas .abas a, body.com-abas .aba-sair {
    flex: 0 0 auto; width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; box-shadow: none;
  }
  body.com-abas .abas a:hover, body.com-abas .aba-sair:hover { background: var(--selecionado); color: var(--texto); }
  body.com-abas .abas a.ativa { background: var(--selecionado); color: var(--texto); }
  body.com-abas .aba-sair { display: flex; margin-top: auto; }
  body.com-abas .aba-nome { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.com-abas .abas .badge { top: 0; left: auto; right: -2px; }
  body.com-abas .topo { grid-column: 2; grid-row: 1; }
  body.com-abas main { grid-column: 2; grid-row: 2; }
  body.com-abas.modo-chat { height: 100vh; height: 100dvh; overflow: hidden; }
  body.com-abas.modo-chat .topo { display: none; }
  body.com-abas.modo-chat main { min-height: 0; }
  .painel-lista { background: var(--painel); }
}

/* tema escuro: regras que precisam vir depois das normais para valer */
@media (prefers-color-scheme: dark) {
  .btn:hover { background: #0d9488; }
  .btn-secundario:hover { background: #115e59; color: #ccfbf1; }
}
/* computador: o Sair fica só na barra lateral */
@media (min-width: 900px) and (min-height: 500px) {
  body.com-abas .btn-sair { display: none; }
}
/* celular: o nome da loja já está no topo */
@media (max-width: 899px), (max-height: 499px) {
  .lista-titulo { display: none; }
}

/* ---------- mídia nas bolhas ---------- */
.bolha-midia { padding: 4px 4px 4px; }
.bolha-midia .bolha-rodape, .bolha-midia .midia-legenda, .bolha-midia .midia-situacao { padding: 0 5px; }
.midia-legenda { white-space: pre-wrap; margin-top: 4px; }
.midia-situacao { display: block; font-style: italic; color: var(--suave); font-size: .88rem; padding: 6px 5px; }
.midia-foto {
  display: block; width: fit-content; max-width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in;
  border-radius: 6px; overflow: hidden; line-height: 0;
}
.midia-foto img { display: block; width: auto; height: auto; max-width: 280px; max-height: 320px; min-width: 80px; min-height: 60px; object-fit: cover; }
.midia-figurinha { background: none; min-width: 0; min-height: 0; }
.midia-figurinha img { max-width: 140px; max-height: 140px; object-fit: contain; }
.bolha-midia:has(.midia-figurinha) { background: transparent; box-shadow: none; }
.midia-audio { display: block; width: min(280px, 68vw); height: 44px; }
.midia-video { display: block; max-width: min(320px, 100%); max-height: 360px; border-radius: 6px; background: var(--papel); }
.midia-doc {
  display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 6px; min-width: 200px; max-width: 300px;
  background: var(--painel-2); border: 1px solid var(--borda); color: var(--texto); text-decoration: none;
}
.midia-doc svg { flex-shrink: 0; color: var(--cor-texto); }
.midia-doc-nome { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .92rem; }
.midia-doc-tamanho { color: var(--suave); font-size: .75rem; white-space: nowrap; }
a.midia-doc:hover { border-color: var(--cor); }

/* visor: foto maior */
.visor {
  position: fixed; inset: 0; z-index: 50; background: var(--visor);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px;
}
.visor img { max-width: 100%; max-height: calc(100% - 80px); object-fit: contain; }
.visor-fechar {
  position: absolute; top: calc(8px + env(safe-area-inset-top)); right: 12px; width: 48px; height: 48px;
  font-size: 2rem; line-height: 1; color: #fff; background: none; border: 0; cursor: pointer;
}
.visor-baixar { color: #fff; font-weight: 600; }

/* ---------- caixa de resposta: emoji, clipe, microfone ---------- */
.caixa-resposta { gap: 4px; }
.btn-icone {
  flex-shrink: 0; width: 44px; height: 46px; padding: 0; border: 0; border-radius: 50%; background: none;
  color: var(--suave); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-icone:hover:not(:disabled) { color: var(--texto); background: var(--hover); }
.btn-icone:disabled { opacity: .45; cursor: default; }
.caixa-resposta textarea { margin: 0 4px; }

.painel-emoji {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 2px;
  max-height: 188px; overflow-y: auto; background: var(--painel); border: 1px solid var(--borda);
  border-radius: 12px; padding: 6px; margin-bottom: 8px;
}
.painel-emoji button { font-size: 1.45rem; line-height: 1; height: 42px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.painel-emoji button:hover, .painel-emoji button:focus-visible { background: var(--hover); }

.previa-anexo {
  display: flex; flex-direction: column; gap: 8px; background: var(--painel); border: 1px solid var(--borda);
  border-radius: 12px; padding: 10px;
}
.previa-topo { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; }
.previa-topo strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.previa-conteudo { display: flex; justify-content: center; }
.previa-img, .previa-video { max-width: 100%; max-height: 38vh; border-radius: 8px; object-fit: contain; }
.previa-acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.previa-acoes .previa-legenda { flex: 1 1 200px; }
.previa-acoes .btn { min-height: 44px; padding: 10px 16px; }

.gravador { display: flex; align-items: center; gap: 8px; min-height: 46px; }
.grav-ponto { width: 12px; height: 12px; border-radius: 50%; background: var(--gravando); animation: piscar 1s infinite; flex-shrink: 0; }
.grav-tempo { font-variant-numeric: tabular-nums; font-weight: 600; }
.grav-dica { flex: 1; color: var(--suave); font-size: .9rem; }
@keyframes piscar { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .grav-ponto { animation: none; } }

/* Campos de token/segredo: texto mascarado (não "password"), para gerenciadores de senha não preencherem sozinhos */
.campo-segredo { -webkit-text-security: disc; }

/* ---------- Assistente virtual (robô) ---------- */
.chips-resumo { margin: 0 0 12px; }
.form-robo { gap: 0; }
.form-robo .cartao { display: flex; flex-direction: column; gap: 14px; }
.opcoes-modo { display: flex; flex-direction: column; gap: 10px; }
.opcao-modo { border: 1px solid var(--borda); border-radius: 10px; padding: 10px 12px; gap: 4px; }
.opcao-modo:has(input:checked) { border-color: var(--cor); background: var(--cor-clara); }
.lista-faq { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.faq-item { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--borda); }
.faq-item:first-child { border-top: 0; padding-top: 0; }
.faq-item .btn-link { align-self: flex-start; }
.teste-conversa { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.teste-bolha { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 12px; max-width: 90%; overflow-wrap: anywhere; white-space: pre-wrap; }
.teste-cliente { align-self: flex-start; background: var(--fundo); }
.teste-assistente { align-self: flex-end; background: var(--cor-clara); color: var(--cor-escura); }
.teste-quem { font-size: .75rem; font-weight: 700; }
.teste-assistente .dica { color: inherit; opacity: .8; }
/* conversa: mensagens e avisos do assistente virtual */
.bolha-robo { background: var(--info-fundo); border: 1px dashed var(--info); }
.bolha-robo .bolha-rodape span:first-child { font-weight: 700; }
.faixa-robo { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: var(--info-fundo); color: var(--info); border-radius: 10px; padding: 6px 12px; margin: 0 0 8px; font-size: .88rem; }
.faixa-robo .btn-link { color: inherit; font-weight: 700; text-decoration: underline; min-height: 36px; }
.cartao-robo { margin-top: 6px; background: var(--info-fundo); color: var(--info); border-radius: 10px; padding: 2px 10px; font-size: .85rem; }
.cartao-robo summary { color: inherit; min-height: 32px; padding: 6px 0; }
.cartao-robo-corpo { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; overflow-wrap: anywhere; }
/* painel de uso do assistente */
.lista-sugestoes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sugestao { padding: 10px 0; border-top: 1px solid var(--borda); }
.sugestao:first-child { border-top: 0; }
.sugestao-topo { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.sugestao-topo a { font-weight: 600; color: var(--cor-texto); }
.sugestao-texto { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--info-fundo); border-radius: 8px; padding: 6px 10px; }

/* Campo de senha com o olhinho (mostrar/esconder) */
.campo-com-olho { position: relative; display: block; }
.campo-com-olho input { width: 100%; padding-right: 44px; box-sizing: border-box; }
.btn-olho {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1; border-radius: 6px;
}
.btn-olho:focus-visible { outline: 2px solid currentColor; }

/* ---------- responder citando uma mensagem ---------- */
/* Botão do menu da mensagem (⌄): no computador aparece ao passar o mouse ou com o teclado; no celular fica sempre visível. */
.bolha { padding-right: 26px; }
/* foto/vídeo: o botão fica por cima do canto da mídia (como no WhatsApp), sem margem extra */
.bolha-midia { padding-right: 4px; }
.bolha-menu-btn {
  position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: inherit; color: var(--suave); cursor: pointer;
  font: inherit; font-size: 1rem; line-height: 1;
}
.bolha-menu-btn:hover, .bolha-menu-btn:focus-visible, .bolha-menu-btn[aria-expanded="true"] { color: var(--texto); background: var(--hover); }
.bolha-menu-btn:focus-visible { outline: 2px solid var(--cor); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) {
  .bolha-menu-btn { opacity: 0; }
  .bolha:hover .bolha-menu-btn, .bolha-menu-btn:focus-visible, .bolha-menu-btn[aria-expanded="true"] { opacity: 1; }
}
/* No toque a área de toque fica maior (o ícone continua pequeno). */
@media (pointer: coarse) {
  .bolha-menu-btn::after { content: ''; position: absolute; inset: -10px; }
}
.bolha-citacao {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; margin: 0 0 4px; padding: 4px 8px;
  background: rgba(127,127,127,.12); border: 0; border-left: 3px solid var(--cor); border-radius: 6px;
  font: inherit; font-size: .8rem; text-align: left; color: var(--texto); cursor: pointer;
}
.bolha-citacao.citacao-saida { border-left-color: var(--info); }
.bolha-citacao strong { color: var(--cor-escura); font-size: .78rem; }
.bolha-citacao.citacao-saida strong { color: var(--info); }
.bolha-citacao span { color: var(--suave); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bolha-destaque { outline: 2px solid var(--cor); outline-offset: 2px; }
.faixa-citacao {
  display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 6px 4px 6px 10px;
  background: var(--fundo); border-left: 3px solid var(--cor); border-radius: 8px;
}
.faixa-citacao[hidden] { display: none; }
.faixa-citacao-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .82rem; }
.faixa-citacao-texto .dica { margin: 0; font-size: .72rem; }
.faixa-citacao-trecho { color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- apagar conversa (confirmação na própria tela) ---------- */
.confirmar-apagar { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--erro-fundo); color: var(--texto); }
.confirmar-apagar[hidden] { display: none; }
.confirmar-apagar p { margin: 0 0 8px; font-size: .9rem; }
.confirmar-apagar .linha { flex-wrap: wrap; }
.btn-perigo { background: var(--erro); color: var(--fundo); }
.btn-perigo:hover { background: var(--erro); filter: brightness(.9); }
.etiqueta-apagada { background: var(--erro-fundo); color: var(--erro) !important; }
.faixa-apagada { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin: 0 0 8px; padding: 8px 10px; border-radius: 10px; background: var(--erro-fundo); color: var(--texto); font-size: .88rem; }
.faixa-apagada .btn { min-height: 40px; padding: 8px 14px; }

/* Reação, edição, "apagar para todos" e conteúdo que o painel não mostra (migração 0012) */
.bolha { position: relative; }
.bolha-com-reacao { margin-bottom: 14px; }
.bolha-reacoes { position: absolute; bottom: -13px; right: 8px; display: flex; gap: 2px; padding: 0 4px; border-radius: 10px;
  background: var(--bolha-entrada); box-shadow: 0 1px 2px rgba(11,20,26,.25); font-size: .8rem; line-height: 1.4; }
.bolha-entrada .bolha-reacoes { right: auto; left: 8px; }
.aviso-tipo { font-style: italic; color: var(--suave); }
.bolha-aviso .bolha-texto { font-size: .85rem; }
.bolha-editada { font-style: italic; }
.removida-original { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--suave); opacity: .8; }
.removida-original .dica { display: block; font-size: .7rem; }
.bolha-correcao { font-weight: 700; }

/* Avatar com cor por cliente (public/cor-avatar.js escolhe a classe). Letra escura no claro, clara no escuro. */
.avatar-c0 { background: #dbeafe; color: #1e3a8a; }
.avatar-c1 { background: #dcfce7; color: #14532d; }
.avatar-c2 { background: #fef3c7; color: #78350f; }
.avatar-c3 { background: #fce7f3; color: #831843; }
.avatar-c4 { background: #ede9fe; color: #4c1d95; }
.avatar-c5 { background: #ccfbf1; color: #134e4a; }
.avatar-c6 { background: #ffedd5; color: #7c2d12; }
.avatar-c7 { background: #e0e7ff; color: #312e81; }
@media (prefers-color-scheme: dark) {
  .avatar-c0 { background: #1e3a8a; color: #dbeafe; }
  .avatar-c1 { background: #14532d; color: #dcfce7; }
  .avatar-c2 { background: #78350f; color: #fef3c7; }
  .avatar-c3 { background: #831843; color: #fce7f3; }
  .avatar-c4 { background: #4c1d95; color: #ede9fe; }
  .avatar-c5 { background: #134e4a; color: #ccfbf1; }
  .avatar-c6 { background: #7c2d12; color: #ffedd5; }
  .avatar-c7 { background: #312e81; color: #e0e7ff; }
}

/* Vários arquivos na prévia do anexo */
.previa-lista { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; width: 100%; max-height: 38vh; overflow-y: auto; }
.previa-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
  padding: 4px; border: 1px solid var(--borda); border-radius: 8px; }
.previa-item img { width: 100%; height: 72px; object-fit: cover; border-radius: 6px; }
.previa-icone { height: 72px; display: flex; align-items: center; justify-content: center; color: var(--suave); }
.previa-item-nome { width: 100%; font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.previa-tirar { position: absolute; top: 2px; right: 2px; min-width: 32px; min-height: 32px; border-radius: 50%; background: var(--cartao); }

/* Horário de trabalho do vendedor (tela Equipe) */
.horario-vendedor { margin-top: 6px; }
.horario-vendedor summary { cursor: pointer; color: var(--suave); font-size: .85rem; }
.form-horario { display: grid; gap: 8px; margin-top: 8px; }
.grade-horario { display: grid; gap: 6px; }
.grade-horario[hidden] { display: none; }
.dia-horario { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.dia-horario > .chave { min-width: 64px; }
.faixa-horario { display: inline-flex; align-items: center; gap: 4px; }
.faixa-horario input[type="time"] { width: auto; min-width: 0; }

/* ---------- menu da mensagem (Responder, Encaminhar, Copiar, Apagar, Mais…) ---------- */
.menu-mensagem {
  position: fixed; z-index: 40; min-width: 200px; max-width: calc(100vw - 16px); padding: 6px 0;
  background: var(--painel); color: var(--texto); border: 1px solid var(--borda); border-radius: 10px;
  box-shadow: 0 4px 16px rgba(11,20,26,.25);
}
.menu-mensagem[hidden] { display: none; }
.menu-mensagem button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 16px;
  background: none; border: 0; font: inherit; font-size: .95rem; color: inherit; text-align: left; cursor: pointer;
}
.menu-mensagem button:hover, .menu-mensagem button:focus-visible { background: var(--hover); outline: none; }
.menu-mensagem svg { flex-shrink: 0; color: var(--suave); }
.menu-mensagem .menu-perigo { color: var(--erro); }
.menu-mensagem .menu-perigo svg { color: var(--erro); }
.menu-mensagem .menu-voltar { color: var(--suave); font-size: .85rem; min-height: 36px; border-bottom: 1px solid var(--borda); }

/* bolha encaminhada e bolha apagada do painel (só o gerente vê) */
.bolha-encaminhada { display: flex; align-items: center; gap: 4px; color: var(--suave); font-size: .75rem; font-style: italic; margin-bottom: 2px; }
.bolha-apagada-painel { opacity: .55; border: 1px dashed var(--suave); }
.bolha-apagada-por { font-weight: 700; color: var(--erro); }

/* diálogo (Apagar, Encaminhar, Reagir, Detalhes) */
.dialogo-fundo {
  position: fixed; inset: 0; z-index: 45; background: rgba(11,20,26,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.dialogo {
  width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--painel); color: var(--texto);
  border-radius: 14px; padding: 12px 16px 16px; box-shadow: 0 8px 28px rgba(0,0,0,.3);
}
.dialogo-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialogo-topo h2 { margin: 0; font-size: 1.05rem; }
.dialogo-corpo { display: flex; flex-direction: column; gap: 10px; }
.dialogo-corpo p { margin: 0; }
.dialogo-corpo .linha { flex-wrap: wrap; }
.dialogo-corpo .btn { min-height: 44px; }
.paleta-reacoes { display: flex; flex-wrap: wrap; gap: 6px; }
.paleta-reacoes button {
  width: 52px; height: 52px; font-size: 1.6rem; line-height: 1; border: 1px solid var(--borda); border-radius: 50%;
  background: none; cursor: pointer;
}
.paleta-reacoes button:hover, .paleta-reacoes button:focus-visible { background: var(--hover); }
.paleta-reacoes button[aria-pressed="true"] { border-color: var(--cor); background: var(--cor-clara); }
.detalhes-msg { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: .92rem; }
.detalhes-msg dt { color: var(--suave); }
.detalhes-msg dd { margin: 0; overflow-wrap: anywhere; }
.enc-lista { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; border: 1px solid var(--borda); border-radius: 10px; }
.enc-lista li + li { border-top: 1px solid var(--borda); }
.enc-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 52px; cursor: pointer; }
.enc-item:hover { background: var(--hover); }
.enc-item input { width: 20px; height: 20px; flex-shrink: 0; }
.enc-item-info { display: flex; flex-direction: column; min-width: 0; }
.enc-item-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.enc-item-info .dica { margin: 0; font-size: .78rem; }
.enc-fora { opacity: .55; cursor: default; }
.enc-vazio { padding: 12px; color: var(--suave); }

/* aviso rápido ("Copiado") */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: var(--texto); color: var(--fundo);
  font-size: .9rem; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.toast[hidden] { display: none; }
.toast-erro { background: var(--erro); }
