A cruise ship passenger who was raped by a crew member — before he tried to throw her overboard — was beaten so viciously that she looked like she was "painted in blood from head to toe," prosecutors said in court Tuesday.

The 31-year-old woman was sexually assaulted, punched and choked with electrical cords during a Valentine's Day attack on a weeklong cruise that left Port Everglades on Feb. 9, authorities said. She eventually managed to escape when fellow passengers banged on her door in answer to her screams for help.

The ship doctor, a 40-year veteran emergency room physician, told FBI agents that the woman was so severely injured he thought she might die.

"In his 40 years, he had not seen such a violent attack," Assistant U.S. Attorney Francis Viamontes said. "Every witness who saw her said she was completely covered in blood."

Ketut Pujayasa, 28, who is charged with attempted murder and aggravated sexual abuse, stared down at the table in front of him for most of the hourlong hearing in federal court in Fort Lauderdale. Shackled and dressed in beige jail scrubs, he spoke only once, confirming to the judge that he understood what was happening in court.

U.S. Magistrate Judge Barry Seltzer ordered that Pujayasa will remain detained without bond after hearing graphic and disturbing testimony. He ruled that Pujayasa is a flight risk and a danger to society.

Pujayasa, an Indonesian citizen who was immediately fired from his job as a room service attendant for Holland America Lines, told FBI agents that he tried to kill the woman. He also said that he raped her to exact revenge for insulting his mother in a comment he claimed he heard her utter from behind her stateroom door, agents said.

Pujayasa said he went to deliver breakfast to the woman's stateroom around 7 a.m. on Feb. 13 and, on his third knock, believed that he heard her say: "Wait a minute, son of a bitch!"

He said he seethed over the comment for close to 17 hours before letting himself into the woman's stateroom, hiding on her balcony and attacking her as she fell asleep.

FBI Agent David Nunez testified that Pujayasa confessed to his roommate, gave a written statement confessing his crimes to ship security who detained him onboard and gave an extensive interview to the FBI when the ship returned to Broward County on Feb. 16. The assault took place in international waters off the coast of Honduras, officials said.

Pujayasa told the FBI that he was particularly angered by the passenger's comment because it insulted his family, Nunez said.

"He made it very clear that he is not easily insulted, that you can call him whatever you want, but that it is not OK to disrespect his family," Nunez said.

Pujayasa told the agents that he was accustomed to personal insults and verbal abuse from rude passengers but lost it over what he said was an insult to his family.

"He made that point over and over again, that it wasn't about insulting him, it was about insulting his family — especially his mother," Nunez said.

When the victim was later shown Pujayasa's passport photo, she told agents she was "70 percent" sure he was the man who attacked her in her dark cabin. Prosecutors said they have a wealth of other evidence — including his confession and pending DNA test results they expect will confirm he was the attacker.

Pujayasa, who is married and lived with his wife, parents and three siblings in Indonesia, had no prior criminal history in the U.S. or his native country, officials said.

Hired in 2012, he worked on the MS Nieuw Amsterdam, which sailed out of and returned to Fort Lauderdale's Port Everglades. His joint business worker and tourist visa, which allowed him to work on U.S. cruises, has been revoked, authorities said.

If convicted, he faces up to life in federal prison and would be deported if he ever gets out of prison.

Officials from the Indonesian consulate, who were in court, politely declined to comment.

Assistant Federal Public Defender Chantel Doakes tried, unsuccessfully, to persuade the judge that Pujayasa should be released on bond. He has no prior record of violence, inappropriate sexual conduct or even complaints about his job performance, she said.

"He was the one who turned himself in [to authorities]," Doakes told the judge, suggesting Pujayasa may have just snapped in response to one incident. "He does not appear to be a continuing danger to the community."

Viamontes said the fact that "something as innocuous as a statement from behind a closed door set this man off" was proof enough he should remain locked up in the Broward County Main Jail.

"It's hard to think of a case where it's more obvious that a person is a danger to the community," Viamontes said. "Yes, he was cooperative and luckily [the victim] survived … but that does not make this man safe to unleash on our community or on any community."

Agents said Pujayasa, who is 5 feet 2 inches tall and weighs 140 pounds, inflicted a horrific beating and sexual assault on the woman, a U.S. citizen identified only by her initials in court.

He said he fell asleep on her balcony while waiting for her to return, remained hidden until she lay down and closed her eyes, then violently attacked her, agents said.

He told them he used a laptop and other random objects he grabbed in the dark cabin to beat the victim, and wrapped a curling iron cord and phone cable around her neck, investigators said.

During the assault, he dragged her by her hair from her bed to the balcony, tried to throw her overboard from the moving vessel so her body would not be found, then dragged her back into the stateroom when he couldn't quite manage to force her over the railing.

The room, the balcony and the doors that lead to it were all smeared with blood, agents said.

They said the woman, who is about 5 feet 6 inches tall and has a "medium fit build," fought hard to defend herself, stabbing at her attacker with a corkscrew she managed to grab. She told them she bit the man's right hand when he put it in her mouth to try to stifle her screams for help, and agents said she left a visible bite mark on Pujayasa.

Passengers who heard pandemonium erupt in the woman's state room began pounding on her door, trying to help her. Pujayasa told agents he was distracted by the repeated knocking, and the woman said she was able to break away from him and ran out into the hallway.