"use client"; import { useEffect, useState, useRef } from "react"; import { Target, Zap, Shield, Lock, TrendingUp } from "lucide-react"; import { BentoGrid } from "@/components/ui/bento-grid"; import { Spotlight } from "@/components/ui/spotlight-new"; import { GlowingEffect } from "@/components/ui/glowing-effect"; import { useScrollAnimation } from "@/hooks/useScrollAnimation"; // ========================================== // Hooks (Kept your optimized hook) // ========================================== function useCountUp( end: number, duration: number = 2000, startOnView: boolean = true, ) { const [count, setCount] = useState(0); const [hasStarted, setHasStarted] = useState(!startOnView); const ref = useRef(null); useEffect(() => { if (!startOnView) return; const observer = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting && !hasStarted) setHasStarted(true); }, { threshold: 0.5 }, ); if (ref.current) observer.observe(ref.current); return () => observer.disconnect(); }, [hasStarted, startOnView]); useEffect(() => { if (!hasStarted || end === 0) return; let startTime: number | null = null; let animationFrame: number; const animate = (timestamp: number) => { if (!startTime) startTime = timestamp; const progress = Math.min((timestamp - startTime) / duration, 1); const easeOut = 1 - Math.pow(1 - progress, 4); // Smoother cubic out const nextValue = end * easeOut; setCount( Number.isInteger(end) ? Math.floor(nextValue) : Number(nextValue.toFixed(1)), ); if (progress < 1) animationFrame = requestAnimationFrame(animate); }; animationFrame = requestAnimationFrame(animate); return () => cancelAnimationFrame(animationFrame); }, [hasStarted, end, duration]); return { count, ref }; } // ========================================== // Types // ========================================== interface StatItem { value: string; numericValue?: number; suffix?: string; prefix?: string; label: string; icon: React.ElementType; gradient: string; className?: string; glowColor?: string; spotlight?: { gradientFirst?: string; gradientSecond?: string; gradientThird?: string; duration?: number; xOffset?: number; }; additional?: string; isText?: boolean; } // ========================================== // High-Impact Stat Card // ========================================== function StatCard({ value, numericValue, suffix = "", prefix = "", label, icon: Icon, gradient, className, glowColor, spotlight, delay, additional, isText = false, }: StatItem & { delay: number }) { const { ref: scrollRef, isVisible } = useScrollAnimation({ threshold: 0.3, }); const { count, ref: countRef } = useCountUp(numericValue || 0, 2500); return (
{/* Outer Glow behind the card */}
{/* The Card Body: Gradient border wrapper + inner glassmorphism */}
{/* Majestic Background Icon */}
{/* Content */}
{/* Vibrant Badge */}
Performance
{/* Massive Gradient Text */}
{isText ? ( {value} ) : ( {prefix} {numericValue !== undefined && !Number.isInteger(numericValue) ? count.toFixed(1) : numericValue !== undefined ? count : value} {suffix} )}

{label}

{/* Glowing Additional Info */} {additional && (
{additional}
)}
); } // ========================================== // Main Component // ========================================== export function Stats() { const { ref: headerRef, isVisible: headerVisible } = useScrollAnimation(); const stats: StatItem[] = [ { value: "99.9", numericValue: 99.9, suffix: "%", label: "OCR + AI Accuracy", icon: Target, gradient: "bg-gradient-to-r from-cyan-500 to-blue-600", glowColor: "bg-cyan-500", className: "md:col-span-2", spotlight: { gradientFirst: "radial-gradient(68% 68% at 55% 31%, hsla(217, 100%, 60%, 0.4) 0, transparent 80%)", }, additional: "+0.3% this month", }, { value: "< 10", label: "Avg. AI Response Time", icon: Zap, gradient: "bg-gradient-to-r from-orange-500 to-amber-600", glowColor: "bg-orange-500", isText: true, spotlight: { gradientFirst: "radial-gradient(68% 68% at 55% 31%, hsla(30, 100%, 60%, 0.4) 0, transparent 80%)", }, additional: "Under 10 seconds", }, { value: "100", numericValue: 100, suffix: "%", label: "Blockchain Verified", icon: Shield, gradient: "bg-gradient-to-r from-emerald-400 to-teal-600", glowColor: "bg-emerald-500", spotlight: { gradientFirst: "radial-gradient(68% 68% at 55% 31%, hsla(150, 100%, 50%, 0.3) 0, transparent 80%)", }, additional: "All docs certified", }, { value: "GDPR", label: "European Compliance", icon: Lock, gradient: "bg-gradient-to-r from-fuchsia-500 to-purple-600", glowColor: "bg-fuchsia-500", className: "md:col-span-2", isText: true, spotlight: { gradientFirst: "radial-gradient(68% 68% at 55% 31%, hsla(280, 100%, 60%, 0.4) 0, transparent 80%)", }, additional: "ISO 27001 Certified", }, ]; return (
{/* Massive Aurora Background Effect This replaces the simple gradient with deep, colorful glowing orbs */}
{/* Grid Pattern */}
{/* Section Header */}
{/* Glowing Pill */}
Platform Metrics

Corporate-Grade Results,
Quantified.

Transparent performance benchmarks proving reliability, accuracy, and compliance at enterprise scale.

{/* Stats Grid */} {stats.map((stat, index) => ( ))}
); }