South Africa enjoy upper hand despite Kohli’s fighting knock