South Carolina agrees to major mental health changes after civil rights probe