/* ============================================
   ANIMATIONS — Dashboard de Tráfego
   ============================================ */

/* ---- Keyframes ---- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    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);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(124, 58, 237, 0.2);
    }

    50% {
        box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

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

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }

    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

@keyframes borderGlow {

    0%,
    100% {
        border-color: var(--border-primary);
    }

    50% {
        border-color: var(--primary-400);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

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

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ---- Animation Classes ---- */
.anim-fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.anim-fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

.anim-fade-in-down {
    animation: fadeInDown 0.6s ease forwards;
}

.anim-fade-in-left {
    animation: fadeInLeft 0.6s ease forwards;
}

.anim-fade-in-right {
    animation: fadeInRight 0.6s ease forwards;
}

.anim-slide-up {
    animation: slideUp 0.7s ease forwards;
}

.anim-scale-in {
    animation: scaleIn 0.5s ease forwards;
}

.anim-bounce-in {
    animation: bounceIn 0.6s ease forwards;
}

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

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

.anim-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.anim-shake {
    animation: shake 0.5s ease;
}

/* ---- Staggered Children ---- */
.stagger-children>* {
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.stagger-children>*:nth-child(1) {
    animation-delay: 0.05s;
}

.stagger-children>*:nth-child(2) {
    animation-delay: 0.1s;
}

.stagger-children>*:nth-child(3) {
    animation-delay: 0.15s;
}

.stagger-children>*:nth-child(4) {
    animation-delay: 0.2s;
}

.stagger-children>*:nth-child(5) {
    animation-delay: 0.25s;
}

.stagger-children>*:nth-child(6) {
    animation-delay: 0.3s;
}

.stagger-children>*:nth-child(7) {
    animation-delay: 0.35s;
}

.stagger-children>*:nth-child(8) {
    animation-delay: 0.4s;
}

.stagger-children>*:nth-child(9) {
    animation-delay: 0.45s;
}

.stagger-children>*:nth-child(10) {
    animation-delay: 0.5s;
}

/* ---- Hover Effects ---- */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: var(--shadow-glow-purple);
}

.hover-scale {
    transition: transform var(--transition-fast);
}

.hover-scale:hover {
    transform: scale(1.03);
}

.hover-border-glow {
    transition: border-color var(--transition-base);
}

.hover-border-glow:hover {
    border-color: var(--primary-400);
}

/* ---- Transition Helpers ---- */
.transition-all {
    transition: all var(--transition-base);
}

.transition-colors {
    transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.transition-transform {
    transition: transform var(--transition-fast);
}

/* ---- Loading Skeleton ---- */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-tertiary) 25%,
            var(--bg-card-hover) 50%,
            var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* ---- Page Transition ---- */
.page-enter {
    animation: fadeInUp 0.4s ease forwards;
}

/* ---- Gradient Text Animation ---- */
.gradient-text-animated {
    background: linear-gradient(270deg, #7c3aed, #ec4899, #3b82f6, #7c3aed);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
}

/* ---- Funnel Animation ---- */
.funnel-bar-fill {
    animation: progressFill 1.2s ease forwards;
}

/* ---- KPI Card Animations ---- */
.kpi-card {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.4s ease,
        border-color 0.4s ease;
    overflow: hidden;
    border: 1px solid transparent;
}

.kpi-card:hover {
    transform: translateY(-8px) scale(1.04);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.3),
        0 0 30px rgba(124, 58, 237, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Icon pulse on hover */
.kpi-card:hover .kpi-icon {
    animation: bounceIn 0.5s ease;
    transform: scale(1.15);
    transition: transform 0.3s ease;
}

/* Value glow on hover */
.kpi-card:hover .kpi-value {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    transition: text-shadow 0.3s ease;
}

/* Speed up particles on hover */
.kpi-card:hover .kpi-particles .particle {
    animation-duration: 1.2s !important;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Brighten shimmer on hover */
.kpi-card:hover .kpi-shimmer {
    animation-duration: 1.5s;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.1) 45%,
            rgba(255, 255, 255, 0.2) 50%,
            rgba(255, 255, 255, 0.1) 55%,
            transparent 100%);
}

/* Floating particles */
@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0);
    }

    15% {
        opacity: 1;
        transform: translateY(-10px) scale(1);
    }

    85% {
        opacity: 0.6;
    }

    100% {
        opacity: 0;
        transform: translateY(-80px) scale(0.4);
    }
}

.kpi-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.kpi-particles .particle {
    position: absolute;
    bottom: 0;
    left: var(--x, 50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
    animation: particleFloat var(--duration, 3s) ease-in-out var(--delay, 0s) infinite;
}

.kpi-particles .particle:nth-child(2) {
    width: 3px;
    height: 3px;
    background: rgba(255, 255, 255, 0.35);
}

.kpi-particles .particle:nth-child(4) {
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* Shimmer sweep */
@keyframes kpiShimmer {
    0% {
        transform: translateX(-100%) skewX(-15deg);
    }

    100% {
        transform: translateX(300%) skewX(-15deg);
    }
}

.kpi-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.06) 45%,
            rgba(255, 255, 255, 0.12) 50%,
            rgba(255, 255, 255, 0.06) 55%,
            transparent 100%);
    animation: kpiShimmer 4s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.kpi-card .kpi-header,
.kpi-card .kpi-value {
    position: relative;
    z-index: 1;
}

/* ---- Alert Attention ---- */
.alert-attention {
    animation: borderGlow 2s ease-in-out infinite;
}

/* ---- Gauge Draw ---- */
.health-gauge-fill {
    animation: none;
    /* controlled via JS */
}

/* ---- Tab Content ---- */
.dashboard-section.active {
    animation: fadeIn 0.35s ease;
}