South Africa's top court rules against president in scandal