/* ============================================================================
   DYNAMIC ANIMATIONS & INTERACTIONS
   Modern micro-interactions and smooth animations
   ============================================================================ */

/* Fade-in Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Pulse Animation for Notifications */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Shimmer Effect for Loading */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

/* Bounce Animation */
@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

/* Rotate Animation for Loading Spinners */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Slide Down for Dropdowns */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Glow Effect */
@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(99, 102, 241, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.6), 0 0 30px rgba(99, 102, 241, 0.4);
    }
}

/* ============================================================================
   ANIMATION UTILITY CLASSES
   ============================================================================ */

.animate-fade-in {
    animation: fadeIn 0.6s ease-out;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.6s ease-out;
}

.animate-fade-in-right {
    animation: fadeInRight 0.6s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.6s ease-out;
}

.animate-scale-in {
    animation: scaleIn 0.4s ease-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 1s ease-in-out;
}

/* Staggered Animation Delays */
.animate-delay-1 {
    animation-delay: 0.1s;
}

.animate-delay-2 {
    animation-delay: 0.2s;
}

.animate-delay-3 {
    animation-delay: 0.3s;
}

.animate-delay-4 {
    animation-delay: 0.4s;
}

.animate-delay-5 {
    animation-delay: 0.5s;
}

.animate-delay-6 {
    animation-delay: 0.6s;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg,
            var(--gray-200) 0%,
            var(--gray-100) 50%,
            var(--gray-200) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-card {
    height: 100px;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* ============================================================================
   HOVER EFFECTS & MICRO-INTERACTIONS
   ============================================================================ */

/* Lift Effect */
.hover-lift {
    transition: all var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Grow Effect */
.hover-grow {
    transition: transform var(--transition-fast);
}

.hover-grow:hover {
    transform: scale(1.05);
}

/* Glow on Hover */
.hover-glow:hover {
    animation: glow 1.5s ease-in-out infinite;
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Smooth Highlight */
.highlight-on-hover {
    position: relative;
    transition: color var(--transition-fast);
}

.highlight-on-hover::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-500);
    transition: width var(--transition-base);
}

.highlight-on-hover:hover::before {
    width: 100%;
}

/* ============================================================================
   SCROLL ANIMATIONS
   ============================================================================ */

/* ============================================================================
   BIDIRECTIONAL SCROLL ANIMATIONS
   Elements fade in when scrolling down, fade out when scrolling up
   ============================================================================ */

.scroll-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal.hidden {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-fade {
    opacity: 0;
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-fade.revealed {
    opacity: 1;
}

.scroll-fade.hidden {
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Cards get bidirectional animation by default */
.card,
.stat-card {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.revealed,
.stat-card.revealed {
    opacity: 1;
    transform: translateY(0);
}

.card.hidden,
.stat-card.hidden {
    opacity: 0;
    transform: translateY(30px);
}

/* Table rows get smooth bidirectional animation */
tbody tr {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

tbody tr.revealed {
    opacity: 1;
    transform: translateY(0);
}

tbody tr.hidden {
    opacity: 0;
    transform: translateY(20px);
}

/* ============================================================================
   ENHANCED COMPONENTS WITH ANIMATIONS
   ============================================================================ */

/* Animated Stats Cards */
.stat-card {
    animation: fadeIn 0.5s ease-out backwards;
}

.stat-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.4s;
}

.stat-value {
    transition: transform var(--transition-base);
}

.stat-card:hover .stat-value {
    transform: scale(1.1);
}

/* Animated Buttons */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

/* Sidebar Animation */
.sidebar {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

.sidebar-nav a {
    opacity: 0;
    animation: fadeInLeft 0.3s ease-out forwards;
}

.sidebar-nav a:nth-child(1) {
    animation-delay: 0.1s;
}

.sidebar-nav a:nth-child(2) {
    animation-delay: 0.15s;
}

.sidebar-nav a:nth-child(3) {
    animation-delay: 0.2s;
}

.sidebar-nav a:nth-child(4) {
    animation-delay: 0.25s;
}

.sidebar-nav a:nth-child(5) {
    animation-delay: 0.3s;
}

.sidebar-nav a:nth-child(6) {
    animation-delay: 0.35s;
}

.sidebar-nav a:nth-child(7) {
    animation-delay: 0.4s;
}

.sidebar-nav a:nth-child(8) {
    animation-delay: 0.45s;
}

/* Table Row Animation */
tbody tr {
    animation: fadeIn 0.3s ease-out backwards;
}

tbody tr:nth-child(1) {
    animation-delay: 0.05s;
}

tbody tr:nth-child(2) {
    animation-delay: 0.1s;
}

tbody tr:nth-child(3) {
    animation-delay: 0.15s;
}

tbody tr:nth-child(4) {
    animation-delay: 0.2s;
}

tbody tr:nth-child(5) {
    animation-delay: 0.25s;
}

/* Form Input Focus Animation */
input:focus,
select:focus,
textarea:focus {
    animation: scaleIn 0.2s ease-out;
}

/* Badge Animation */
.status-badge {
    animation: scaleIn 0.3s ease-out;
}

/* Toast Notification */
.toast {
    animation: slideDown 0.3s ease-out;
}

/* ============================================================================
   PAGE TRANSITION
   ============================================================================ */

.page-enter {
    animation: fadeIn 0.4s ease-out;
}

.page-exit {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ============================================================================
   RESPONSIVE MOTION
   ============================================================================ */

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================================
   NUMBER COUNTER ANIMATION (for stats)
   ============================================================================ */

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.counter {
    animation: countUp 0.6s ease-out;
}