A rough outline could be:
Four nights in madrid including a day trip to Toledo
Catch the AVE train to Seville for a four night stay. Your option on stopping in Cordoba along the way.
Train or bus to Granada for a three night stay. Carefully research alhambra ticket purchase.
Fly from granada to Barcelona for a six night stay including opportunities to day trip to Montserrat or other locals.
Thoughts:
This is broad brushed to form a framework for discussion.
It is very hot in july so i advocate slowing down and accounting for some lost energy due to the heat. Stay hydrated! Also take advantage of adopting to Spanish life by staying up late with them. Cooler and more fun.
For a better value we stay in apts, examine airbnb to learn the benefits of doing so. You will be on the road a long time so having the room to spread out, have a kitchen and maybe a washer could be of added benefit. You could also choose to rent private rooms to save money and meet locals (very beneficial to learning local tips on places to go)
Pack light, really light! It is a real drag to haul around luggage, especially alone. Have fun and purchase clothes while on your trip. This makes for great fun and better souvenirs.
To obtain some great help from experienced travelers will you please address the following questions?
How many times have you been to Europe?
Your preferred style of travel (at a gallop, slow and leisurely, activities, museum lover, foodie????)
Define your concerns about traveling alone.
A range of your age
What is the primary impetus/goal for selecting spain?
What has been your best memory from a prior journey?