Sant Pol de Mar is about an hour up the coast by train from Sants station.
Sant Pol de Mar is not really the Costa Brava. You have to go a bit more to the north for that. The closest you can get by train is Blanes. (There the train turns inland.)
At Blanes the coast changes from sandy beaches to the typical rocky coastline of the Costa Brava. So you can stay and eat in Blanes or take a bus to one of the next towns on the coast (for the real Costa Brava).