Rishabh Pant hits century as South Africa fight back in third Test