First, merely having a thought or temptation go through your mind isn't a sin. Martin Luther once said, "You can't stop the birds from flying over your head but you can keep them from building a nest in your hair" This corrupt world and our own fallen natures constantly work together trying to lure us into sin and the only solution is to seek a renewal of the mind as in Rom12:1-2 "I appeal to you therefore, brethren, and beg of you in view of all the mercies of God, to make a decisive dedication of your bodies as a living sacrifice, holy and well pleasing to God, which is your reasonable service and spiritual worship. Do not be conformed to this world but be transformed by the renewal of your mind, so that you may prove for yourselves what is the good and acceptable and perfect will of God, even the thing which is good and acceptable and perfect in His sight for you."
This is accomplished thru God's Word as stated in Eph5:25-27 "Christ loved the church and gave Himself up for her, so that He might sanctify her, having cleansed her by the washing of water with the Word, that He might present the church to Himself in glorious splendor, without spot or wrinkle or any such things." This requires our cooperation with the Holy Spirit as Rom8:12-15 spells out: "So then, brethren, we are debtors, but not to the flesh, to live of the flesh. For if you live according to the dictates of the flesh, you will surely die. But if through the power of the Holy Spirit you put to death the evil deeds prompted by the body, you shall genuinely live forever. For all who are led by the Spirit of God are sons of God. For the Spirit which you have now received is not a spirit of slavery to put you once more in bondage to fear, but you have received the Spirit of adoption in which we cry, Abba! Father!"
This brings us to blasphemy of the Holy Spirit (the unforgivable sin) which is defined by Christ in verses such as Mk3:28-30 "Truly and solemnly I say to you, all sins will be forgiven the sons of men, and whatever abusive and blasphemous things they utter; But whoever speaks abusively against or maliciously misrepresents the Holy Spirit can never get forgiveness, but is guilty of and is in the grasp of an everlasting trespass. For they persisted in saying, He has an unclean spirit." and Mt12:31-32 "Therefore I tell you, every sin and blasphemy can be forgiven men, but blasphemy against the Holy Spirit shall not and cannot be forgiven. And whoever speaks a word against the Son of Man will be forgiven, but whoever speaks against the Spirit, the Holy One, will not be forgiven, either in this world and age or in the world and age to come."
He's speaking about those who have rejected the voice of the Holy Spirit as He testifies of the Truth for so long and are so hardened that they regard His voice to be that of Satan. When someone reaches that condition they can no longer be saved - and the only time I've ever encountered this condition is during exchanges with hardened Calvinists who have openly told me, "Anyone who says that God loves all people and that Christ died for everyone is speaking by the devil" Those who reach that hardened condition can never be saved no matter what you say to them - they're caught in an eternal trespass. From what you posted here, this doesn't remotely apply to you - just come before God, confess your past failures, surrender your life to Him, ask Him to reveal His will for you and to give you the strength to follow it when He does. You'll be just fine (unless you think Satan prompted this answer!).