12. (20 points) Given the ellipse $\frac{x^{2}}{4}+y^{2}=1$, and $P$ is any point on the circle $x^{2}+y^{2}=16$. Tangents $PA$ and $PB$ are drawn from $P$ to the ellipse, touching the ellipse at points $A$ and $B$ respectively. Find the maximum and minimum values of $\overrightarrow{P A} \cdot \overrightarrow{P B}$.
12. Let point $P(m, n), A\left(x_{1}, y_{1}\right), B\left(x_{2}, y_{2}\right)$. Then the tangent equations are
$$
\begin{array}{l}
l_{A P}: \frac{x_{1} x}{4}+y_{1} y=1, \\
l_{P B}: \frac{x_{2} x}{4}+y_{2} y=1 .
\end{array}
$$

Since the tangents $P A$ and $P B$ both pass through point $P$, we have $\frac{x_{1} m}{4}+y_{1} n=1$ and $\frac{x_{2} m}{4}+y_{2} n=1$ simultaneously. Therefore, $l_{A B}: \frac{m x}{4}+n y=1$.
Solving the system of equations for line $A B$ and the ellipse, we get
$$
\left\{\begin{array}{l}
\frac{x^{2}}{4}+y^{2}=1 \\
\frac{m}{4} x+n y=1
\end{array}\right.
$$

which simplifies to $\left(4 n^{2}+m^{2}\right) x^{2}-8 m x+\left(16-16 n^{2}\right)=0$.
Thus, $x_{1}+x_{2}=\frac{8 m}{4 n^{2}+m^{2}}$,
$$
x_{1} x_{2}=\frac{16-16 n^{2}}{4 n^{2}+m^{2}} \text {. }
$$

Then $y_{1} y_{2}=\frac{4-m x_{1}}{4 n} \cdot \frac{4-m x_{2}}{4 n}=\frac{4-m^{2}}{4 n^{2}+m^{2}}$,
$$
\left(y_{1}+y_{2}\right) n=2-\frac{m\left(x_{1}+x_{2}\right)}{4}=\frac{8 n^{2}}{4 n^{2}+m^{2}}
$$

Hence $\overrightarrow{P A} \cdot \overrightarrow{P B}$
$$
\begin{aligned}
= & \left(x_{1}-m, y_{1}-n\right) \cdot\left(x_{2}-m, y_{2}-n\right) \\
= & x_{1} x_{2}-\left(x_{1}+x_{2}\right) m+m^{2}+y_{1} y_{2}- \\
& \left(y_{1}+y_{2}\right) n+n^{2} \\
= & \frac{20-3 m^{2}}{4 n^{2}+m^{2}}+m^{2}+n^{2}-6 .
\end{aligned}
$$

Substituting $m^{2}=16-n^{2}$ into the above equation, we get
$$
\overrightarrow{P A} \cdot \overrightarrow{P B}=11-\frac{44}{3 n^{2}+16} \text {. }
$$

Since $0 \leqslant n^{2} \leqslant 16$, when $n^{2}=0, m^{2}=16$, i.e., $P( \pm 4,0)$,
$(\overrightarrow{P A} \cdot \overrightarrow{P B})_{\text {min }}=\frac{33}{4}$;
when $n^{2}=16, m^{2}=0$, i.e., $P(0, \pm 4)$, $(\overrightarrow{P A} \cdot \overrightarrow{P B})_{\max }=\frac{165}{16}$.