Non-autonomous Dynamics in Complex Systems: Theory and Applications to Critical Transitions