A good idea came to me.

Literal

Good idea [subject-が] floated-up-に.

浮かぶ ('to float, come to the surface, come to mind') is used with 考え ('idea, thought') for the classic 'an idea came to me' metaphor — ideas 'surface' in the mind. The ga-marker presents the idea as new information.