Fermat's Little Theorem says that, if p is prime, then a^p = a mod p. You can take complex numbers mod p as well, but for them, the little theorem fails.
More specifically, for p > 2, if c = (a, b), then c^p = c mod p iff p is of the form p=4n+1. If p=4n+3, then c^p = c conjugate mod p. In this context, the conjugate of c is (a, p-b).
Why? Because i^4n+1 = i, but i^4n+3 = -i. The rest follows from the binomial proof of the little theorem (see https://en.wikipedia.org/wiki/Proofs_of_Fermat%27s_little_theorem).
It is a theorem that if every prime p of the form 4n+1 can be written as a sum of two squares: 5 = 1 + 4, 13 = 4 + 9, etc. Conversely, no prime of the form 4n+3 can be (reduce it mod 4).
Let Z[i] be the set in which you're doing arithmetic, of complex numbers of the form a + bi, where a,b are both integers. These are called the Gaussian integers [1].
If p = a^2 + b^2, then p = (a + bi)(a - bi) in the Gaussian integers. So that means that whenever p=4n+1, p is no longer prime in Z[i]. So you shouldn't expect the machinery of Fermat's little theorem to work. Conversely, any prime p=4n+3 is still prime in this bigger set, and so the machinery underlying Fermat's little theorem still works.
The rabbit hole goes very deep :)
[1] https://en.wikipedia.org/wiki/Gaussian_integer