My best advice: have an independent lawyer from day one — not one recommended by the agency or seller.
They should review the agency contract, the arras (deposit) contract, check the property registry for debts/encumbrances, verify Catastro vs. Registry, habitability license, and that community fees and taxes are up to date.
This alone can save you a lot of headaches later.