There is so much to see and do in and around Barcelona that I would save it for a future trip. There is more than enough to enjoy in Andalucia and Madrid for the time you have. Here's my suggestion:
8th - go to Cordoba by train. 2 nights
10th - train to Sevilla. 2 nights
12th - rent car. drive through hills, overnight in Ronda
13th - drive through hills to Granada and return car. 2 nights
15th - train to Madrid.
That gives you 3 nights to "play with" spending your last night in Madrid for your flight home. I'd add 2 nights in Sevilla, 1 in Ronda. This pretty much means skipping Madrid. In January the parks and gardens there won't be much to see and the big draw is the great art museums, which you don't list as a priority.
Spending an extra night in Ronda gives you time to explore more of the hill towns by car. Ronda itself has enough sights to fill up a day, so you could even spend 3 nights there. 3-4 nights in Sevilla gives you time to see the sights there and take a day trip to Jerez by train to see a horse show at the Royal Equestrian School (check their website - the shows are only 2-3 days a week) and tour a sherry bodega (Tio Pepe is the most fun) and/or a day trip to Cadiz.