I notice that you don't have Granada and the AMAZING Alhambra on your itinerary. The Alhambra is a very important cultural and historical site, and is absolutely stunning! I can't imagine going to Andalucia and not seeing the Alhambra.
When is your trip? Keep in mind that Andalucia is VERY VERY HOT during the summer. Spring and fall would be a better time to visit.
I have been to all the places on your itinerary except for Mallorca. I assume you want some island/beach time so I won't suggest you delete Mallorca from your trip.
If it were my trip, I would omit Barcelona from your itinerary and save it for another trip to Spain. Based on my first-hand experience, I think it's better to spend 1 or 2 nights in Toledo and the same for Cordoba. Both places are so wonderful and charming at night when they are illuminated and the daytrippers and tour buses have left.
So, I would take the 3 nights from Barcelona and spend 2 nights in Granada and 1 night either in Toledo or Cordoba. That means you will see one of these places as a day trip, which isn't ideal but is better than not seeing it at all.
Can you add an extra night or two to your trip? If so, spend 2 nights in Cordoba and at least one night in Toledo, along with the 2 nights I suggest for Granada.
A second trip to Spain, and I am sure you will want to return, could be to Barcelona, Girona, and the Costa Brava. We spent 6 nights in Barcelona and still did not see everything. And as you state, you want time for wandering and exploring, too.