/* Animaciones suaves en todo el sistema */

/* Estilos de animación (Apariencia > Animaciones) */
:root {
  --an-k: 1;
  --an-ease: ease;
  --an-pop: cubic-bezier(0.2, 0.9, 0.3, 1.2);
  --an-dist: 10px;
  --an-scale: 0.92;
  --an-rot: 0deg;
}
html[data-anim-estilo='rapido'] {
  --an-k: 0.5;
  --an-ease: ease-out;
  --an-pop: ease-out;
  --an-dist: 5px;
  --an-scale: 0.97;
}
html[data-anim-estilo='elegante'] {
  --an-k: 1.7;
  --an-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --an-pop: cubic-bezier(0.22, 1, 0.36, 1);
  --an-dist: 20px;
  --an-scale: 0.97;
}
html[data-anim-estilo='dinamico'] {
  --an-k: 1.05;
  --an-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
  --an-pop: cubic-bezier(0.34, 1.7, 0.64, 1);
  --an-dist: 18px;
  --an-scale: 0.8;
}
html[data-anim-estilo='divertido'] {
  --an-k: 1.25;
  --an-ease: cubic-bezier(0.68, -0.55, 0.27, 1.55);
  --an-pop: cubic-bezier(0.68, -0.6, 0.27, 1.6);
  --an-dist: 26px;
  --an-scale: 0.66;
  --an-rot: -2.5deg;
}
@keyframes dsFadeUp {
  from {
    opacity: 0;
    transform: translateY(var(--an-dist)) rotate(var(--an-rot));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes dsFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes dsPop {
  from {
    opacity: 0;
    transform: scale(var(--an-scale)) translateY(calc(var(--an-dist) * 0.8)) rotate(var(--an-rot));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes dsSlideIn {
  from {
    opacity: 0;
    transform: translateX(calc(var(--an-dist) * -1));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes dsRow {
  from {
    opacity: 0;
    transform: translateX(calc(var(--an-dist) * 0.8));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes dsPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

/* Pantallas y tarjetas */
#view > * {
  animation: dsFadeUp calc(0.35s * var(--an-k)) var(--an-ease) both;
}
#view > *:nth-child(2) {
  animation-delay: calc(0.04s * var(--an-k));
}
#view > *:nth-child(3) {
  animation-delay: calc(0.08s * var(--an-k));
}
#view > *:nth-child(4) {
  animation-delay: calc(0.12s * var(--an-k));
}
#view > *:nth-child(5) {
  animation-delay: calc(0.16s * var(--an-k));
}
#view > *:nth-child(n + 6) {
  animation-delay: calc(0.2s * var(--an-k));
}
.kpis > *,
.grid > *,
.grid2 > * {
  animation: dsFadeUp calc(0.4s * var(--an-k)) var(--an-ease) both;
}
.kpis > *:nth-child(2),
.grid > *:nth-child(2),
.grid2 > *:nth-child(2) {
  animation-delay: calc(0.05s * var(--an-k));
}
.kpis > *:nth-child(3),
.grid > *:nth-child(3) {
  animation-delay: calc(0.1s * var(--an-k));
}
.kpis > *:nth-child(4),
.grid > *:nth-child(4) {
  animation-delay: calc(0.15s * var(--an-k));
}
.kpis > *:nth-child(5),
.grid > *:nth-child(5) {
  animation-delay: calc(0.2s * var(--an-k));
}
.kpis > *:nth-child(n + 6),
.grid > *:nth-child(n + 6) {
  animation-delay: calc(0.25s * var(--an-k));
}
.card2,
.kpi,
.panel {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
@media (hover: hover) {
  .kpi:hover,
  .card2:hover {
    transform: translateY(-2px);
  }
}
#top h1 {
  animation: dsSlideIn calc(0.35s * var(--an-k)) var(--an-ease) both;
}
tbody tr {
  animation: dsRow calc(0.3s * var(--an-k)) var(--an-ease) both;
}
tbody tr:nth-child(2) {
  animation-delay: calc(0.03s * var(--an-k));
}
tbody tr:nth-child(3) {
  animation-delay: calc(0.06s * var(--an-k));
}
tbody tr:nth-child(4) {
  animation-delay: calc(0.09s * var(--an-k));
}
tbody tr:nth-child(5) {
  animation-delay: calc(0.12s * var(--an-k));
}
tbody tr:nth-child(6) {
  animation-delay: calc(0.15s * var(--an-k));
}
tbody tr:nth-child(7) {
  animation-delay: calc(0.18s * var(--an-k));
}
tbody tr:nth-child(8) {
  animation-delay: calc(0.21s * var(--an-k));
}
tbody tr:nth-child(n + 9) {
  animation-delay: calc(0.24s * var(--an-k));
}
tbody tr {
  transition: background 0.15s;
}
.badge,
.chip,
.chipf {
  transition:
    transform 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}
.badge:hover,
.chip:hover,
.chipf:hover {
  transform: scale(1.05);
}

/* Botones: al pasar el mouse se elevan, al tocar se hunden */
button,
.btn,
.tile,
.chip,
.chipf,
nav a,
.seg button {
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    background 0.2s ease,
    opacity 0.2s ease,
    color 0.2s;
}
@media (hover: hover) {
  button:not(:disabled):hover,
  .tile:hover {
    transform: translateY(-1px);
  }
}
button:not(:disabled):active,
.tile:active,
nav a:active {
  transform: scale(0.95);
}
button.primary:not(:disabled):hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}
nav a {
  transition:
    background 0.15s,
    transform 0.15s,
    padding-left 0.15s;
}
@media (hover: hover) {
  nav a:hover {
    padding-left: 16px;
  }
}

/* Ventanas emergentes y avisos */
#modal:not(.hidden) {
  animation: dsFade calc(0.2s * var(--an-k)) var(--an-ease) both;
}
#modal:not(.hidden) .card {
  animation: dsPop calc(0.28s * var(--an-k)) var(--an-pop) both;
}
#toast {
  transform: translate(-50%, 24px);
  transition:
    opacity 0.3s,
    transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
