Hello,
Firstly, I want to stress that you were completely fine to kill the detective, it was self-defense. However, the fact of the matter is you still shot at and killed a detective, which is probably the most traitorous thing you can possibly do, so anyone can kill you for doing it. Killing a detective as a non detective is
always kosable.
If you had reported the detective in-game, he probably would have been punished as it does seem to be RDM on his part, but you didn't. Insanity killed for because you killed a detective, which is a valid KOS reason, therefore this had been denied.