Assume that the prime factorization of a natural number $n$ is
$$
n=2^a\prod_{i, p_i\equiv-1\pmod4}p_i^{s_i}\prod_{j,p_j\equiv1\pmod4}p_j^{r_j}.\qquad(*)
$$
We need the multiplicativity of the norm $N(u+vi)=(u+vi)(u-vi)=u^2+v^2$ and the known splitting behavior of rational primes in $\Bbb{Z}[i]$. Namely:
- $2$ ramifies and is up to a unit factor equal to $(1+i)^2=2i$, where $1+i$ is a prime of $\Bbb{Z}[i]$.
- If $p\equiv-1\pmod4$, then $p$ is also a prime of $\Bbb{Z}[i]$.
- If $p\equiv1\pmod4$, then $p$ factors as $p=(a+bi)(a-bi)$ for some two primes $a\pm bi$ of $\Bbb{Z}[i]$. Here $ab\neq0$.
Let's look at the three factors on the r.h.s. of $(*)$, call them $n_1,n_2,n_3$, individually.
- If $n_1=2^a$ and $n=u^2+v^2$, then $N(u+vi)=2^a$. Unique factorization in $\Bbb{Z}[i]$ implies that $u+vi=i^k(1+i)^a$. We easily see that if $a$ is even, then either $u=0$ or $v=0$. But if $a$ is odd, then $|u|=|v|$. The conclusion is that $2^a$ is always a sum of two squares, but a sum of two non-zero squares iff $a$ is odd.
- If $n_2=\prod_{i, p_i\equiv-1\pmod4}p_i^{s_i}$ it is well known that $n_2$ is a sum of two squares iff it is a square (i.e. if all the exponents $s_i$ are even). Furthermore, $n_2$ cannot be a sum of two non-zero squares in this case.
- If $n_3=\prod_{j,p_j\equiv1\pmod4}p_j^{r_j}$. Then each of the primes $p_j$
is a sum of two squares: $p_j=(a_j+ib_j)(a_j-ib_j)=a_j^2+b_j^2$, $a_jb_j\neq0$. Consider the product
$$u+iv=\prod_j(a_j+ib_j)^{r_j}.$$
I claim that if $n_3>$ both $u$ and $v$ are non-zero. This follows from the UFD-property. For if $uv=0$ then $u+iv$ and $u-iv$ are associates in $\Bbb{Z}[i]$, i.e. their ratio is a power of $i$. But,
$u-iv=\prod_j(a_j-ib_j)^{r_j}$, and for all $j$ the primes $a_j+ib_j$ are $a_j-ib_j$ are non-associates, so $uv=0, n_3>1$ violates uniqueness of factorization of the Gaussian integer $u+iv$. The conclusion is that if $n_3>1$ it is a sum of two non-zero integers.
We need to put these pieces together. Fermat's theorem (see the above link, but we actually got that as a by-product) states that $n$ is a sum of two squares, iff $n_2$ is a square. I claim that
$n$ is a sum of two non-zero squares, iff $n_2$ is a square and either $n_1$ or $n_3$ is a sum of two non-zero squares.
If $n_1$ or $n_3$ (or both) is a sum of two non-zero squares, then using the multiplicativity of the norm gives rise to a presentation of $n$ as a sum of two non-zero squares. If $n_1=N(a_1+ib_1)$, $n_2=a_2^2$ and $n_3=N(a_3+ib_3)$, then then product $u+iv=(a_1+ib_1)a_2(a_3+ib_3)$ cannot be real or pure imaginary by the argument from item 3 above, and $N(u+iv)=n$.
OTOH, if $n=N(u+iv)$ with $uv\neq0$, then the prime factorization of $u+iv$ must either contain a factor of $n_3>1$ or an odd power of $(1+i)$.
Summary: $n$ is a sum of two non-zero squares, iff all the exponents $s_i$ are even, and in addition either $a$ is odd, or at least one of the exponents $r_j>0$.
Your ring $\mathbb{Z}_n[i]$ can be seen as the quotient $$\Bbb Z_n [i] \cong \Bbb Z[i] / (n).$$ One of the isomorphism theorems, which can be found on every algebra book, says that the ideals of a quotient $R/A$ are in bijection with the ideals of $R$ that contain $A$, and the bijection is given by $$B \mapsto B/A = \{b+A : b \in B\}.$$Because $\Bbb Z[i]$ is a PID, every ideal that contains $(n)$ is of the form $(m)$, where $m \mid n$. If $$n=p_1^{k_1} \ldots p_r^{k_r}$$is the decomposition of $n$ as product of primes (in $\Bbb Z [i]$), then any ideal containing $(n)$ is of the form $(p_1^{s_1} \ldots p_r^{s_r})$, where $s_j \leq k_j$ and, in particular, there are $(k_1+1) \ldots (k_r+1)$ different ideals, which, in turn, correspond to different ideals of $\mathbb{Z}_n[i]$.\
Note that there is nothing particular of $\Bbb Z [i]$ apart from being a PID that we are using here. The same method proves how to find all the ideals in the quotient of a PID by one of its ideals, as you would do with $\Bbb Z _n$, but now taking into account that you need to factorise in $\Bbb Z[i]$ so, for example, $5$ is not prime because $5=(2+i)(2-i)$.
As it has been said in the comments, every ideal of $\mathbb{Z}_n[i]$ is principal. This is a general result. If you look back to the correspondence of ideals in a quotient, if $B$ is generated by $b$, then $B/A$ is generated by $b+A$.
Best Answer
I think all four of your questions can be answered by looking at the following question:
i.e. when do there exist integers $a,b$ such that $$p = a^2+b^2.$$
This is certainly a natural, number theoretic question to ask. And the answer relies heavily on the Gaussian integers. Indeed, if $p$ can be expressed in the above form, then, as an element of $\mathbb Z[i]$, $$p=(a+bi)(a-bi),$$ so we can rephrase our question as follows:
It turns out that the answer to your questions $3$ and $4$ is yes:
In particular, we can rephrase our question once more:
It turns out that this is a question we can answer using the arithmetic of $\mathbb Z[i]$. It is possible (but not easy) to show that $$p\text{ is no longer prime in }\mathbb Z[i]\iff X^2+1\text{ is reducible modulo }p.$$ Note that $X^2+1$ is the minimal polynomial of $i$. Using facts from elementary number theory, $-1$ is a square mod $p$ if and only if $p=2$ or $p\equiv 1 \pmod 4$. This gives an answer to our question.
However, the story doesn't stop here. Let's say instead, we wanted to know which prime numbers $p$ can be written in the form $$p=a^2+5b^2?$$
If we were to play the same game as before, we might want to consider the ring $\mathbb Z[\sqrt{-5}]$. However, in this setting we have a problem: we no longer have unique factorisation, since, for example, $$6 = (1+\sqrt{-5})(1-\sqrt{-5})=2\cdot 3.$$ It is problems like this which the field of algebraic number theory comes to answer.