Turkish authorities have detained the lawyer defending jailed Istanbul Mayor Ekrem Imamoglu, President Tayyip Erdogan's biggest political rival.