Assalamu Alaikum Warahmatullahi Wabarakatuhu, Lately I have been having thoughts of shirk pop into my head. The other day I was daydreaming and imagining myself talking to someone and In my mind I swore by something other than Allah which is shirk, except it wasn’t intentional I was just imagining me talking to someone and then all of a sudden I swore by something other than Allah. It just popped into my head as soon as I had the thought I started saying “Astaghfirullah”. Nothing was intentional and it keeps happening to me and replaying in my head. Have I committed shirk?
Alsalam alikum brother/syster the prophet [pbuh] once got asked if we sre judged by our thoughts and he said
"Allah [swt] has forgiven my ummah for there thoughts as long as thry don't say or do by that"
so if you get any bad thoughts it is okey the only importent thing is to take refuge by Allah from the Devil and to not react on it or do anything about it.