Engineering the electronic structure and optical properties of g-C3N4 by non-metal ion doping