#toast.on {
  transform: translate(-50%, 0);
}
#scrim {
  animation: dsFade calc(0.2s * var(--an-k)) var(--an-ease) both;
}
#gs:not(.hidden),
#gs.on {
  animation: dsFade calc(0.18s * var(--an-k)) var(--an-ease) both;
}

/* Menú lateral: las categorías se despliegan con animación */
nav .grpbody {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.28s ease;
}
nav .grpbody > div {
  overflow: hidden;
  min-height: 0;
  transition:
    opacity 0.25s ease,
    visibility 0s;
}
nav .grp.cerrado .grpbody {
  grid-template-rows: 0fr;
}
nav .grp.cerrado .grpbody > div {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0s 0.28s;
}
nav .grp:not(.cerrado) .grpbody a {
  animation: dsSlideIn calc(0.3s * var(--an-k)) var(--an-ease) both;
}

/* POS */
.tile {
  animation: dsPop calc(0.3s * var(--an-k)) var(--an-ease) both;
}
.tile:nth-child(2) {
  animation-delay: calc(0.02s * var(--an-k));
}
.tile:nth-child(3) {
  animation-delay: calc(0.04s * var(--an-k));
}
.tile:nth-child(4) {
  animation-delay: calc(0.06s * var(--an-k));
}
.tile:nth-child(5) {
  animation-delay: calc(0.08s * var(--an-k));
}
.tile:nth-child(6) {
  animation-delay: calc(0.1s * var(--an-k));
}
.tile:nth-child(n + 7) {
  animation-delay: calc(0.12s * var(--an-k));
}
.line,
.row {
  animation: dsFade calc(0.25s * var(--an-k)) var(--an-ease) both;
}
.fab,
#fabs button,
#fabs > * {
  animation: dsPop calc(0.4s * var(--an-k)) var(--an-ease) both;
}
.badge.bad {
  animation: dsPulse 2.2s ease-in-out infinite;
}
.empty {
  animation: dsFade calc(0.6s * var(--an-k)) var(--an-ease) both;
}

