Optimizing mode transition sequences in idle intervals for component-level and system-level energy minimization