/* ═══════════════════════════════════════════════════════════════
   NEXUS Dashboard - Animations & Micro-Interactions
   Fluid, Physics-Based Motion Design
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   Keyframe Animations
   ───────────────────────────────────────────────────────────────── */

/* Floating Orbs */
@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(30px, -30px) scale(1.05);
    }
    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }
    75% {
        transform: translate(20px, 10px) scale(1.02);
    }
}

/* Pulse Animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* Slow Rotation */
@keyframes rotate-slow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Slide In with Fade */
@keyframes slideInFade {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide Up Entrance */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Skeleton Loading */
@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Chart Draw Animation */
@keyframes drawLine {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* Glow Pulse */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--color-accent-glow);
    }
    50% {
        box-shadow: 0 0 40px var(--color-accent-glow), 0 0 60px var(--color-accent-glow);
    }
}

/* Number Count Up (for stats) */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ripple Effect */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Shake (for errors) */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Bounce */
@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);
    }
}

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

/* Ping */
@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* ─────────────────────────────────────────────────────────────────
   Page Load Stagger Animation
   ───────────────────────────────────────────────────────────────── */
.dashboard-header {
    animation: slideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    animation-delay: 0.1s;
}

.stats-bar {
    animation: slideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    animation-delay: 0.2s;
}

.stats-bar .stat-card:nth-child(1) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.3s; }
.stats-bar .stat-card:nth-child(2) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.4s; }
.stats-bar .stat-card:nth-child(3) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.5s; }
.stats-bar .stat-card:nth-child(4) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.6s; }

.widget-grid .widget:nth-child(1) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.4s; }
.widget-grid .widget:nth-child(2) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.5s; }
.widget-grid .widget:nth-child(3) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.55s; }
.widget-grid .widget:nth-child(4) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.6s; }
.widget-grid .widget:nth-child(5) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.65s; }
.widget-grid .widget:nth-child(6) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.7s; }
.widget-grid .widget:nth-child(7) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.75s; }
.widget-grid .widget:nth-child(8) { animation: scaleIn 0.5s ease-out backwards; animation-delay: 0.8s; }

/* ─────────────────────────────────────────────────────────────────
   Hover Micro-Interactions
   ───────────────────────────────────────────────────────────────── */

/* Stat Card Hover */
.stat-card {
    transform-origin: center;
}

.stat-card:hover .stat-icon {
    animation: bounce 0.6s ease-in-out;
}

.stat-card:hover .stat-value {
    animation: countUp 0.3s ease-out;
}

/* Navigation Button Hover */
.nav-btn {
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, var(--color-accent-primary) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-base);
}

.nav-btn:hover::before {
    opacity: 0.1;
    transform: scale(2);
}

/* Icon Button Hover */
.icon-btn {
    position: relative;
}

.icon-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    background: var(--color-accent-primary);
    border-radius: var(--radius-lg);
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-fast);
    z-index: -1;
}

.icon-btn:hover::before {
    opacity: 0.15;
    transform: scale(1);
}

/* Widget Hover Effects */
.widget-header {
    transition: background var(--transition-base);
}

.widget:hover .widget-header {
    background: rgba(0, 240, 255, 0.03);
}

.widget:hover .widget-title {
    color: var(--color-accent-primary);
    transition: color var(--transition-base);
}

/* Drag Handle Hover */
.drag-handle {
    transition: all var(--transition-fast);
}

.drag-handle:hover {
    transform: scale(1.2);
    text-shadow: 0 0 10px var(--color-accent-glow);
}

/* Activity Item Hover */
.activity-item {
    transition: all var(--transition-fast);
}

.activity-item:hover {
    transform: translateX(4px);
    border-color: var(--color-accent-primary);
    box-shadow: -4px 0 0 var(--color-accent-primary);
}

/* Mini Stat Bar Hover */
.mini-stat:hover .mini-stat-bar::after {
    filter: brightness(1.2);
    box-shadow: 0 0 20px var(--color-accent-glow);
}

/* ─────────────────────────────────────────────────────────────────
   Theme Transition
   ───────────────────────────────────────────────────────────────── */
html {
    transition:
        background-color var(--transition-slow),
        color var(--transition-slow);
}

/* Smooth color transitions on theme change */
.widget,
.stat-card,
.dashboard-header,
.nav-btn,
.icon-btn,
.activity-item,
.mini-stat-bar,
.toggle-track,
.toggle-thumb {
    transition:
        background-color var(--transition-slow),
        border-color var(--transition-slow),
        color var(--transition-slow),
        box-shadow var(--transition-slow),
        transform var(--transition-base);
}

/* ─────────────────────────────────────────────────────────────────
   Chart Animations
   ───────────────────────────────────────────────────────────────── */
.chart-animate-in {
    animation: fadeIn 0.8s ease-out;
}

/* Canvas glow effect on hover */
.widget-body canvas {
    transition: filter var(--transition-base);
}

.widget:hover .widget-body canvas {
    filter: drop-shadow(0 0 8px var(--color-accent-glow));
}

/* ─────────────────────────────────────────────────────────────────
   Live Indicator Animations
   ───────────────────────────────────────────────────────────────── */
.live-indicator {
    animation: fadeIn 1s ease-out;
}

.live-indicator::before {
    content: '';
    position: absolute;
    left: 0;
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
    animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* ─────────────────────────────────────────────────────────────────
   Scroll-Triggered Animations (for when implemented)
   ───────────────────────────────────────────────────────────────── */
.scroll-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

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

    .gradient-orb {
        animation: none;
    }

    .pulse {
        animation: none;
    }

    .logo-mark {
        animation: none;
    }
}

/* ─────────────────────────────────────────────────────────────────
   Special Effects
   ───────────────────────────────────────────────────────────────── */

/* Glassmorphism shine effect */
.widget::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 40%,
        rgba(255, 255, 255, 0.03) 45%,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0.03) 55%,
        transparent 60%
    );
    transform: translateX(-100%) rotate(45deg);
    pointer-events: none;
    transition: transform 0.8s ease-in-out;
}

.widget:hover::after {
    transform: translateX(100%) rotate(45deg);
}

/* Notification dot pulse ring */
.notification-dot::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--color-danger);
    border-radius: 50%;
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
