Say Lucario uses Swords Dance. Does the +Atk last forever, or just until the battle ends?
It only lasts until the Pokemon faints or is switched out. Think about how ridiculously powerful it would be otherwise. What if that Lucario used three Swords Dances on an opponent that posed no threat, then the battle ended? It would be easy to steamroll the game past that.
Source: This and experience
Hope I helped!
Just until the battle ends.
All positive and negative stat changes are temporary.