/* ══════════════════════════════════════════════════════════════════════════
   OS AVISOS DO VECTRA: o aviso rápido e o diálogo, no mesmo vidro (11/10/2026)

   *"Vamos ajeitar essas mensagens padrão de erro, sucesso e afins, que
   destoam bastante do resto do app"* (Marcos). Eram três famílias: o flash
   pastel do servidor, o diálogo branco chapado e oito toasts próprios.

   ⚠️⚠️ ESTE ARQUIVO É DAS TRÊS CAMADAS (app, hub e portal do cliente). O hub e
   o portal não carregam o `app.css`, então nada aqui depende de token de lá:
   todo token é `--av-*` e nasce na própria peça.
   · quem desenha o aviso é `static/js/avisos.js` (`Vectra.aviso`);
   · quem desenha o diálogo é `static/js/vectra_dialogs.js` (`vAlert`,
     `vConfirm`, `vPrompt`), que não injeta mais CSS nenhum;
   · o flash do servidor sai de `partials/flash.html` e é ABSORVIDO pelo
     `avisos.js`. Sem JavaScript ele aparece assim mesmo, na reserva do fim
     deste arquivo: aviso alto é recuperável, aviso calado não.
   `tests/test_avisos_em_toda_camada.py` cobra os três `<link>` e os scripts.
   ══════════════════════════════════════════════════════════════════════════ */

