For example, if apple get a patent on an idea, and I already had that idea and didn't get a patent for it, and I went ahead and open a company that makes a product based on my idea, can apple sue me for intellectual property infringement? Even if I didn't steal their product secret, but I used my idea to make a product similar to apple's.
If, in your example, Apple filed for the patent before you commercialized your idea then yes you can be sued for infringement. It doesn't matter if you thought of the idea independently or even before the patent filing. If, however, you commercialized or even publicly disclosed your invention prior to Apple's patent application date, then it would constitute prior art and could invalidate the Apple patent. You could still be sued, but would likely win in court.
I should point out that infringement means implementing each and every step of at least one claim in a patent. People often over estimate how broad patents are. Long claims are actually considered narrower than short ones. As always, I suggest consulting with an actual patent attorney in matters of freedom to operate.
Eric's answer is generally correct, except that you used a term in your question and I want to respond to that particular term.
Patent applications, by their very nature, are not "secret". If Apple had filed an application, there would be nothing "secret", except during the period of time between when the application is filed and when it is published.
On a side note, an "idea" isn't patentable. What is patentable is a specific embodiment of that idea. "Ideas" are often the easy part, the hard part is devising a solution to whatever problem the "idea" is attempting to solve. I was once a part of a patent team which authored several dozen applications all of which solved the same problem, based on a single "idea". So, if your "idea" has multiple implementations, all of which meet the basic patentability tests, your implementation of the "idea" would be patentable.