Geneva - The UN human rights chief warned on Thursday that serious violations were "endemic" in many detention centres in Libya, but said he was "optimistic" that authorities were intent on improving the situation.Zeid Ra'ad Al Hussein, who this week became the first UN rights chief to make an official visit to Libya, welcomed commitments he received from authorities, including Prime Minister Fayez Serraj, and the ministers of Justice and Interior, to address a wide range of abuses.But he warned that "the human rights situation in Libya continues to be marked by widespread abuses and violations perpetrated by all sides to the conflict with complete impunity".Libya has plunged into chaos since the overthrow of longtime dictator Muammar Gaddafi in 2011, with dozens of armed factions, filling the power vacuum.MigrantsThe country has also become the main launchpad for African migrants trying to reach Europe across the Mediterranean in boats operated by smugglers, but many of the migrants are also detained in the country, reportedly in horrific conditions.In addition to his meetings with members of Libya's government, Zeid said he had met with civil society and women's human rights groups, and had visited one of the country's main prisons and a camp for displaced people during his one-day visit on Tuesday."Thousands of people are held arbitrarily in detention centres across the country, some since the 2011 armed conflict, many subjected to torture and ill-treatment," he said."Armed groups unlawfully kill and hold hostage civilians and combatants. Civilian men, women and children are killed and injured every week by the indiscriminate use of weapons," he added.'Horrific'Zeid especially stressed the "horrific" reports emerging from a number of detention centres, including the Mitigia detention centre."The situation there needs to be addressed urgently, as do other facilities where abuses are endemic," he warned.Zeid acknowledged that "the large-scale near-collapse in the justice system, the power and influence of armed groups, and the many challenges faced by the government are real".But he insisted that there was still much the government could do to improve the situation, urging it to "halt the practice of arbitrary detention, and to ensure accountability for the abuses perpetrated against migrants in detention centres".He said authorities had told him one of the detention centres in Surman, where there have been serious allegations of sexual abuse, had been closed, stressing that his office was working with the government to confirm that this was the case."The human rights challenges in Libya are massive, but they are not insurmountable," Zeid said.