import { AlertTriangle, CheckCircle2, Info } from 'lucide-react'

const SEVERITY_CONFIG: Record<string, { bg: string; label: string; icon: React.ComponentType<{ className?: string }> }> = {
  critical: { bg: 'bg-red-100 text-red-800', label: 'Kritisch', icon: AlertTriangle },
  high: { bg: 'bg-orange-100 text-orange-800', label: 'Hoch', icon: AlertTriangle },
  medium: { bg: 'bg-yellow-100 text-yellow-800', label: 'Mittel', icon: Info },
  low: { bg: 'bg-green-100 text-green-800', label: 'Niedrig', icon: CheckCircle2 },
}

export function SeverityBadge({ severity }: { severity: string }) {
  const config = SEVERITY_CONFIG[severity] || SEVERITY_CONFIG.medium
  const Icon = config.icon
  return (
    <span className={`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${config.bg}`}>
      <Icon className="w-3 h-3" />
      {config.label}
    </span>
  )
}

export function StateBadge({ state }: { state: string }) {
  const config: Record<string, string> = {
    draft: 'bg-gray-100 text-gray-600',
    review: 'bg-blue-100 text-blue-700',
    approved: 'bg-green-100 text-green-700',
    deprecated: 'bg-red-100 text-red-600',
    needs_review: 'bg-yellow-100 text-yellow-800',
    too_close: 'bg-red-100 text-red-700',
    duplicate: 'bg-orange-100 text-orange-700',
  }
  const labels: Record<string, string> = {
    needs_review: 'Review noetig',
    too_close: 'Zu aehnlich',
    duplicate: 'Duplikat',
  }
  return (
    <span className={`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${config[state] || config.draft}`}>
      {labels[state] || state}
    </span>
  )
}

export function LicenseRuleBadge({ rule }: { rule: number | null | undefined }) {
  if (!rule) return null
  const config: Record<number, { bg: string; label: string }> = {
    1: { bg: 'bg-green-100 text-green-700', label: 'Free Use' },
    2: { bg: 'bg-blue-100 text-blue-700', label: 'Zitation' },
    3: { bg: 'bg-amber-100 text-amber-700', label: 'Reformuliert' },
  }
  const c = config[rule]
  if (!c) return null
  return <span className={`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${c.bg}`}>{c.label}</span>
}
