/* Animaciones de la interfaz. Se desactivan si el sistema pide "reducir movimiento". */

/* Entrada escalonada de tarjetas, indicadores y casillas */
@keyframes subir {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.sube {
  animation: subir 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
  animation-delay: var(--d, 0ms);
}

/* Aparición suave del título al cambiar de sección */
@keyframes aparece {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.hd h1,
.tb {
  animation: aparece 0.45s ease backwards;
}

/* Efecto al pasar el cursor */
.kpi,
.tl,
.card,
.btn,
.ch,
#nv button {
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease,
    border-color 0.18s ease,
    opacity 0.18s ease;
}
.kpi:hover,
.tl:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  border-color: color-mix(in srgb, var(--ac) 55%, transparent);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
.btn:active:not(:disabled) {
  transform: scale(0.96);
}
.tbl tbody tr {
  transition: background-color 0.15s ease;
}
.tbl tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}
.it {
  transition: background-color 0.15s ease;
}
.it:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Ventanas (cobro, factura, anulación) */
@keyframes velo {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes ventana {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
#m.on {
  animation: velo 0.2s ease;
}
#m.on #mb {
  animation: ventana 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Punto de estado que late en los locales pendientes */
@keyframes latido {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent);
  }
  60% {
    box-shadow: 0 0 0 6px transparent;
  }
}
.dot.pendiente {
  animation: latido 1.8s ease-out infinite;
}

/* Avisos (toast) */
#toasts {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sf2);
  color: var(--tx);
  border: 1px solid var(--bd);
  border-left: 4px solid var(--ok);
  padding: 11px 16px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  font-weight: 600;
  animation: entra 0.35s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.toast.err {
  border-left-color: var(--er);
}
.toast.sale {
  opacity: 0;
  transform: translateX(24px);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}
@keyframes entra {
  from {
    opacity: 0;
    transform: translateX(32px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ==========================================================================
   Menú lateral
   ========================================================================== */
#nv {
  position: relative;
}
#nv button {
  position: relative;
  z-index: 1;
  overflow: hidden;
}
/* Barra amarilla que crece al pasar el cursor */
#nv button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 3px;
  background: var(--ac);
  transform: scaleY(0);
  transition: transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
}
#nv button:hover:not(.on) {
  transform: translateX(5px);
}
#nv button:hover:not(.on)::before {
  transform: scaleY(1);
}
#nv button:active {
  transform: scale(0.97);
}
#nv button svg {
  transition: transform 0.3s cubic-bezier(0.3, 1.7, 0.5, 1);
}
#nv button:hover svg {
  transform: scale(1.22) rotate(-8deg);
  color: var(--ac);
}
#nv button.on:hover svg {
  color: inherit;
}
/* Píldora amarilla que se desliza al botón activo */
#nv.pil button.on {
  background: transparent;
}
#pil {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  border-radius: 10px;
  background: var(--ac);
  box-shadow: 0 6px 20px rgba(253, 182, 0, 0.35);
  overflow: hidden;
  pointer-events: none;
  transition:
    transform 0.5s cubic-bezier(0.3, 1.25, 0.4, 1),
    width 0.4s ease,
    height 0.4s ease;
}
#pil::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -50%;
  width: 40%;
  background: linear-gradient(
    100deg,
    transparent,
    rgba(255, 255, 255, 0.55),
    transparent
  );
  transform: skewX(-18deg);
  animation: barrido 4.5s ease-in-out 1.5s infinite;
}
@keyframes barrido {
  0%,
  60% {
    left: -50%;
  }
  100% {
    left: 130%;
  }
}
/* El icono del botón recién elegido da un salto */
#nv button.on.pop svg {
  animation: iconoSalto 0.65s cubic-bezier(0.3, 1.4, 0.5, 1);
}
@keyframes iconoSalto {
  0% {
    transform: scale(0.5) rotate(-30deg);
  }
  55% {
    transform: scale(1.4) rotate(10deg);
  }
  100% {
    transform: none;
  }
}
/* Entrada del menú, pieza por pieza */
.m-in {
  animation: menuEntra 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms + 120ms);
}
@keyframes menuEntra {
  from {
    opacity: 0;
    transform: translateX(-22px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* Globito con el número de recordatorios vencidos */
.bdg {
  margin-left: auto;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--er);
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  animation: pulsoBdg 1.8s ease-out infinite;
}
@keyframes pulsoBdg {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 107, 94, 0.6);
  }
  70%,
  100% {
    box-shadow: 0 0 0 9px rgba(255, 107, 94, 0);
  }
}
/* Logo con flotación suave y avatar con aro de luz */
.sb .lg {
  animation: flotaSuave 6s ease-in-out infinite;
}
@keyframes flotaSuave {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
.prof .av {
  animation: aroAvatar 3.2s ease-out infinite;
}
@keyframes aroAvatar {
  0% {
    box-shadow: 0 0 0 0 rgba(253, 182, 0, 0.55);
  }
  70%,
  100% {
    box-shadow: 0 0 0 9px rgba(253, 182, 0, 0);
  }
}

/* ==========================================================================
   Resumen y tarjetas
   ========================================================================== */
/* Luz que sigue al cursor */
.kpi,
.card,
.tl {
  position: relative;
}
.kpi::before,
.card::before,
.tl::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  background: radial-gradient(
    240px circle at var(--mx, 50%) var(--my, 50%),
    rgba(253, 182, 0, 0.13),
    transparent 62%
  );
}
.kpi:hover::before,
.card:hover::before,
.tl:hover::before {
  opacity: 1;
}
/* Inclinación 3D de los indicadores */
.kpi {
  transform-style: preserve-3d;
}
.kpi:hover {
  transform: perspective(800px) rotateX(var(--rx, 0deg))
    rotateY(var(--ry, 0deg)) translateY(-4px);
  transition:
    transform 0.12s ease-out,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}
