import { TrendingUp, AlertCircle, Clock, CheckCircle2, Settings2, type LucideIcon } from 'lucide-react'; import { cn, fmt } from '@/lib/utils'; import type { Dollars } from '@/lib/money'; type CardType = 'starting' | 'paid' | 'remaining' | 'overdue'; interface CardDef { label: string; icon: LucideIcon; bar: string; glow: string; borderActive?: string; valueClass: string; activateWhen: (v: number) => boolean; } const CARD_DEFS: Record = { starting: { label: 'Starting', icon: TrendingUp, bar: 'from-slate-400 to-slate-300', glow: '', valueClass: 'text-foreground', activateWhen: () => true, }, paid: { label: 'Total Paid', icon: CheckCircle2, bar: 'from-emerald-500 to-emerald-300', glow: 'shadow-[0_4px_20px_rgba(16,185,129,0.15)]', borderActive: 'border-emerald-400/40', valueClass: 'text-emerald-600 dark:text-emerald-200', activateWhen: (v) => v > 0, }, remaining: { label: 'Remaining', icon: Clock, bar: 'from-blue-400 to-indigo-300', glow: '', valueClass: 'text-foreground', activateWhen: () => true, }, overdue: { label: 'Overdue', icon: AlertCircle, bar: 'from-rose-400 to-orange-300', glow: 'shadow-[0_4px_20px_rgba(251,113,133,0.10)]', borderActive: 'border-rose-400/35', valueClass: 'text-red-500 dark:text-rose-200', activateWhen: (v) => v > 0, }, }; interface TrendInfo { direction: string; percent_change: number; } export function TrendIndicator({ trend }: { trend?: TrendInfo | null }) { if (!trend) return null; const { direction, percent_change } = trend; let icon: string, color: string, text: string; switch (direction) { case 'up': icon = '↑'; color = 'text-emerald-500'; text = `${icon} ${percent_change}%`; break; case 'down': icon = '↓'; color = 'text-red-500'; text = `${icon} ${Math.abs(percent_change)}%`; break; default: icon = '→'; color = 'text-muted-foreground'; text = `${icon} ${percent_change}%`; } return (
{text} vs 3-mo avg
); } interface SummaryCardProps { type: CardType; value?: Dollars; onEdit?: () => void; hint?: string; label?: string; } export function SummaryCard({ type, value, onEdit, hint, label }: SummaryCardProps) { const def = CARD_DEFS[type]; const isActive = def.activateWhen(value || 0); const Icon = def.icon; const displayLabel = label || def.label; return (

{displayLabel}

{type === 'starting' && onEdit && ( )}

{fmt(value)}

{hint &&

{hint}

}
); } export function TrendCard({ trend }: { trend?: TrendInfo | null }) { if (!trend) return null; return (

3-Month Trend

); }