I also suggest Zaragoza, located in the shadow of the Pyrenees, Zaragoza was once the seat of the mighty Kingdom of Aragon, whose possessions included southern France, Sicily, and even Greece during the middle ages. More importantly for you it's well connected to both Madrid and Bilbao lol!
These days Zaragoza is a charming city to explore with more than 2,000 years of history including Roman ruins of the city walls, forum, and amphitheater, and the Aljafería; an 11th-century Moorish palace, the most northern Islamic palace in Europe. Throughout Zaragoza you'll find Mudéjar architecture, a unique mix between Moorish and Christian styles and motifs. Zaragoza is also the home to the Nuestra Señora del Pilar Basilica, which has one of the best church exteriors in Spain.
I think that Zaragoza is one of those undiscovered gems that Rick Steves calls "back doors". It reminds me a lot of Barcelona before international mass tourism really took off. Virtually unknown to foreign tourists, who just zoom past it on the highspeed train from Barcelona to Madrid.
I recommend Hotel NH Ciudad de Zaragoza, an incredible location for a very reasonable price, directly overlooking the Pilar Basilica and the old Roman walls, in the old town. Recently renovated and very modern. The best area for tapas in Zaragoza is a neighborhood called El Tubo (https://www.spain.info/es/lugares-interes/barrio-el-tubo/). Another good place to eat is a Gourmet Food Market off the Plaza de España, called Puerta Cinegia Mercado.
2-3 nights should be good for Zaragoza.