We took trains in all those cities, and you must pass thru security. I would say 20 minutes early would be fine in Sevilla and Cordoba (assuming you already have tickets) and for Madrid, if you are using Atocha, the first time you are at the station you may find it big and overwhelming so you might allow more time. That said, when we purchased train tickets at the airport to get to Sevilla, the helpful and pleasant RENFRE employee sold us tickets that allowed about 20 minutes between our train arrival at Atocha and departure at Sevilla. She told us we would be fine and even though the train arrived a few minutes late, we had plenty of time. Are you asking if there are restaurants close to the Cordoba train station, if so, I can't recall anything close, there are a couple faster food restaurants in the station tho I thought the were pricey. Within Cordoba old town there are lots of restaurants and they just start for dinner at 8pm at the earliest though it appeared there was always something open. I thought Madrid was "open" rather late and at 11pm I think you'd find dinner options.