type ThreatLevel = 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW' | 'NORMAL' | 'KNOWN_BOT';

const BADGE_STYLES: Record<ThreatLevel, string> = {
  CRITICAL:  'bg-red-900/50 text-red-400 border border-red-800/50',
  HIGH:      'bg-orange-900/50 text-orange-400 border border-orange-800/50',
  MEDIUM:    'bg-yellow-900/50 text-yellow-400 border border-yellow-800/50',
  LOW:       'bg-green-900/50 text-green-400 border border-green-800/50',
  NORMAL:    'bg-slate-700/50 text-slate-400 border border-slate-600/50',
  KNOWN_BOT: 'bg-purple-900/50 text-purple-400 border border-purple-800/50',
};

interface ThreatBadgeProps {
  level: string;
}

export default function ThreatBadge({ level }: ThreatBadgeProps) {
  const key = (level?.toUpperCase() ?? 'NORMAL') as ThreatLevel;
  const cls = BADGE_STYLES[key] ?? BADGE_STYLES.NORMAL;
  return (
    <span className={`text-xs px-1.5 py-0.5 rounded font-medium uppercase ${cls}`}>
      {level || 'NORMAL'}
    </span>
  );
}
