A powerful 7.7 magnitude earthquake has struck Panama, collapsing buildings and prompting evacuations.