/**
 * Animations Library - Gestor de Despesas v3.0
 * Reusable animations for micro-interactions
 */

/* ========== Fade Animations ========== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.anim-fade-in { animation: fadeIn var(--transition-normal, 250ms ease) forwards; }
.anim-fade-in-up { animation: fadeInUp var(--transition-normal, 250ms ease) forwards; }
.anim-fade-in-down { animation: fadeInDown var(--transition-normal, 250ms ease) forwards; }
.anim-fade-in-scale { animation: fadeInScale var(--transition-normal, 250ms ease) forwards; }

/* ========== Slide Animations ========== */

@keyframes slideInUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========== Counter Animation ========== */

.counter-animate {
    transition: opacity 0.15s ease;
}

.counter-animate.counting {
    opacity: 0.7;
}

/* ========== Skeleton Loading ========== */

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg,
        var(--bg-secondary) 25%,
        rgba(255,255,255,0.15) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text-sm {
    height: 0.75rem;
    width: 60%;
    margin-bottom: 0.375rem;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
    border-radius: 12px;
}

/* Dashboard skeletons */
.skeleton-hero {
    height: 160px;
    border-radius: 16px;
    margin-bottom: 1rem;
}

.skeleton-quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.skeleton-quick-stat {
    height: 90px;
    border-radius: 12px;
}

.skeleton-feed-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
}

.skeleton-feed-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    flex-shrink: 0;
}

.skeleton-feed-lines {
    flex: 1;
}

/* ========== Progress Bar Animation ========== */

@keyframes progressFill {
    from { width: 0%; }
}

.progress-animated .hero-progress-fill,
.progress-animated .category-bar-fill {
    animation: progressFill 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ========== Stagger Animation ========== */

.stagger-children > * {
    opacity: 0;
    animation: fadeInUp 0.35s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }

/* ========== Pulse / Attention ========== */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg); }
    75% { transform: rotate(3deg); }
}

.anim-pulse { animation: pulse 2s ease-in-out infinite; }
.anim-bounce { animation: bounce 0.5s ease; }

/* ========== Score Circle (SVG) ========== */

@keyframes scoreCircleFill {
    from { stroke-dashoffset: 283; }
}

.score-circle-progress {
    animation: scoreCircleFill 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ========== Haptic feedback (visual) ========== */

@keyframes tapFeedback {
    0% { transform: scale(1); }
    50% { transform: scale(0.97); }
    100% { transform: scale(1); }
}

.tap-feedback:active {
    animation: tapFeedback 0.15s ease;
}

/* ========== Page Transition ========== */

.page-enter {
    animation: fadeInUp 0.25s ease forwards;
}

/* ========== Reduced Motion ========== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .skeleton {
        animation: none;
        background: var(--bg-secondary);
    }
}
