Long-time asymptotics and stability for the sine-Gordon equation