'use client'; interface TrendPoint { date: string; score: number; } interface HealthTrendProps { data: TrendPoint[]; } function getColor(score: number) { if (score >= 90) return '#10b981'; if (score >= 75) return '#3b82f6'; if (score >= 60) return '#f59e0b'; if (score >= 35) return '#f97316'; return '#ef4444'; } export function HealthTrend({ data }: HealthTrendProps) { if (data.length < 2) return null; const w = 160; const h = 48; const pad = { top: 4, right: 4, bottom: 12, left: 4 }; const chartW = w - pad.left - pad.right; const chartH = h - pad.top - pad.bottom; const scores = data.map((d) => d.score); const min = Math.max(0, Math.min(...scores) - 5); const max = Math.min(100, Math.max(...scores) + 5); const range = max - min || 1; const points = data.map((d, i) => ({ x: pad.left + (i / (data.length - 1)) * chartW, y: pad.top + chartH - ((d.score - min) / range) * chartH, ...d, })); const pathD = points.map((p, i) => `${i === 0 ? 'M' : 'L'}${p.x},${p.y}`).join(' '); const lastPoint = points[points.length - 1]; const firstPoint = points[0]; const trend = lastPoint.score - firstPoint.score; return (