Spain declares a national emergency as millions of people are left without power amid chaotic scenes.