Prisons chaos fuels massive legal costs as violence surges