legal detainment definition