/* RIB Administrativo — animações e ajustes de celular */

/* ============ Transição entre páginas ============ */
.conteudo.preparando { position: absolute; visibility: hidden; pointer-events: none; }
.conteudo.saindo { animation: vt-sai .16s cubic-bezier(.4,0,.2,1) both; }
.conteudo.entrando { animation: vt-entra .55s cubic-bezier(.16,1,.3,1) backwards; }
@keyframes vt-sai { to { opacity: 0; transform: scale(.985) translateY(-6px); filter: blur(3px); } }
@keyframes vt-entra {
  from { opacity: 0; clip-path: inset(0 0 22% 0 round 18px); transform: translateY(22px); filter: blur(5px); }
  to { opacity: 1; clip-path: inset(0 0 0 0 round 0); transform: none; filter: none; }
}

/* Troca de tema: círculo que se expande a partir do botão */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: vt-tema .7s cubic-bezier(.65,0,.35,1) both; }
@keyframes vt-tema { from { clip-path: circle(0 at var(--tx, 90%) var(--ty, 30px)); } to { clip-path: circle(var(--tr, 150vmax) at var(--tx, 90%) var(--ty, 30px)); } }

/* ============ Entrada em cascata dos elementos (dobra 3D) ============ */
.cascata > * , .cascata-filhos > * > * {
  animation: dobra .6s cubic-bezier(.16,1,.3,1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
  transform-origin: 50% 0;
}
@keyframes dobra { from { opacity: 0; transform: perspective(700px) rotateX(-22deg) translateY(14px); } to { opacity: 1; transform: none; } }
table.tab tbody tr.surge { animation: linha .5s cubic-bezier(.16,1,.3,1) backwards; animation-delay: calc(var(--i, 0) * 22ms); }
@keyframes linha { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }

/* ============ Toque nos botões: anel que se expande ============ */
.onda { position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); opacity: .45;
  background: radial-gradient(circle, currentColor 0 30%, transparent 70%); animation: onda .6s cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes onda { to { transform: scale(2.6); opacity: 0; } }
.btn, .pn-btn, .lateral a, .nav-baixo a, .abas button, .filtro-chips button { position: relative; overflow: hidden; }
.btn:active, .nav-baixo a:active { transform: scale(.97); }

/* ============ Abas com indicador deslizante ============ */
.abas { position: relative; scrollbar-width: none; }
.abas::-webkit-scrollbar { display: none; }
.abas button { border-bottom-color: transparent !important; transition: color .2s; }
.abas .indicador { position: absolute; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--pri);
  transition: left .35s cubic-bezier(.16,1,.3,1), width .35s cubic-bezier(.16,1,.3,1); }

