When acidic solution of ephedrine or pseudoephedrine is mixed with copper sulfate and sodium hydroxide solutions, a violet color is formed. Upon shaking with ether, the organic phase turns red/purple and the aqueous phase turns blue. The staining is based on the formation of a coordination complex of two ephedrine molecules and a copper ion Cu
This works, because, in an alkaline solution, the hydroxyl and amine groups are de-protonated, leaving a negative charge on the central atoms. They can then form a coordination complex with the positively-charged cupric ions from the copper sulfate. Phenethylamines (and their derivatives) that have a β-ketone group will also react, but less predictably and dramatically (the carbonyl oxygen is less nucleophilic than the deprotonated hydroxyl group). They usually form a deeper blue color, and often a grey-ish precipitate. This includes the cathinones and presumably βK-2C-x compounds.