/* Destello que cruza cada indicador al entrar */
.kpi.sube::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(
    100deg,
    transparent,
    rgba(255, 255, 255, 0.14),
    transparent
  );
  transform: skewX(-18deg);
  pointer-events: none;
  animation: barrido1 1.2s ease calc(var(--d, 0ms) + 0.55s) 1 both;
}
@keyframes barrido1 {
  from {
    left: -60%;
  }
  to {
    left: 140%;
  }
}
.kpi .ki {
  animation: flotaIcono 3.8s ease-in-out infinite;
}
.kpi:nth-child(2) .ki {
  animation-delay: -0.9s;
}
.kpi:nth-child(3) .ki {
  animation-delay: -1.8s;
}
.kpi:nth-child(4) .ki {
  animation-delay: -2.7s;
}
@keyframes flotaIcono {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  50% {
    transform: translateY(-3px) rotate(-6deg);
  }
}
/* Cifras: pequeño rebote al llegar al valor */
.pop:not(button) {
  animation: cifraPop 0.5s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes cifraPop {
  40% {
    transform: scale(1.09);
    color: var(--ac);
  }
}
/* Subrayado que se dibuja bajo el título */
.hd h1::after {
  content: "";
  display: block;
  height: 3px;
  width: 0;
  margin-top: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--ac), var(--or));
  animation: subraya 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.25s forwards;
}
@keyframes subraya {
  to {
    width: 48px;
  }
}
/* Casillas de locales: entran con un pequeño salto */
.tl.sube {
  animation-name: casillaPop;
  animation-duration: 0.65s;
  animation-timing-function: cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes casillaPop {
  from {
    opacity: 0;
    transform: scale(0.6) rotate(-4deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.tl.dis.sube {
  animation:
    casillaPop 0.65s cubic-bezier(0.3, 1.5, 0.5, 1) backwards,
    respira 3.6s ease-in-out infinite;
  animation-delay: var(--d, 0ms), calc(var(--d, 0ms) + 0.7s);
}
@keyframes respira {
  50% {
    border-color: color-mix(in srgb, var(--ac) 50%, transparent);
  }
}
.dot.parcial {
  animation: latido 2.4s ease-out infinite;
}
/* Filas de las listas: se deslizan una tras otra */
.desliza {
  animation: aparece 0.5s ease backwards;
  animation-delay: var(--d, 0ms);
}
/* Tarjeta destacada: brillo que gira y botón que late */
.cta {
  position: relative;
  overflow: hidden;
}
.cta::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -60px;
  bottom: -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(253, 182, 0, 0.45), transparent 65%);
  pointer-events: none;
  animation: derivaCta 9s ease-in-out infinite alternate;
}
@keyframes derivaCta {
  to {
    transform: translate(-90px, -50px) scale(1.3);
  }
}
.cta > * {
  position: relative;
  z-index: 1;
}
.cta .btn {
  animation: pulsoBtn 2.6s ease-out 1.5s infinite;
}
@keyframes pulsoBtn {
  0% {
    box-shadow: 0 0 0 0 rgba(253, 182, 0, 0.55);
  }
  70%,
  100% {
    box-shadow: 0 0 0 12px rgba(253, 182, 0, 0);
  }
}
/* Aviso de recordatorios: borde que respira */
.avb.sube {
  animation:
    subir 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) backwards,
    respiraAviso 2.4s ease-in-out infinite;
  animation-delay: var(--d, 0ms), calc(var(--d, 0ms) + 0.6s);
}
@keyframes respiraAviso {
  50% {
    box-shadow: 0 0 22px rgba(255, 107, 94, 0.28);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
