/* ============================================================
   EmprestaAí — Animations CSS
   Micro-animations, transitions, and keyframes
   ============================================================ */

/* ===================== KEYFRAMES ===================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes slideUp {
  from { transform: translate(-50%, 100%); opacity: 0; }
  to   { transform: translate(-50%, 0);   opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pageExit {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-12px); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes logoSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes loadingBar {
  0%   { width: 0%;   margin-left: 0; }
  50%  { width: 60%;  margin-left: 20%; }
  100% { width: 0%;   margin-left: 100%; }
}

@keyframes loadingPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  25%       { transform: translateY(-8px); }
  75%       { transform: translateY(-4px); }
}

@keyframes shake {
  0%, 100%  { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80%       { transform: translateX(6px); }
}

@keyframes checkmark {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0; }
}

@keyframes ripple {
  from { transform: scale(0); opacity: 0.5; }
  to   { transform: scale(4); opacity: 0; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-16px) scale(0.95); }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes cardFlip {
  from { transform: rotateY(90deg); opacity: 0; }
  to   { transform: rotateY(0); opacity: 1; }
}

@keyframes progressFill {
  from { width: 0; }
}

/* ===================== UTILITY ANIMATION CLASSES ===================== */

.animate-fade-in { animation: fadeIn 0.2s ease; }
.animate-scale-in { animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.animate-slide-up { animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.animate-page { animation: pageEnter 0.28s cubic-bezier(0.4, 0, 0.2, 1); }
.animate-bounce { animation: bounce 0.5s ease; }
.animate-shake  { animation: shake 0.4s ease; }
.animate-spin   { animation: spin 1s linear infinite; }
.animate-pulse  { animation: pulse 2s ease-in-out infinite; }

/* ===================== RIPPLE EFFECT ===================== */
.ripple-container {
  position: relative;
  overflow: hidden;
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  animation: ripple 0.6s ease-out forwards;
}

/* ===================== TRANSITION CLASSES ===================== */
.transition-fast { transition: var(--transition-fast); }
.transition-base { transition: var(--transition-base); }
.transition-slow { transition: var(--transition-slow); }
.transition-spring { transition: var(--transition-spring); }

/* ===================== NAV ACTIVE INDICATOR ===================== */
.nav-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.2s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item.active::after,
.nav-item[data-active="true"]::after {
  background: var(--clr-accent);
  transform: scale(1);
}

/* ===================== CARD HOVER EFFECTS ===================== */
.card-hover {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.25s ease;
}

.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--clr-accent-alpha);
}

.card-hover:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-sm);
  transition-duration: 0.1s;
}

/* ===================== STAGGER CHILDREN ===================== */
.stagger-children > * {
  animation: pageEnter 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.stagger-children > *:nth-child(1)  { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2)  { animation-delay: 0.10s; }
.stagger-children > *:nth-child(3)  { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4)  { animation-delay: 0.20s; }
.stagger-children > *:nth-child(5)  { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6)  { animation-delay: 0.30s; }
.stagger-children > *:nth-child(7)  { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8)  { animation-delay: 0.40s; }
.stagger-children > *:nth-child(9)  { animation-delay: 0.45s; }
.stagger-children > *:nth-child(10) { animation-delay: 0.50s; }

/* ===================== BUTTON PRESS ===================== */
.btn-press {
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-press:active {
  transform: scale(0.96);
}

/* ===================== HAPTIC FEEDBACK VISUAL ===================== */
.haptic-press:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* ===================== FAB ANIMATION ===================== */
.nav-fab {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease;
}

/* ===================== SKELETON PULSE ===================== */
@keyframes skeletonPulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; }
  100% { opacity: 1; }
}

.skeleton-pulse { animation: skeletonPulse 1.8s ease-in-out infinite; }

/* ===================== CHECKMARK SVG ===================== */
.checkmark-path {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.checkmark-path.animate { animation: checkmark 0.4s ease-in-out 0.1s forwards; }

/* ===================== STATUS BAR GLOW ===================== */
.kpi-card.kpi-blue   { box-shadow: var(--shadow-sm), 0 0 20px rgba(0, 122, 255, 0.05); }
.kpi-card.kpi-green  { box-shadow: var(--shadow-sm), 0 0 20px rgba(52, 199, 89, 0.05); }
.kpi-card.kpi-orange { box-shadow: var(--shadow-sm), 0 0 20px rgba(255, 149, 0, 0.05); }
.kpi-card.kpi-red    { box-shadow: var(--shadow-sm), 0 0 20px rgba(255, 59, 48, 0.05); }

/* ===================== MODAL DRAG HANDLE ===================== */
.modal-handle {
  cursor: grab;
  transition: background 0.2s ease;
}

.modal-handle:active { cursor: grabbing; background: var(--clr-text-tertiary); }

/* ===================== LIST ITEM SWIPE HINT ===================== */
@keyframes swipeHint {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-8px); }
  40%  { transform: translateX(0); }
  100% { transform: translateX(0); }
}

.swipe-hint { animation: swipeHint 2s ease 1.5s both; }

/* ===================== ENTRY ANIMATIONS ===================== */
.enter-from-right {
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.enter-from-left {
  animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================== ACCESSIBILITY ===================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
