have a light-bulb moment
To be suddenly struck with or inspired by an ingenious idea, insight, or revelation. He'd been trying to work out the puzzle for nearly an hour, when suddenly he had a light-bulb moment and understood how it fit together. A: "But it was Martin who came up with the remarkable idea that saved out company." B: "What can I say—I had a light-bulb moment."