look (off) into space
To stare vacantly or absentmindedly at nothing in particular, usually while one is preoccupied with or distracted by thoughts of something else. I sat at the back of class, looking off into space, when suddenly the solution came to me. He just looked into space as his parents lectured him on the importance of paying attention during class.