An action principle for complex quantum trajectories