Prove a trigonometric identity: $\cos^2A+\cos^2B+\cos^2C+2\cos A\cos B\cos C=1$ when $A+B+C=\pi$ There is a trigonometric identity:

$$\cos^2A+\cos^2B+\cos^2C+2\cos A\cos B\cos C\equiv 1\text{ when }A+B+C=\pi$$

It is easy to prove it in an algebraic way, just like that:

$\quad\cos^2A+\cos^2B+\cos^2C+2\cos A\cos B\cos C\\=\cos^2A+\cos^2B+\cos^2\left(\pi-A-B\right)+2\cos A\cos B\cos \left(\pi-A-B\right)\\=\cos^2A+\cos^2B+\cos^2\left(A+B\right)-2\cos A\cos B\cos \left(A+B\right)\\=\cos^2A+\cos^2B+\left(\cos A\cos B-\sin A\sin B\right)^2-2\cos A\cos B\left(\cos A\cos B-\sin A\sin B\right)\\=\cos^2A+\cos^2B+\cos^2A\cos^2B+\sin^2A\sin^2B-2\sin A\cos A\sin B\cos B-2\cos^2A\cos^2B+2\sin A\cos A\sin B\cos B\\=\cos^2A+\cos^2B-\cos^2A\cos^2B+\left(1-\cos^2A\right)\left(1-\cos^2B\right)\\=\cos^2A+\cos^2B-\cos^2A\cos^2B+1-\cos^2A-\cos^2B+\cos^2A\cos^2B\\=1$

Then, I want to find a geometric way to prove this identity, as $A+B+C=\pi$ and it makes me think of the angle sum of triangle. However, it is quite hard to prove it in a geometric way. Therefore, I hope there is someone who can help. Thank you!

I don't know if this counts as a proof, but following your suggestion, I used the cosine laws to obtain your result.
Suppose you have a triangle ABC as in the figure:

Since the angles $A+B+C=\pi$, these are the internal angles of a general triangle.
Using the law of cosines, you can write:
$a^2=b^2+c^2-2bc\cos A\\b^2=a^2+c^2-2ac\cos B\\c^2=a^2+b^2-2ab\cos C$
It follows from here that:
$
\cos A=\frac{a^2-b^2-c^2}{-2bc}\\
\cos B=\frac{b^2-a^2-c^2}{-2ac}\\
\cos C=\frac{c^2-a^2-b^2}{-2ac}
$
Now, to verify your formula, we have:
$\cos^2A+\cos^2B+\cos^2C+2\cos A\cos B\cos C=\\
\left(\frac{a^2-b^2-c^2}{-2bc}\right)^2+\left(\frac{b^2-a^2-c^2}{-2ac}\right)^2+\left(\frac{c^2-a^2-b^2}{-2ac}\right)^2+2\left( \frac{a^2-b^2-c^2}{-2bc} \right)\left( \frac{b^2-a^2-c^2}{-2ac} \right)\left( \frac{c^2-a^2-b^2}{-2ac} \right)
$
It is now a matter of manipulation of the equation to show that this equals 1. Observe that the least common multiple of the first three terms is $4a^2b^2c^2$, which is equal to the product of the last term,
$
\frac{a^2(a^2-b^2-c^2)^2+b^2(b^2-a^2-c^2)^2+c^2(c^2-a^2-b^2)^2}{4a^2b^2c^2}-\frac{(a^2-b^2-c^2)(b^2-a^2-c^2)(c^2-a^2-b^2)}{4a^2b^2c^2}
$
expanding the products in the numerator, you can verify that:
$a^2(a^2-b^2-c^2)^2+b^2(b^2-a^2-c^2)^2+c^2(c^2-a^2-b^2)^2-(a^2-b^2-c^2)(b^2-a^2-c^2)(c^2-a^2-b^2)=4a^2b^2c^2$
so the fraction simplifies to
$
\frac{4a^2b^2c^2}{4a^2b^2c^2}=1
$
