Democrats have won control of US Congress in a widespread repudiation of President Donald Trump and the Republican Party.