/* O Nexo em todas as páginas (14/09/2026): a barra ao lado das notificações.
   O desenho é o da barra do editor de sites (loja-editor.html, .trilho), com as cores do app: a linha
   de estado que troca desfocando, o sol que fica verde no fim, a luz que corre na borda enquanto o Nexo
   pensa e o histórico transparente que só abre pela porta. Tudo com o prefixo nxg-. */

/* a caixa no topo tem tamanho fixo e a barra flutua dentro dela: o recado que desdobra desce por cima
   da página e o topo não cresce */
.nxg { --nxg-curva: cubic-bezier(.22,.61,.36,1); --nxg-mv: .42s; position: relative; width: min(460px, 40vw); min-width: 240px; height: 38px; margin-right: 0.35rem; }
.nxg-abrigo { position: absolute; top: 0; left: 0; right: 0; z-index: 65; }

.nxg-barra { position: relative; width: 100%; padding: 1px; border: 1px solid var(--border-1); border-radius: 12px; overflow: hidden; background: var(--bg-1); transition: border-color var(--nxg-mv) var(--nxg-curva), box-shadow var(--nxg-mv) var(--nxg-curva); }
/* enquanto ele trabalha a borda some: quem desenha o contorno é a luz */
.nxg-barra.pensando, .nxg-barra.pronto, .nxg-barra.gravando { border-color: transparent; }
.nxg-barra.pensando { box-shadow: 0 0 20px -6px color-mix(in srgb, var(--primary) 55%, transparent); }
.nxg-barra.pronto { box-shadow: 0 0 22px -4px color-mix(in srgb, var(--accent-green) 50%, transparent); }
.nxg-estado { position: relative; z-index: 1; height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 4px 0 9px; border-radius: 11px; background: var(--bg-1); }

.nxg-sol { width: 20px; height: 20px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--bg-1); font: 800 11px/1 var(--font-sans); transition: transform var(--nxg-mv) cubic-bezier(.34,1.56,.64,1), background-color var(--nxg-mv) var(--nxg-curva); }
.nxg-sol.fim { background: var(--accent-green); transform: scale(1.14); }