@property --av-mx { syntax: '<length-percentage>'; inherits: true; initial-value: 18%; }
@property --av-my { syntax: '<length-percentage>'; inherits: true; initial-value: 30%; }
@property --av-giro { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

/* ───────────── o vidro: a peça que aviso e diálogo dividem ───────────── */
.av-vidro {
  --av-fundo: rgba(11, 19, 28, .72);
  --av-borda: rgba(255, 255, 255, .13);
  --av-ink: #fff;
  --av-ink2: rgba(255, 255, 255, .8);
  --av-brilho: rgba(255, 255, 255, .7);
  --av-botao: rgba(255, 255, 255, .11);
  --av-botao-h: rgba(255, 255, 255, .22);
  --av-campo: rgba(255, 255, 255, .09);
  --av-success: #7fe0a0;
  --av-danger: #ff7d8c;
  --av-warning: #ffc25c;
  --av-info: #4fd3d9;
  --av-tint: var(--av-info);
  --av-grad: linear-gradient(118deg, #8fcb3a 0%, #8fcb3a 42%, #5cbf7e 64%, #16b1b3 92%, #11adb4 100%);
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  color: var(--av-ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--av-fundo);
  -webkit-backdrop-filter: blur(24px) saturate(175%);
  backdrop-filter: blur(24px) saturate(175%);
  border: 1px solid var(--av-borda);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 22px 46px -16px rgba(5, 14, 24, .6);
}
/* a luz na cor do aviso: segue o ponteiro; sem ponteiro, passeia sozinha */
.av-vidro::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1; pointer-events: none;
  background: radial-gradient(260px circle at var(--av-mx) var(--av-my), color-mix(in srgb, var(--av-tint) 34%, transparent), transparent 70%);
}
/* o fio de luz na borda */
.av-vidro::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: radial-gradient(200px circle at var(--av-mx) var(--av-my), var(--av-brilho), transparent 65%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; opacity: .8;
}
html:not(.av-ponteiro) .av-vidro { animation: av-passeio 7s ease-in-out infinite alternate; }
@keyframes av-passeio { from { --av-mx: 6%; --av-my: 10%; } to { --av-mx: 94%; --av-my: 90%; } }
/* sem desfoque de fundo o vidro vira chapa escura: o texto continua legível */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .av-vidro { --av-fundo: #16212d; }
}

/* ───────────── o aviso rápido ───────────── */
/* Acima de todo modal da casa (o drill é 9990, o Suporte 10040, o carregador
   de navegação 100001) e abaixo do diálogo (100050): quem pergunta ganha. */
.av-pilha {
  position: fixed; z-index: 100040;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column;
  pointer-events: none;            /* o toque passa; só o aviso o pega */
}
@media (min-width: 601px) {
  .av-pilha { top: calc(16px + env(safe-area-inset-top, 0px)); left: auto; right: 16px; width: min(420px, calc(100vw - 32px)); }
}
.av-caixa { margin-bottom: 10px; transition: height .32s cubic-bezier(.3, .8, .3, 1), margin .32s; }
.av {
  pointer-events: auto;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 13px 12px 14px 14px; border-radius: 18px; overflow: hidden;
  font-size: 14px; line-height: 1.4; text-align: left;
  animation: av-entra .5s cubic-bezier(.2, 1.25, .35, 1) both;
  transition: opacity .25s, transform .25s, filter .25s;
}
.av.av-sai { opacity: 0; transform: scale(.94); filter: blur(4px); }
@keyframes av-entra {
  from { opacity: 0; transform: translateY(-16px) scale(.94); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes av-esmaece { from { opacity: 0; } to { opacity: 1; } }
.av-success { --av-tint: var(--av-success); }
.av-danger { --av-tint: var(--av-danger); }
.av-warning { --av-tint: var(--av-warning); }
.av-info, .av-loading { --av-tint: var(--av-info); }

.av-ico {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--av-tint);
  background: color-mix(in srgb, var(--av-tint) 18%, transparent);
  box-shadow: 0 0 22px -4px color-mix(in srgb, var(--av-tint) 70%, transparent), inset 0 0 0 1px color-mix(in srgb, var(--av-tint) 34%, transparent);
}
.av-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.av-ico .av-traco { stroke-dasharray: 30; stroke-dashoffset: 30; animation: av-desenha .45s .18s ease-out forwards; }
@keyframes av-desenha { to { stroke-dashoffset: 0; } }
.av-danger .av-ico { animation: av-treme .4s .1s; }
@keyframes av-treme { 20% { transform: translateX(-3px); } 45% { transform: translateX(3px); } 70% { transform: translateX(-2px); } }
/* o escudo que espera: três <svg> empilhados, um por faceta, só opacidade
   (a régua do carregador de 01/10: pedaço de SVG animado trava no iPhone) */
.av-escudo { position: relative; display: block; width: 22px; aspect-ratio: 613 / 589; }
.av-escudo svg { position: absolute; inset: 0; width: 100%; height: 100%; stroke: none; animation: av-faceta 1.2s ease-in-out infinite; will-change: opacity; }
.av-ico .av-escudo svg { fill: none; stroke: none; stroke-width: 0; }
.av-escudo svg:nth-child(2) { animation-delay: .2s; }
.av-escudo svg:nth-child(3) { animation-delay: .4s; }
@keyframes av-faceta { 0%, 100% { opacity: .3; } 40% { opacity: 1; } }
/* no emblema do diálogo o escudo respira devagar: ele não está esperando nada */
.av-escudo-suave svg { animation: av-respira 2.8s ease-in-out infinite; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .35)); }
.av-escudo-suave svg:nth-child(2) { animation-delay: .35s; }
.av-escudo-suave svg:nth-child(3) { animation-delay: .7s; }
@keyframes av-respira { 0%, 100% { opacity: .72; } 45% { opacity: 1; } }

