You plan on going to Seville, in Spain as well as Portugal?
I suggest saving Seville when you do Spain later.
Since you plan to do Portugal from the Algarve to Porto in the north, you will need those 18 days.
4-5 days in the Algarve.
Consider 4-5 days in Lisbon, with a day trip to Evora and Sintra.
Then on your way to Porto, take in Obidos, Batalha Cathedral, Coimbria and perhaps Nazare.
After a couple of days in Porto (Consider the amazing InPatio Guesthouse for lodging), spend a few days in the Douro River Valley. It is very impressive. We did a wonderful seven day river cruise there. If you don't want to do that take the train up the river to Pinhao and/or Regua.
If you want to go a bit farther just over the border in Spain and the city of Salamanca, that is worth a day trip.
Further, you could add a day in Porto to do a day trip to Santiago de Compostela just over the border north of Porto.