'use client';

import { ShieldCheck, Sparkles } from 'lucide-react';
import { cn } from '@/lib/utils';
import { PublicUser } from '@/lib/api';
import { getPrimaryRoleLabel } from '@/lib/admin-access';

export function AdminBadge({ user, className }: { user: PublicUser; className?: string }) {
  if (!user.isSuperAdmin && !user.canAccessAdmin) return null;

  const label = getPrimaryRoleLabel(user);

  return (
    <span
      className={cn(
        'inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-semibold',
        user.isSuperAdmin ? 'bg-gradient-to-r from-[#20212b] to-[#3d4255] text-white shadow-sm' : 'bg-[#eef4ff] text-[#1d4ed8]',
        className
      )}
    >
      {user.isSuperAdmin ? <Sparkles className="h-3.5 w-3.5" /> : <ShieldCheck className="h-3.5 w-3.5" />}
      {label}
    </span>
  );
}