/* a linha de estado: um texto de cada vez, trocando desfocado; o recado vem em linhas (b) */
.nxg-txt { flex: 1; min-width: 0; height: 18px; position: relative; overflow: hidden; padding: 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.nxg-txt span { position: absolute; inset: 0; display: block; line-height: 18px; font-weight: 600; font-size: 0.78rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nxg-txt span b { display: block; font-weight: inherit; overflow: hidden; text-overflow: ellipsis; }
.nxg-txt span b.ok { color: var(--accent-green); font-weight: 600; }
.nxg-txt span b.mal { color: var(--accent-red); font-weight: 600; }
.nxg-txt span b.item { position: relative; padding-left: 12px; font-weight: 500; }
.nxg-txt span b.item::before { content: ""; position: absolute; left: 1px; top: .6em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-green); }
.nxg-txt span b.mal.item { color: var(--text-2); }
.nxg-txt span b.mal.item::before { background: var(--accent-red); }
.nxg-txt span.entra { animation: nxgDesfoca .5s var(--nxg-curva) both; }
.nxg-txt span.sai { animation: nxgDesfocaSai .4s var(--nxg-curva) forwards; }
@keyframes nxgDesfoca { from { opacity: 0; filter: blur(7px); transform: scale(.97); } to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes nxgDesfocaSai { to { opacity: 0; filter: blur(7px); transform: scale(1.03); } }

/* o recado que não cabe numa linha desdobra a barra para baixo; escrevendo ou gravando, é uma linha só.
   A primeira linha fica na altura do sol e dos botões; passando do teto, o fim esmaece (o resto está no histórico) */
.nxg-barra.longo:not(.on):not(.gravando) { box-shadow: var(--shadow-lg); }
.nxg-barra.longo.pronto:not(.on):not(.gravando) { box-shadow: var(--shadow-lg), 0 0 22px -4px color-mix(in srgb, var(--accent-green) 50%, transparent); }
.nxg-barra.longo:not(.on):not(.gravando) .nxg-estado { height: auto; min-height: 34px; align-items: flex-start; padding-top: 3px; padding-bottom: 3px; }
.nxg-barra.longo:not(.on):not(.gravando) .nxg-sol { margin-top: 4px; }
.nxg-barra.longo:not(.on):not(.gravando) .nxg-txt { height: auto; max-height: 150px; margin: 5px 0; }
.nxg-barra.longo:not(.on):not(.gravando) .nxg-txt span:not(.sai) { position: relative; inset: auto; white-space: normal; overflow: visible; line-height: 1.5; font-weight: 500; color: var(--text-1); }
.nxg-barra.longo:not(.on):not(.gravando) .nxg-txt span b { overflow: visible; }
.nxg-barra.longo:not(.on):not(.gravando) .nxg-txt span b + b { margin-top: 3px; }
.nxg-barra.longo.cortado:not(.on):not(.gravando) .nxg-txt { -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent); }

/* o que a busca achou: uma lista dentro da própria barra, embaixo da linha de estado, e cada linha abre o
   item. Não some sozinha (é para escolher): sai num clique fora, no Esc, ao abrir um item ou num pedido novo */
.nxg-achados { display: none; position: relative; z-index: 1; flex-direction: column; gap: 1px; max-height: min(340px, 60vh); overflow-y: auto; overscroll-behavior: contain; padding: 0 5px 6px; background: var(--bg-1); border-radius: 0 0 11px 11px; }
.nxg-achados > * { flex-shrink: 0; }   /* lista que rola espreme os itens sem isto */
.nxg-barra.achou:not(.on):not(.gravando) { box-shadow: var(--shadow-lg); }
.nxg-barra.achou:not(.on):not(.gravando) .nxg-achados { display: flex; animation: nxgDesce var(--nxg-mv) var(--nxg-curva) both; }
.nxg-achado { display: grid; grid-template-columns: 76px minmax(0, 1fr); column-gap: 8px; row-gap: 1px; align-items: baseline; width: 100%; padding: 6px 7px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background-color .18s var(--nxg-curva); }
.nxg-achado:hover, .nxg-achado:focus-visible { background: color-mix(in srgb, var(--text-1) 7%, transparent); outline: none; }
.nxg-achado:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
.nxg-achado-tipo { grid-row: 1 / span 2; align-self: start; justify-self: start; margin-top: 1px; padding: 2px 6px; border-radius: 5px; background: color-mix(in srgb, var(--primary) 13%, transparent); color: var(--primary); font-size: 0.64rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.nxg-achado-t { min-width: 0; font-size: 0.8rem; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nxg-achado-d { grid-column: 2; min-width: 0; font-size: 0.72rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.nxg-achados-cab { padding: 8px 7px 3px; font-size: 0.68rem; font-weight: 700; letter-spacing: .03em; color: var(--text-3); }
.nxg-achados-mais { padding: 6px 7px 2px; font-size: 0.72rem; line-height: 1.4; color: var(--text-3); }

/* o campo e o estado dividem a mesma linha, um de cada vez */
.nxg-campo, .nxg-enviar { display: none; }
.nxg-barra.on .nxg-campo { display: block; animation: nxgEntraCampo var(--nxg-mv) var(--nxg-curva) both; }
.nxg-barra.on .nxg-enviar { display: grid; animation: nxgEntraCampo var(--nxg-mv) var(--nxg-curva) both; }
.nxg-barra.on .nxg-txt { display: none; }
@keyframes nxgEntraCampo { from { opacity: 0; transform: translateX(6px); } to { opacity: 1; transform: none; } }
.nxg-campo { flex: 1; min-width: 0; height: 20px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text-1); font-size: 0.82rem; }
.nxg-campo::placeholder { color: var(--text-4); }
.nxg-enviar { flex: 0 0 auto; width: 26px; height: 26px; place-items: center; padding: 0; border: 0; border-radius: 8px; background: var(--primary); color: var(--bg-1); cursor: pointer; }
.nxg-falar, .nxg-porta { position: relative; flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-4); cursor: pointer; transition: color var(--nxg-mv) var(--nxg-curva), background-color var(--nxg-mv) var(--nxg-curva); }
.nxg-falar:hover, .nxg-porta:hover { color: var(--text-1); background: color-mix(in srgb, var(--text-1) 8%, transparent); }
.nxg-porta svg { transition: transform var(--nxg-mv) var(--nxg-curva); }
.nxg-abrigo.aberto .nxg-porta { color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); }
.nxg-abrigo.aberto .nxg-porta svg { transform: rotate(-25deg); }
.nxg-porta.novo::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* a luz que corre na borda é um disco girando atrás, recortado pelo canto arredondado */
.nxg-aura { position: absolute; inset: -70%; z-index: 0; opacity: 0; pointer-events: none; background: conic-gradient(from 0deg, transparent 0 60%, var(--primary) 78%, transparent 94%); }
.nxg-barra.pensando .nxg-aura { animation: nxgVolta 1.5s linear infinite, nxgAcende .35s var(--nxg-curva) both; }
.nxg-barra.pronto .nxg-aura { animation: nxgAcende .3s var(--nxg-curva) both; background: conic-gradient(from 0deg, transparent 0 40%, var(--accent-green) 70%, transparent 100%); }
@keyframes nxgVolta { to { transform: rotate(360deg); } }
@keyframes nxgAcende { from { opacity: 0; } to { opacity: .95; } }

/* gravando: a linha vira o cancelar, o tempo e o nível do microfone; a luz fica vermelha */
.nxg-gravacao { display: none; flex: 1; min-width: 0; align-items: center; gap: 8px; }
.nxg-barra.gravando .nxg-gravacao { display: flex; }
.nxg-barra.gravando .nxg-sol, .nxg-barra.gravando .nxg-txt, .nxg-barra.gravando .nxg-campo, .nxg-barra.gravando .nxg-falar, .nxg-barra.gravando .nxg-porta { display: none; }
.nxg-barra.gravando .nxg-enviar { display: grid; }
.nxg-barra.gravando .nxg-aura { opacity: .9; background: conic-gradient(from 0deg, transparent 0 60%, var(--accent-red) 80%, transparent 96%); animation: nxgVolta 2.2s linear infinite; }
.nxg-cancela { width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; }
.nxg-cancela:hover { color: var(--accent-red); background: var(--bg-2); }
.nxg-rec { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--accent-red); animation: nxgPisca 1.2s ease-in-out infinite; }
@keyframes nxgPisca { 50% { opacity: .35; } }
.nxg-tempo { min-width: 30px; font-size: 0.76rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.nxg-niveis { display: flex; align-items: center; gap: 3px; height: 20px; flex-shrink: 0; }
.nxg-niveis i { width: 3px; height: 100%; border-radius: 2px; background: var(--text-3); transform: scaleY(.18); transition: transform .09s linear; }
.nxg-barra.ouvindo-navegador .nxg-niveis i { animation: nxgBarra 1s ease-in-out infinite; }
.nxg-barra.ouvindo-navegador .nxg-niveis i:nth-child(odd) { animation-delay: .25s; }
.nxg-barra.ouvindo-navegador .nxg-niveis i:nth-child(3n) { animation-delay: .5s; }
@keyframes nxgBarra { 0%, 100% { transform: scaleY(.2); } 50% { transform: scaleY(.85); } }
.nxg-ouvido { flex: 1; min-width: 0; font-size: 0.76rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* o histórico: vidro fantasma, descendo da barra, e só quando a porta é apertada */
.nxg-hist { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: min(440px, 92vw); max-height: min(420px, 62vh); display: none; flex-direction: column; gap: 6px; overflow-y: auto; overscroll-behavior: contain; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg-1) 90%, transparent); border: 1px solid color-mix(in srgb, var(--text-1) 10%, transparent); box-shadow: var(--shadow-lg); }
@supports (backdrop-filter: blur(2px)) { .nxg-hist { backdrop-filter: blur(12px); } }
.nxg-abrigo.aberto .nxg-hist { display: flex; animation: nxgDesce var(--nxg-mv) var(--nxg-curva) both; }
@keyframes nxgDesce { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.nxg-vez { display: flex; gap: 8px; align-items: flex-start; font-size: 0.78rem; line-height: 1.45; animation: nxgDesce var(--nxg-mv) var(--nxg-curva) both; }
.nxg-vez i { flex: 0 0 auto; width: 5px; height: 5px; margin-top: 7px; border-radius: 50%; background: var(--primary); }
.nxg-vez.feito i { background: var(--accent-green); }
.nxg-vez.mal i { background: var(--accent-red); }
.nxg-vez.achado i { background: var(--text-4); }
.nxg-vez p { flex: 1; min-width: 0; margin: 0; color: var(--text-1); white-space: pre-wrap; word-break: break-word; }
.nxg-vez.mal p { color: var(--text-3); }
.nxg-vez.eu { justify-content: flex-end; }
.nxg-vez.eu p { flex: 0 1 auto; max-width: 86%; padding: 5px 10px; border-radius: 10px 10px 3px 10px; background: var(--primary); color: var(--bg-1); font-weight: 600; }
.nxg-vez.eu i { display: none; }
.nxg-vazio { padding: 6px 2px; font-size: 0.78rem; line-height: 1.5; color: var(--text-3); }
.nxg-limpa { align-self: center; margin-top: 2px; padding: 4px 8px; border: 0; background: transparent; color: var(--text-4); font-size: 0.72rem; cursor: pointer; }
.nxg-limpa:hover { color: var(--text-1); }

@media (max-width: 768px) {
  /* no celular a barra ocupa o meio do topo (a caixa de busca saiu); ao abrir, gravar, pensar, dar um recado
     ou mostrar o que achou, ela desce e ganha a largura da tela */
  .nxg { flex: 1 1 auto; width: auto; min-width: 0; margin-right: 0.15rem; }
  .nxg:not(.ativo) .nxg-falar { display: none; }
  .nxg.ativo .nxg-abrigo { position: fixed; left: 10px; right: 10px; top: calc(62px + env(safe-area-inset-top, 0px)); z-index: 70; }
  .nxg.ativo .nxg-barra { box-shadow: var(--shadow-lg); }
  .nxg-hist { position: fixed; left: 10px; right: 10px; top: calc(62px + env(safe-area-inset-top, 0px)); width: auto; }
  .nxg.ativo .nxg-hist { top: calc(112px + env(safe-area-inset-top, 0px)); }
}
@media (max-width: 345px) {
  /* celular estreito: recolhida, a barrinha diz só "Nexo" (o "pronto para ajudar" não cabe e virava "pronto p…") */
  .nxg:not(.ativo) .nxg-txt span.parado { font-size: 0; }
  .nxg:not(.ativo) .nxg-txt span.parado::after { content: "Nexo"; font-size: 0.78rem; }
}
@media (prefers-reduced-motion: reduce) {
  .nxg *, .nxg *::before, .nxg *::after { animation: none !important; transition: none !important; }
}
