Phase transition, electronic and optical properties of NaCl under pressure