Find the minimum value of
\[(\sin x + \csc x)^2 + (\cos x + \sec x)^2\]for $0 < x < \frac{\pi}{2}.$
We can write
\begin{align*}
(\sin x + \csc x)^2 + (\cos x + \sec x)^2 &= \sin^2 x + 2 + \csc^2 x + \cos^2 x + 2 + \sec^2 x \\
&= \csc^2 x + \sec^2 x + 5 \\
&= \frac{1}{\sin^2 x} + \frac{1}{\cos^2 x} + 5 \\
&= \frac{\cos^2 x + \sin^2 x}{\sin^2 x} + \frac{\cos^2 x + \sin^2 x}{\cos^2 x} + 5 \\
&= \frac{\cos^2 x}{\sin^2 x} + \frac{\sin^2 x}{\cos^2 x} + 7 \\
&= \frac{\cos^2 x}{\sin^2 x} - 2 + \frac{\sin^2 x}{\cos^2 x} + 9 \\
&= \left( \frac{\cos x}{\sin x} - \frac{\sin x}{\cos x} \right)^2 + 9 \\
&\ge 9.
\end{align*}Equality occurs when $x = \frac{\pi}{4},$ so the minimum value is $\boxed{9}.$