interface Props { label: string; className?: string }

export function Badge({ label, className = "" }: Props) {
  return (
    <span className={`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${className}`}>
      {label}
    </span>
  );
}

const STATUS_STYLES: Record<string, string> = {
  active:      "bg-green-100 text-green-800",
  maintenance: "bg-yellow-100 text-yellow-800",
  paused:      "bg-gray-100 text-gray-600",
  archived:    "bg-red-100 text-red-700",
};

const PRIORITY_STYLES: Record<string, string> = {
  high: "bg-red-100 text-red-700",
  mid:  "bg-blue-100 text-blue-700",
  low:  "bg-gray-100 text-gray-500",
};

const STATUS_LABELS: Record<string, string> = {
  active: "进行中", maintenance: "维护中", paused: "暂停", archived: "已归档",
};
const PRIORITY_LABELS: Record<string, string> = {
  high: "高", mid: "中", low: "低",
};

export function StatusBadge({ status }: { status?: string }) {
  const s = status ?? "active";
  return <Badge label={STATUS_LABELS[s] ?? s} className={STATUS_STYLES[s] ?? "bg-gray-100 text-gray-600"} />;
}

export function PriorityBadge({ priority }: { priority?: string }) {
  const p = priority ?? "mid";
  return <Badge label={PRIORITY_LABELS[p] ?? p} className={PRIORITY_STYLES[p] ?? "bg-gray-100 text-gray-500"} />;
}
