https://en.wikipedia.org/wiki/Inverse_function
@OP: I read what you wrote, based on the fact that you didn't understand why "the domain restricted to [0, pi]" it led me to conclude you weren't aware that you may have asked Wolfram Alpha for something other than what you thought you did.
Honestly, you need to lose the attitude. People help those who are pleasant to deal with. This forum is for the discussion of Science, my dredging up memories of something I ran into over a decade ago is an optional extra.
If you still want the why the imaginary parts didn't appear then the answer is on the Wiki. I thought my response summed it up fairly succinctly but Wiki certainly has the answer if you feel the need to investigate further.