import { Server, Wifi, AlertTriangle, Activity } from 'lucide-react'
import { Card, CardContent } from '@/components/ui/card'
import { useAnimatedCounter } from '@/hooks/useAnimatedCounter'
import { cn } from '@/lib/utils'
export interface KpiCardsProps {
totalDevices: number
onlinePercent: number // 0-100
activeAlerts: number
totalBandwidthBps: number // bytes per second
}
/**
* Formats bytes-per-second into a human-readable bandwidth string.
* Auto-scales through bps, Kbps, Mbps, Gbps.
*/
export function formatBandwidth(bps: number): { value: number; unit: string } {
if (bps < 1_000) return { value: bps, unit: 'bps' }
if (bps < 1_000_000) return { value: bps / 1_000, unit: 'Kbps' }
if (bps < 1_000_000_000) return { value: bps / 1_000_000, unit: 'Mbps' }
return { value: bps / 1_000_000_000, unit: 'Gbps' }
}
interface KpiCardProps {
icon: React.ReactNode
label: string
value: number
suffix?: string
decimals?: number
colorClass: string
highlight?: boolean
}
function KpiCard({
icon,
label,
value,
suffix,
decimals = 0,
colorClass,
highlight,
}: KpiCardProps) {
const animatedValue = useAnimatedCounter(value, 800, decimals)
return (