From the 16th to 19th centuries , Montenegro became a theocracy ruled by a series of bishop princes ; in 1852 , it was transformed into a secular principality .