Period and sex talk with daughter!!

At what age did you have that talk with your daughter. My mom never had that talk or THE talk with me so when I was 9 I went to the bathroom and was bleeding I freaked out thinking in dying cuz I didn't know what is was, now I have a 9 year old and I'm talking to her about her period but I'm not sure how to talk to her sex and how far into detail I should go. And suggesting.