In Germany, unusually even for Europe, this is solved for civil cases by assigning a fixed fee per case that lawyers and the court itself must adhere to - they can't go below, they can't go above - depending on the claim value, usually around 5-10% of the claim itself in total for all three parties.
This is still nasty for the less advantaged individuals when faced with a claim that could lead to, say, a $10k maximum fee, but for smaller businesses any reasonable claim amount is still affordable and the "drain the other party's legal funds" tactic is practically outlawed.