A weighted anisotropic variant of the Caffarelli–Kohn–Nirenberg inequality and applications