The first line is the issue. The problem is that you never defined exponentiation properly: What is $a^b$?. If $a$ is a positive real, there is no much mistery, is the usual exponentiation that we know. But things get weirder if $a$ is negative, If $b$ is an integer, everything is well defined, e.g. $(-1)^4=1$ makes total sense. But what happens when $a$ is negative and $b$ is a fraction? For instance, what if $a=-1$ and $b=0.5$, can we make sense of $(-1)^{0.5}$? you may think it as square root of $-1$, so let's say that $(-1)^{0.5}=i$.But then you think about it... wait what about saying $(-1)^{0.5}=-i$? Things get even more complicated if $b$ is an arbitrary real number, for instance what is $(-1)^\pi$?
As you can see, there are a lot of issues when the base is negative. So, technically, $a^b$ is not well defined for $a<0$. How do we define $a^b$ in general then? The best we can do is to define the following:
For $a\in\mathbb{C}\setminus(-\infty,0]$ and $b\in\mathbb{C}$. We define
$a^b:=e^{b\operatorname{Log}(a)}$. Where $\operatorname{Log}(z)$ is the "principal branch" of the logarithm, which is defined only for $z\in\mathbb{C}\setminus(-\infty,0]$.
So, as a rule of thumb, to not make mistakes like this, always work with positive basis (preferrably $e$), since in this case all the properties of exponentials are still satisfied.