Hi i would reckon somewhere like Asilah in Morocco, its very quiet and yet pretty much everything you need is nearby, clean and interesting medina, both moroccan and european which ever feeling youre wanting at the time , lovely coast line and eating out is cheap and excellent with seafood and also excellent fruit and vege souks brought in fresh by the local growers.
It also has good internet connections, i use the cybercafe frequently and always get fast connection/usage.
It has a small hospital for minor complaints or Tangier is only 45 mins away and Spain is only an hour away by ferry from Tangier.
Nice walks along the coast line too.
Its quiet and people leave you alone if you wish, and as stimulating as you wish - you may want to attend any art events at the international gallery conference centre.
and there is the international arts festival there every july.
and longterm you can rent a nice selfcontained apartment - large spacish, tv etc for as low as £10 a night. let me know and i have contacts who can find you choices. we stay there frequently and have always got somewhere even when we turn up at 11pm at night.
And its all only 45 minutes from what you might want at Tangier or the ferry terminal back to spain and flights from Gibraltar or Malaga which can be very cheap with Monarch, British Airways or Easyjet.
Its also on the trainline so if you want to jump on a train to Marrakech, Casablanca, Rabat or Fes.... and lots of grande taxis and buses to get around to say places like wonderful Chefchouen.