Microscopic theory of hot-carrier relaxation in semiconductor-based quantum-cascade lasers