I don't think it was stupid. Look at the alternatives. You looked for a used replacement and came up empty. Even if you had found something, it may have also needed repairs/maintenance. You could also bought a new bike, which certainly would cost you more than $500 and if used the same way as your old bike, would eventually need maintenance/repairs.
If you like the bike and use it, I don't see anything wrong in putting some money into it.
If you really want to save money, consider investing in some tools and learning to do some basic maintenance/repairs on your own. Replacing a cassette, cables, and some of the other work you mention is not that difficult and would save you a bunch.