interface SellerChipProps {
  name?: string;
  logo?: string | null;
}

/**
 * Small brand chip (logo + name) shown over a product card's image overlay.
 * Renders nothing when there's no seller name. Falls back to the seller's
 * initial when no logo is available (e.g. before the backend exposes it).
 */
export default function SellerChip({ name, logo }: SellerChipProps) {
  if (!name) return null;
  return (
    <div className="flex items-center gap-1.5 mb-1 min-w-0">
      <span className="w-[15px] h-[15px] rounded-full overflow-hidden border border-white/40 bg-white/20 shrink-0 grid place-items-center text-[8px] font-bold text-white">
        {logo ? (
          <img
            src={logo}
            alt=""
            className="w-full h-full object-cover"
            onError={(e) => {
              e.currentTarget.style.display = "none";
            }}
          />
        ) : (
          name.trim().charAt(0)
        )}
      </span>
      <span className="text-white/85 text-[10.5px] truncate">{name}</span>
    </div>
  );
}
