/* ============================================================
   FINZY BUDGET — ANIMATIONS
   ============================================================ */

/* ─── KEYFRAMES ──────────────────────────────────────────── */

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

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

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

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

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

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

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

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
  50%       { transform: translateY(-8px); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}

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

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); max-height: 100px; }
  to   { opacity: 0; transform: translateX(100%); max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }
}

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

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

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

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(0,196,140,0.2); }
  50%       { box-shadow: 0 0 40px rgba(0,196,140,0.45); }
}

@keyframes confettiFall {
  0%   { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

/* ─── ANIMATION UTILITY CLASSES ──────────────────────────── */

.animate-fade-in {
  animation: fadeIn 400ms ease forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 450ms ease forwards;
}

.animate-slide-in-left {
  animation: slideInLeft 400ms ease forwards;
}

.animate-slide-in-right {
  animation: slideInRight 400ms ease forwards;
}

.animate-scale-in {
  animation: scaleIn 300ms ease forwards;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse 2s ease infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

/* Staggered children */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 80ms; }
.stagger-children > *:nth-child(3) { animation-delay: 160ms; }
.stagger-children > *:nth-child(4) { animation-delay: 240ms; }
.stagger-children > *:nth-child(5) { animation-delay: 320ms; }
.stagger-children > *:nth-child(6) { animation-delay: 400ms; }
.stagger-children > *:nth-child(7) { animation-delay: 480ms; }
.stagger-children > *:nth-child(8) { animation-delay: 560ms; }

/* ─── PAGE TRANSITION ────────────────────────────────────── */
.page-enter {
  animation: fadeInUp 450ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ─── CARD HOVER EFFECTS ─────────────────────────────────── */
.card-hover {
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

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

/* ─── BUTTON RIPPLE ──────────────────────────────────────── */
.btn {
  position: relative;
  overflow: hidden;
}

.btn .ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: ripple 600ms linear;
  pointer-events: none;
}

/* ─── NUMBER COUNTER ─────────────────────────────────────── */
.count-up {
  animation: countUp 600ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ─── PROGRESS BAR ANIMATED ──────────────────────────────── */
.progress-fill {
  animation: progressFill 800ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ─── SKELETON SHIMMER ───────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e4e4e4 37%,
    #f0f0f0 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

/* ─── SIDEBAR NAV ITEMS ───────────────────────────────────── */
.sidebar .nav-item {
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.sidebar .nav-item:hover {
  transform: translateX(3px);
}

.sidebar .nav-item.active {
  transform: translateX(3px);
}

/* ─── LANDING PAGE HERO ───────────────────────────────────── */
.hero-card-float {
  animation: float 4s ease-in-out infinite;
}

.hero-gradient-text {
  background: linear-gradient(135deg, #00C48C, #00A876, #059669);
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  animation: fadeIn 200ms ease forwards;
}

.modal-overlay.open .modal {
  animation: scaleIn 250ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ─── GOAL COMPLETED ─────────────────────────────────────── */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  z-index: 9999;
  pointer-events: none;
  animation: confettiFall 3s ease-in forwards;
}

/* ─── LOADING PAGE ───────────────────────────────────────── */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 400ms ease, visibility 400ms ease;
}

.page-loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.page-loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.page-loader-logo {
  width: 52px;
  height: 52px;
  background: var(--color-primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: white;
  animation: pulse 1.5s ease infinite;
}

/* ─── CHART ANIMATIONS ───────────────────────────────────── */
.chart-container canvas {
  animation: fadeIn 600ms ease forwards;
}

/* ─── HOVER SCALE ────────────────────────────────────────── */
.hover-scale {
  transition: transform var(--transition-fast);
}
.hover-scale:hover { transform: scale(1.02); }

/* ─── FOCUS RING ─────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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