Hello, and welcome.
I'm sorry your daughter is in this situation.
Is the image that she drew in school, the same as, or related to the inappropriate Littlest Pet Shop video made by an adult on her tablet? Do you mean that an adult had use of her tablet to place the videos there, or she went to a site and found that material?
Find out if you can buy a program for a tablet (or if it comes with it) with parental controls/locks, so she can't view particular sites by inputting certain words, etc., so only you can control what she views on her tablet, computer, phone (if she has one), etc. Taking her tablet away from her for a specified amount of time was a good move on your part, and a good consequence for her action.
As far as the punishment for the school incident, in addition to the school's punishment, of detention, I would take away certain privileges she enjoys, like TV, computer and/or tablet use (only if necessary for schoolwork and under your supervision), phone, and play dates with friends, for about a week.
A letter of apology is a great idea, and I would definitely try to get to the bottom of her story, regarding a friend of a girl that bullied her last year, 'made' her draw the picture and hand it to the boy. If your daughter is being bullied, this is very serious and must be reported to her teacher and the school administration.
You said many good things to her, but I would not mention anything about a boy following her into the restroom, etc., because that will make her afraid to go to the restroom. You CAN explain to her that her actions DO reflect the way others view her and that's why it's so important to always do the right thing and develop a reputation where people think well of you and don't think badly of you.
Have you had the 'birds and the bees' talk with your daughter and does she know about sex? If not, this would be a good age to start speaking to her about this; if so, she probably understands the basics, but her information should not come from friends or the internet, etc., because it's usually not correct.
I'm glad that you also talked to her about not doing what other people tell her, and being her 'own' person, making correct decisions on her on, based on HER values and what she has been taught at home. Tell her if anyone threatens her if she won't do something she doesn't want to do, she needs to tell you and her teacher, right away.
I hope this helped and things will improve!
Please be so kind as to rate my answer with positive feedback so I receive credit for my assistance. Thank you.
Rating will not cut off our communication and you can click 'Reply' at any time to ask for any clarification or additional information.