.av-txt { min-width: 0; display: grid; gap: 1px; padding-top: 1px; }
.av-txt strong { font-size: 14.5px; font-weight: 700; letter-spacing: -.005em; color: var(--av-ink); }
.av-msg { font-size: 14px; font-weight: 500; color: var(--av-ink2); overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; white-space: pre-line; }
.av-msg a { color: var(--av-ink); text-decoration: underline; }
.av-acao {
  justify-self: start; margin-top: 8px; border: 0; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
  min-height: 32px; padding: 6px 13px; border-radius: 99px; color: var(--av-ink); background: var(--av-botao);
}
.av-acao:hover { background: var(--av-botao-h); }
.av-bts { display: flex; gap: 4px; }
.av-bt {
  width: 30px; height: 30px; padding: 0; border-radius: 10px; border: 0; cursor: pointer; display: grid; place-items: center;
  color: var(--av-ink2); background: transparent;
}
.av-bt:hover { background: var(--av-botao-h); color: var(--av-ink); }
.av-bt svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.av-bt.av-copiado { color: var(--av-success); }
.av-bt:focus-visible, .av-acao:focus-visible { outline: 2px solid #4fd3d9; outline-offset: 2px; }
@media (pointer: coarse) { .av-bt { width: 40px; height: 40px; } .av-acao { min-height: 40px; } }
/* a linha do tempo dos que somem sozinhos; para com o ponteiro em cima */
.av-tempo {
  position: absolute; left: 14px; right: 14px; bottom: 6px; height: 2px; border-radius: 2px; transform-origin: left;
  background: var(--av-tint); opacity: .75; animation: av-tempo var(--av-dura, 5s) linear forwards;
}
.av.av-pausa .av-tempo { animation-play-state: paused; }
@keyframes av-tempo { to { transform: scaleX(0); } }

/* ───────────── o diálogo (vAlert, vConfirm, vPrompt) ───────────── */
.vdlg-overlay {
  position: fixed; inset: 0; z-index: 100050; display: flex; align-items: center; justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px))
           calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  touch-action: manipulation; overscroll-behavior: contain;
}
.vdlg-overlay[hidden] { display: none !important; }
.vdlg-backdrop {
  position: absolute; inset: 0; background: rgba(8, 14, 20, .4);
  -webkit-backdrop-filter: blur(9px) saturate(130%); backdrop-filter: blur(9px) saturate(130%);
  animation: av-esmaece .25s both;
}
.vdlg-card {
  width: min(400px, 100%); max-height: 100%; overflow-y: auto; border-radius: 24px; padding: 24px 22px 20px;
  text-align: center; display: grid; gap: 6px; justify-items: center;
  animation: vdlg-entra .42s cubic-bezier(.2, 1.2, .35, 1) both;
}
.vdlg-card.tom-danger { --av-tint: var(--av-danger); }
@keyframes vdlg-entra {
  from { opacity: 0; transform: translateY(18px) scale(.94); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}
.vdlg-ico {
  position: relative; width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; margin-bottom: 6px;
  background: color-mix(in srgb, var(--av-tint) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--av-tint) 34%, transparent);
}
.vdlg-ico::before {
  content: ""; position: absolute; inset: -10px; border-radius: 28px; z-index: -1; filter: blur(14px); opacity: .55;
  background: conic-gradient(from var(--av-giro, 0deg), var(--av-tint), transparent 40%, var(--av-tint) 70%, transparent);
  animation: vdlg-gira 6s linear infinite;
}
@keyframes vdlg-gira { to { --av-giro: 360deg; } }
.vdlg-ico > svg { width: 32px; height: 32px; }
.vdlg-ico .av-escudo { width: 34px; }
.vdlg-title { margin: 0; font-size: 17.5px; font-weight: 700; letter-spacing: -.01em; color: var(--av-ink); text-wrap: balance; }
.vdlg-msg { margin: 0 0 12px; font-size: 14.5px; line-height: 1.45; color: var(--av-ink2); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 36ch; }
.vdlg-input {
  width: 100%; box-sizing: border-box; height: 46px; border-radius: 14px; border: 1px solid var(--av-borda);
  background: var(--av-campo); color: var(--av-ink); padding: 0 14px; font: inherit; font-size: 16px; margin: 0 0 12px;
}
.vdlg-input[hidden] { display: none !important; }
.vdlg-input::placeholder { color: var(--av-ink2); }
.vdlg-actions { display: flex; flex-direction: column-reverse; gap: 10px; width: 100%; }
@media (min-width: 481px) { .vdlg-actions { flex-direction: row; } }
.vdlg-btn { flex: 1; min-height: 46px; padding: 0 14px; border-radius: 14px; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 14.5px; }
.vdlg-cancel { background: var(--av-botao); color: var(--av-ink); }
.vdlg-cancel:hover { background: var(--av-botao-h); }
.vdlg-cancel[hidden] { display: none !important; }
.vdlg-ok { color: #fff; background: var(--av-grad); box-shadow: 0 10px 22px -10px rgba(17, 173, 180, .9); }
.vdlg-ok.danger { background: linear-gradient(118deg, #f0596a, #d43f55); box-shadow: 0 10px 22px -10px rgba(212, 63, 85, .9); }
.vdlg-input:focus-visible, .vdlg-btn:focus-visible { outline: 2px solid #4fd3d9; outline-offset: 2px; }

/* ───────────── reduzir movimento: a cor e o esmaecer ficam, o que translada sai ─────────────
   ⚠️ Este bloco vem DEPOIS de tudo o que ele desliga: media query não soma
   especificidade, e a regra de baixo é a que ganha. */
@media (prefers-reduced-motion: reduce) {
  .av, .vdlg-card { animation-name: av-esmaece; animation-duration: .25s; }
  .av.av-sai { transform: none; filter: none; }
  .av-danger .av-ico { animation: none; }
  html:not(.av-ponteiro) .av-vidro { animation: none; }
  .vdlg-ico::before { animation: none; }
  .av-escudo svg { animation-duration: 2.4s; }
  .av-escudo-suave svg { animation-duration: 4.5s; }
}

/* ───────────── a reserva: o flash do servidor sem JavaScript ─────────────
   Com o `avisos.js` de pé (`html.av-js`), a pilha crua some e cada mensagem
   vira um aviso de vidro. Sem ele, é isto que aparece.
   ⚠️ O DEFAULT DO `.flash` É O DE ERRO, de propósito (01/09/2026): categoria
   sem regra tem que aparecer ALTO. `test_flash_categorias.py` cobra. */
/* ⚠️ Só a pilha do SERVIDOR some (`data-av-servidor`): pilha montada à mão por
   uma tela continua aparecendo, senão um erro viraria silêncio. */
html.av-js .flash-stack[data-av-servidor] { display: none !important; }
.flash-stack {
  position: fixed; z-index: 100040;
  top: calc(8px + env(safe-area-inset-top, 0px)); right: 8px; left: 8px;
  display: grid; gap: 10px; pointer-events: none;
}
@media (min-width: 601px) { .flash-stack { top: calc(16px + env(safe-area-inset-top, 0px)); left: auto; right: 16px; max-width: min(440px, calc(100vw - 32px)); } }
.flash {
  pointer-events: auto; display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 8px;
  padding: 12px 14px; border-radius: 12px; font-weight: 600; line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .06);
  border: 1px solid #fbc8d0; background: #ffedf0; color: #b12f48;
  transition: opacity .3s ease;
}
.flash.hide { opacity: 0; }
.flash-msg { user-select: text; overflow-wrap: anywhere; }
.flash-btn { appearance: none; border: 0; background: rgba(0, 0, 0, .06); color: inherit; font-size: 18px; font-weight: 700; cursor: pointer; padding: 0 8px; border-radius: 8px; line-height: 1.2; }
.flash-error   { background: #ffedf0; color: #b12f48; border-color: #fbc8d0; }
.flash-success { background: #ecfbf3; color: #0f8b58; border-color: #bfeccc; }
.flash-danger  { background: #ffedf0; color: #b12f48; border-color: #fbc8d0; }
.flash-warning { background: #fff7e9; color: #915f0b; border-color: #fde2bf; }
.flash-info    { background: #edf8fb; color: #0d7180; border-color: #bfe1ea; }