/* ============ Carregamento: esqueleto com brilho ============ */
.esqueleto { display: flex; flex-direction: column; gap: 14px; }
.esqueleto .linha-e { height: 16px; border-radius: 8px; }
.esqueleto .bloco-e { height: 110px; border-radius: 16px; }
.esqueleto .grade-e { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.esqueleto .linha-e, .esqueleto .bloco-e {
  background: linear-gradient(100deg, var(--cinza-bg) 30%, color-mix(in srgb, var(--cinza-bg) 40%, var(--sup)) 50%, var(--cinza-bg) 70%);
  background-size: 300% 100%; animation: brilho 1.3s ease-in-out infinite;
}
@keyframes brilho { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ============ Avisos (toasts) com barra de tempo ============ */
.toast { position: relative; overflow: hidden; animation: toast-entra .5s cubic-bezier(.16,1,.3,1) both; }
.toast .tempo { position: absolute; left: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.55); animation: toast-tempo linear forwards; }
@keyframes toast-entra { from { opacity: 0; transform: translateY(18px) scale(.9); } 60% { transform: translateY(-3px) scale(1.02); } to { opacity: 1; transform: none; } }
@keyframes toast-tempo { from { width: 100%; } to { width: 0; } }
.toast.saindo { animation: toast-sai .3s ease forwards; }
@keyframes toast-sai { to { opacity: 0; transform: translateX(30px) scale(.95); } }

/* ============ Etiquetas que mudam: pequeno salto ============ */
.pulo { animation: pulo .45s cubic-bezier(.34,1.56,.64,1); }
@keyframes pulo { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ============ Login animado ============ */
.login-marca { background-size: 200% 200%; animation: aurora 16s ease-in-out infinite alternate; }
@keyframes aurora { from { background-position: 0% 0%; } to { background-position: 100% 100%; } }
.login-marca .bolha { position: absolute; border-radius: 50%; filter: blur(40px); opacity: .55; pointer-events: none; animation: bolha 14s ease-in-out infinite alternate; }
.login-marca .bolha.b1 { width: 320px; height: 320px; background: #2f74d0; top: -80px; right: -60px; }
.login-marca .bolha.b2 { width: 260px; height: 260px; background: #22d3ee; bottom: -90px; left: 10%; animation-duration: 18s; opacity: .3; }
@keyframes bolha { to { transform: translate(-60px, 50px) scale(1.15); } }
.login-marca canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; pointer-events: none; }
.login-marca > *:not(.bolha):not(canvas):not(.pv-login) { position: relative; z-index: 2; }
.login-cartao { animation: sobe-cartao .8s cubic-bezier(.16,1,.3,1) .1s both; }
@keyframes sobe-cartao { from { opacity: 0; transform: translateY(30px) rotateX(10deg); } to { opacity: 1; transform: none; } }
.login-marca h1 .letra { display: inline-block; animation: letra .7s cubic-bezier(.16,1,.3,1) both; animation-delay: calc(var(--i) * 35ms + .2s); }
@keyframes letra { from { opacity: 0; transform: translateY(.5em) rotate(8deg); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.form-tremor { animation: tremor .4s; }
@keyframes tremor { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ============ Menu lateral: itens entram em sequência ============ */
@media (max-width: 960px) {
  .app.menu-aberto .lateral a, .app.menu-aberto .lateral .grupo { animation: menu-item .45s cubic-bezier(.16,1,.3,1) both; animation-delay: calc(var(--i, 0) * 30ms + 60ms); }
}
@keyframes menu-item { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }

/* ============ Janela (modal) como folha deslizante no celular ============ */
.modal .alca { display: none; }
@media (max-width: 600px) {
  .modal { animation: folha .45s cubic-bezier(.16,1,.3,1); touch-action: pan-y; }
  .modal .alca { display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--borda-forte); margin: 8px auto 0; flex: none; }
  .modal .m-cab { padding-top: 10px; }
  .modal.arrastando { transition: none; }
  .modal-fundo.fechando .modal { transform: translateY(100%) !important; transition: transform .25s ease-in; }
  .modal-fundo.fechando { opacity: 0; transition: opacity .25s; }
}
@keyframes folha { from { transform: translateY(100%); } to { transform: none; } }

/* ==========================================================
   AJUSTES DE CELULAR
   ========================================================== */
.nav-baixo { display: none; }
.filtros-btn { display: none; }
.filtros-extra { display: contents; }
.filtros-extra label.mini { display: none; }
@media (max-width: 960px) {
  /* Barra de navegação inferior, estilo aplicativo */
  .nav-baixo {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 50; background: color-mix(in srgb, var(--sup) 82%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid var(--borda); border-radius: 20px; box-shadow: 0 10px 30px -10px rgba(10,20,40,.35); padding: 6px;
  }
  .nav-baixo a, .nav-baixo button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; border-radius: 14px; border: 0; background: none;
    font-size: 10.5px; font-weight: 600; color: var(--txt-3); text-decoration: none; cursor: pointer; transition: color .2s; }
  .nav-baixo svg { width: 22px; height: 22px; transition: transform .35s cubic-bezier(.34,1.56,.64,1); }
  .nav-baixo .ativo { color: var(--pri); }
  .nav-baixo .ativo svg { transform: translateY(-2px) scale(1.08); }
  .nav-baixo .bolinha { position: absolute; z-index: -1; top: 6px; bottom: 6px; border-radius: 14px; background: var(--pri-suave);
    transition: left .4s cubic-bezier(.16,1,.3,1), width .4s cubic-bezier(.16,1,.3,1); }
  .conteudo { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .toasts { top: calc(10px + env(safe-area-inset-top)); bottom: auto; left: 10px; right: 10px; max-width: none; align-items: stretch; }
  .toast { max-width: none; }
  @keyframes toast-entra { from { opacity: 0; transform: translateY(-18px) scale(.95); } to { opacity: 1; transform: none; } }

  /* Topo compacto: título numa linha só */
  .topo { gap: 6px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); }
  .topo h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
  .topo .espaco { display: none; }
  .avatar { width: 32px; height: 32px; font-size: 13px; }
}
@media (max-width: 760px) {
  .conteudo { padding-left: 12px; padding-right: 12px; padding-top: 12px; }
  /* Indicadores viram uma faixa deslizante */
  .indicadores { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin-left: -12px; margin-right: -12px; padding: 2px 12px 6px; scrollbar-width: none; }
  .indicadores::-webkit-scrollbar { display: none; }
  .indicadores > .ind { flex: 0 0 auto; width: 46%; min-width: 150px; scroll-snap-align: start; padding: 14px; }
  .ind .val { font-size: 24px; }
  /* Chips de status deslizantes */
  .filtro-chips { flex-wrap: nowrap; overflow-x: auto; margin-left: -12px; margin-right: -12px; padding: 0 12px 4px; scrollbar-width: none; }
  .filtro-chips::-webkit-scrollbar { display: none; }
  .filtro-chips button { flex: none; }
  /* Barra de ferramentas: busca + botão de filtros; filtros abrem num painel */
  .cartao .cab { padding: 12px; }
  .barra-ferr { gap: 8px; }
  .barra-ferr .busca { flex: 1 1 0; min-width: 0; }
  .filtros-btn { display: inline-flex; flex: none; }
  .filtros-btn b { background: var(--pri); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; min-width: 18px; }
  .filtros-extra { display: none; flex-basis: 100%; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--borda); border-radius: 14px; background: var(--sup-2); animation: dobra .4s cubic-bezier(.16,1,.3,1); }
  .filtros-extra.aberto { display: flex; }
  .filtros-extra label.mini { display: block; font-size: 12px; font-weight: 600; color: var(--txt-3); margin-bottom: -4px; }
  .barra-ferr .acoes, .cartao .cab > .acoes { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 8px; }
  .acoes .btn { width: 100%; padding: 10px 8px; }
  .acoes .btn.pri, .acoes .btn.fantasma { grid-column: 1 / -1; }
  .conteudo { overflow-x: clip; }
  #sv-lote-barra:not(.oculto) { position: fixed; left: 10px; right: 10px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 45; background: var(--sup);
    border: 1px solid var(--borda) !important; border-radius: 16px; box-shadow: var(--sombra-alta); animation: dobra .35s cubic-bezier(.16,1,.3,1); }
  /* Cartões das tabelas */
  table.tab.responsiva tr { position: relative; border-radius: 16px; padding: 8px 0; box-shadow: var(--sombra); }
  table.tab.responsiva td { padding: 5px 14px; align-items: center; }
  table.tab.responsiva td.principal-td { padding-right: 54px; }
  table.tab.responsiva td.chk { position: absolute; top: 10px; right: 6px; width: auto; padding: 4px 8px; }
  table.tab.responsiva td.chk::before { display: none; }
  table.tab.responsiva td.chk input { width: 22px; height: 22px; }
  table.tab.responsiva td.acoes-td { border-top: 1px dashed var(--borda); margin-top: 6px; padding-top: 10px; }
  table.tab.responsiva td.acoes-td .btn.icone { padding: 9px 14px; }
  table.tab.responsiva td .obs-edit { max-width: 62%; text-align: right; border-color: var(--borda); }
  table.tab td { word-break: break-word; }
  .prazo { flex-direction: row; align-items: center; gap: 8px; }
  /* Abas com degradê nas bordas indicando que deslizam */
  .abas { margin-left: -12px; margin-right: -12px; padding: 0 12px; scroll-snap-type: x proximity;
    mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 24px), transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 24px), transparent); }
  .abas button { scroll-snap-align: start; padding: 10px 12px; flex: none; }
  /* TI */
  .teste .res:empty { display: none; }
  .teste-grade { grid-template-columns: 1fr; }
  .cmd { flex-direction: column; gap: 8px; }
  .cmd .btn { align-self: flex-start; }
  /* Tabela de permissões com primeira coluna fixa */
  .matriz th:first-child, .matriz td:first-child { position: sticky; left: 0; background: var(--sup); z-index: 1; min-width: 130px; }
  /* Modal */
  .modal .m-corpo { padding: 16px; }
  .grade-form { grid-template-columns: 1fr; }
  .sugestoes { max-height: 46vh; }
  /* Painel */
  .pn-hero::before { opacity: .25; }
}
@media (max-width: 380px) {
  .indicadores > .ind { width: 62%; }
  .nav-baixo a, .nav-baixo button { font-size: 9.5px; }
}

/* ============ Quem prefere menos movimento ============ */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .cascata > *, .cascata-filhos > * > *, table.tab tbody tr.surge, .login-cartao, .login-marca h1 .letra { opacity: 1 !important; transform: none !important; }
}
.prox { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
@media (max-width: 760px) {
  .prox { align-items: flex-end; text-align: right; }
  .matriz { min-width: 600px; }
}