/* --- Animaciones añadidas: todo lo que antes aparecía de golpe --- */
@keyframes dsGrowX {
  from {
    transform: scaleX(0);
  }
  to {
    transform: none;
  }
}
@keyframes dsGrowY {
  from {
    transform: scaleY(0);
  }
  to {
    transform: none;
  }
}
@keyframes dsDrop {
  from {
    opacity: 0;
    transform: translateY(calc(var(--an-dist) * -1)) scale(var(--an-scale));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes dsShake {
  0%,
  100% {
    transform: rotate(0);
  }
  15% {
    transform: rotate(-16deg);
  }
  30% {
    transform: rotate(13deg);
  }
  45% {
    transform: rotate(-9deg);
  }
  60% {
    transform: rotate(6deg);
  }
  75% {
    transform: rotate(-3deg);
  }
}
@keyframes dsBadge {
  0% {
    transform: scale(0);
  }
  60% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes dsSheet {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* barras y gráficas crecen */
.bar i,
.ct-pres-bar i,
.ayu-prog div {
  transform-origin: left center;
  animation: dsGrowX calc(0.6s * var(--an-k)) var(--an-ease) both;
}
.days div,
.ct-flujo i,
.ct-comp i {
  transform-origin: center bottom;
  animation: dsGrowY calc(0.55s * var(--an-k)) var(--an-ease) both;
}
.ct-comp > div:nth-child(n + 2) i,
.ct-flujo > div:nth-child(n + 2) i,
.days div:nth-child(n + 2) {
  animation-delay: calc(0.03s * var(--an-k));
}
.ct-comp > div:nth-child(n + 5) i,
.ct-flujo > div:nth-child(n + 5) i,
.days div:nth-child(n + 5) {
  animation-delay: calc(0.08s * var(--an-k));
}
.ct-comp > div:nth-child(n + 9) i,
.ct-flujo > div:nth-child(n + 9) i,
.days div:nth-child(n + 9) {
  animation-delay: calc(0.13s * var(--an-k));
}
/* contabilidad, ayuda, atajos */
.ct-per button,
.ct-acc > * {
  animation: dsFade calc(0.3s * var(--an-k)) var(--an-ease) both;
}
.ct-out > div {
  animation: dsSlideIn calc(0.25s * var(--an-k)) var(--an-ease) both;
}
.ct-alertas {
  animation: dsDrop calc(0.35s * var(--an-k)) var(--an-pop) both;
}
.ct-dlg {
  animation: dsFade calc(0.2s * var(--an-k)) ease both;
}
.ct-dlg > .card2 {
  animation: dsPop calc(0.28s * var(--an-k)) var(--an-pop) both;
}
.ayu-main > * {
  animation: dsFadeUp calc(0.3s * var(--an-k)) var(--an-ease) both;
}
.ayu-card,
.ayu-tema,
.ayu-res {
  animation: dsPop calc(0.3s * var(--an-k)) var(--an-ease) both;
}
.ayu-cards > *:nth-child(2),
.ayu-temas > *:nth-child(2) {
  animation-delay: calc(0.03s * var(--an-k));
}
.ayu-cards > *:nth-child(3),
.ayu-temas > *:nth-child(3) {
  animation-delay: calc(0.06s * var(--an-k));
}
.ayu-cards > *:nth-child(4),
.ayu-temas > *:nth-child(4) {
  animation-delay: calc(0.09s * var(--an-k));
}
.ayu-cards > *:nth-child(n + 5),
.ayu-temas > *:nth-child(n + 5) {
  animation-delay: calc(0.12s * var(--an-k));
}
.ayu-it.sub {
  animation: dsSlideIn calc(0.22s * var(--an-k)) var(--an-ease) both;
}
.ayu-card,
.ayu-tema,
.ayu-it,
.ayu-cat {
  transition:
    transform 0.15s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}
#ayupos {
  animation: dsSheet calc(0.3s * var(--an-k)) var(--an-ease) both;
}
.atj-ov {
  animation: dsFade calc(0.18s * var(--an-k)) ease both;
}
.atj-box {
  animation: dsPop calc(0.28s * var(--an-k)) var(--an-pop) both;
}
.atj-row {
  animation: dsRow calc(0.25s * var(--an-k)) var(--an-ease) both;
}
/* formularios y detalles */
input,
select,
textarea {
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}
input[type='checkbox'],
input[type='radio'] {
  transition: transform 0.15s ease;
}
input[type='checkbox']:active,
input[type='radio']:active {
  transform: scale(0.85);
}
details[open] > *:not(summary) {
  animation: dsFadeUp calc(0.25s * var(--an-k)) var(--an-ease) both;
}
summary {
  transition: color 0.2s ease;
}
.tip {
  animation: dsFade calc(0.4s * var(--an-k)) var(--an-ease) both;
}
img {
  transition:
    opacity 0.3s ease,
    transform 0.2s ease;
}
/* POS */
#tabs button {
  animation: dsDrop calc(0.3s * var(--an-k)) var(--an-ease) both;
}
#tabs button:nth-child(2) {
  animation-delay: calc(0.03s * var(--an-k));
}
#tabs button:nth-child(3) {
  animation-delay: calc(0.06s * var(--an-k));
}
#tabs button:nth-child(4) {
  animation-delay: calc(0.09s * var(--an-k));
}
#tabs button:nth-child(n + 5) {
  animation-delay: calc(0.12s * var(--an-k));
}
#app > .panel {
  animation: dsFadeUp calc(0.3s * var(--an-k)) var(--an-ease) both;
}
.acc {
  animation: dsRow calc(0.28s * var(--an-k)) var(--an-ease) both;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease;
}
.chips .chip {
  animation: dsFade calc(0.3s * var(--an-k)) var(--an-ease) both;
}
#calc {
  animation: dsPop calc(0.25s * var(--an-k)) var(--an-pop) both;
  transform-origin: bottom left;
}
/* menú lateral en celular */
#side {
  transition: transform calc(0.3s * var(--an-k)) var(--an-ease);
}
/* notificaciones */
.noti-btn.sacude .noti-ico {
  animation: dsShake calc(0.8s * var(--an-k)) ease both;
  transform-origin: 50% 10%;
  display: inline-block;
}
.noti-badge.pop {
  animation: dsBadge calc(0.45s * var(--an-k)) var(--an-pop) both;
}
#notipanel {
  animation: dsDrop calc(0.24s * var(--an-k)) var(--an-pop) both;
  transform-origin: top right;
}
#notipanel.sale {
  animation: dsFade 0.16s ease reverse both;
}
.noti-it {
  animation: dsRow calc(0.28s * var(--an-k)) var(--an-ease) both;
  animation-delay: calc(var(--i, 0) * 0.03s * var(--an-k));
}
.noti-vacio b {
  animation: dsPulse 2.4s ease-in-out infinite;
  display: inline-block;
}
.nt-card {
  animation: dsFadeUp calc(0.3s * var(--an-k)) var(--an-ease) both;
  animation-delay: calc(var(--i, 0) * 0.025s * var(--an-k));
}
.nt-sw {
  transition:
    background 0.2s ease,
    transform 0.15s ease;
}

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