My guess is that you had given t a numeric value, and this interfered with Integrate. You can protect the integration variable by wrapping it into Module:
Clear[ak, bk];
ak[f_, n_] :=
ak[f, n] =
Module[{t}, (1/\[Pi]) Integrate[f[t] Cos[n t], {t, -\[Pi], \[Pi]}]];
bk[f_, n_] :=
bk[f, n] =
Module[{t}, (1/\[Pi]) Integrate[f[t] Sin[n t], {t, -\[Pi], \[Pi]}]];
f[t_] := \[Pi]^2 - t^2;
ak[f, 2]
Also, it may be prudent to use NIntegrate instead of Integrate, unless you know in advance that your integrals have a closed form.
As for the FillingStyle, you may first define your measure of accuracy, for example the L2 distance
el2distance[f_, fn_] :=
Module[{t}, Sqrt@NIntegrate[Abs[f[t] - fn[t]]^2, {t, -Pi, Pi}]]
and then write something like
FillingStyle -> GrayLevel[el2distance[f, fn]]
This may not work straight away, because you probably have to normalize the distance first, as GrayLevel[x] wants x between 0 and 1.
Instead of GrayLevel[x], you may prefer something like Blend[{Blue, Red}, x].