You do have rigid kind of thinking
Democracy in principle is the same like Consultation defined in Quran talking about how problem should be solved which is to include consultation system, which tell about discussion among society. Quran doesnt talk about who should be the actors during the consultation process, so it shows Quran understand the way consultation system is implemented can be vary.
Madinah state for instant is similar like what happen in ancient Greece during their democracy where one prominent city become the main political actors which is in this regard talking about two main power within the society which are Anshar and Quraish Tribe. These are represent of people, not chosen Ulama in many way. This is why I ask you to read Muhammad biography, there was Anshar leader that wants to be leader competing Abu Bakr and he is political leader, not Ulama in the way you think.
Consultation can be in many form, it is ridiculous to implement Today democracy during 7 century in Arabia, but in principle is the same, this is why the political actors during that period are prominent members in both Quraish and Anshar clan ( tribe ), and prominent members in each clan of course are chosen by people as well in traditional term, don think there will be voting machine like Today LOL