/* =====================================================================
   Movimento do sistema: toque sem o "flash" azul do Android e animações
   discretas, rápidas e com a mesma curva em tudo (estilo app nativo).
   Base (todas as páginas) + extras do painel (body.painel).
   ===================================================================== */
:root {
  --ease-saida: cubic-bezier(.22, 1, .36, 1);     /* desacelera no fim: entradas */
  --ease-entrada: cubic-bezier(.55, 0, 1, .45);   /* acelera: saídas */
  --ease-mola: cubic-bezier(.34, 1.4, .64, 1);    /* leve "assentada" no fim */
}

/* ---------- Toque (todas as páginas) ---------- */
* { -webkit-tap-highlight-color: transparent; }
button, a, label, summary, select, [role="button"], [role="switch"], .chave, .sair {
  touch-action: manipulation;           /* sem a espera do toque duplo */
  -webkit-user-select: none; user-select: none;
}
/* Contorno só para quem navega pelo teclado, nunca no toque */
:focus:not(:focus-visible) { outline: none; }

/* ---------- Painel ---------- */
body.painel button, body.painel .sair, body.painel .vb, body.painel .cab nav a, body.painel .cab nav button {
  transition: transform .18s var(--ease-saida), background-color .2s, border-color .2s, opacity .2s, box-shadow .25s;
}
body.painel button:not(:disabled):active, body.painel .sair:active, body.painel .vb:active,
body.painel .cab nav a:active, body.painel label.vb:active {
  transform: scale(.96);
  transition-duration: .08s;
}
body.painel button:disabled { transition: opacity .2s; }

/* Entrada da página: topo desce, conteúdo sobe (uma vez) */
body.painel .cab { animation: mv-desce .5s var(--ease-saida) both; }
body.painel #painel, body.painel section#painel, body.painel main, body.painel .tela-cheia {
  animation: mv-sobe .55s .06s var(--ease-saida) both;
}
@keyframes mv-desce { from { opacity: 0; transform: translateY(-10px); } }
@keyframes mv-sobe { from { opacity: 0; transform: translateY(14px); } }
@keyframes mv-aparece { from { opacity: 0; } }

/* Cartões (pedidos, pratos, placas): entram em cascata */
.mv-entra { animation: mv-cartao .5s var(--ease-saida) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes mv-cartao { from { opacity: 0; transform: translateY(12px) scale(.985); } }
/* Pedido que acabou de chegar: entra e brilha duas vezes em vermelho */
.mv-chegou { animation: mv-cartao .55s var(--ease-mola) both, mv-brilho 1.6s .2s ease-out 2; }
@keyframes mv-brilho {
  0% { box-shadow: 0 0 0 0 rgba(224, 36, 45, .55); }
  70% { box-shadow: 0 0 0 14px rgba(224, 36, 45, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 36, 45, 0); }
}

/* Janelas: abrem crescendo de leve, fecham encolhendo (o fechar é ligado em movimento.js) */
body.painel dialog[open] { animation: mv-janela-abre .32s var(--ease-saida); }
body.painel dialog[open]::backdrop { animation: mv-aparece .3s ease; }
body.painel dialog.mv-fechando { animation: mv-janela-fecha .17s var(--ease-entrada) forwards; }
body.painel dialog.mv-fechando::backdrop { animation: mv-some .17s ease forwards; }
@keyframes mv-janela-abre { from { opacity: 0; transform: translateY(10px) scale(.965); } }
@keyframes mv-janela-fecha { to { opacity: 0; transform: translateY(6px) scale(.975); } }
@keyframes mv-some { to { opacity: 0; } }

/* Avisos e alertas deslizam para dentro */
body.painel .alerta-agente:not([hidden]), body.painel .pendentes-equipe:not([hidden]), body.painel .ativar-som:not([hidden]) {
  animation: mv-sobe .4s var(--ease-saida) both;
}
body.painel .aviso { animation: mv-toast .35s var(--ease-mola) both; }
@keyframes mv-toast { from { opacity: 0; transform: translate(-50%, 16px) scale(.96); } }

/* Indicador "conectado" respira devagar */
body.painel .status-imp.ok i { animation: mv-respira 2.4s ease-in-out infinite; }
@keyframes mv-respira { 50% { box-shadow: 0 0 0 5px rgba(52, 199, 89, .15); } }
body.painel .status-imp span { transition: color .2s; }

/* Campos: foco suave */
body.painel input, body.painel select, body.painel textarea { transition: border-color .2s, box-shadow .25s, background-color .2s; }

/* Interruptores e caixas de seleção acompanham a mesma curva */
body.painel .chave::after { transition: transform .28s var(--ease-mola); }
body.painel .chave { transition: background-color .25s; }

/* Quem pediu menos movimento no aparelho: sem animações */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Financeiro: blocos em cascata, colunas crescem do chão, barras correm da esquerda */
body.painel .kpis > .bloco, body.painel .kpis-2 > .bloco, body.painel section > .bloco { animation: mv-cartao .5s var(--ease-saida) both; }
body.painel .kpis > .bloco:nth-child(2), body.painel .kpis-2 > .bloco:nth-child(2) { animation-delay: .04s; }
body.painel .kpis > .bloco:nth-child(3), body.painel .kpis-2 > .bloco:nth-child(3) { animation-delay: .08s; }
body.painel .kpis > .bloco:nth-child(4), body.painel .kpis-2 > .bloco:nth-child(4) { animation-delay: .12s; }
body.painel .grafico .barra { transform-box: fill-box; transform-origin: 50% 100%; animation: mv-coluna .7s var(--ease-saida) both; }
body.painel .lista-barras .trilho i { transform-origin: 0 50%; animation: mv-trilho .8s var(--ease-saida) both; }
@keyframes mv-coluna { from { transform: scaleY(0); } }
@keyframes mv-trilho { from { transform: scaleX(0); } }

@media print { *, *::before, *::after { animation: none !important; transition: none !important; } }
