you need to pass your medical in the country in which you are going to study for you pilot licences.
Spain is fully Jar-fcl3.
You can do your initial one at Madrid, or at Barcelona only.
There are some psychometric test as well. nothing very difficult but some people still fail at this stage.
I think it will cost you at least 500 euros.
good luck !