HC directs State to pay compensation to man for illegal detention