Hi Farenzzzzno,
I didn't have time to look deeply, but at a glance, it seems you have many bones, including other smart bones, under the control of GIRO CUERPO. In the image below, Moho is highlighting all the bones controlled by GIRO CUERPO.
I mainly suspect that the rotation of the thigh bone is being 'locked' by the GIRO CUERPO Smart Bone because that's how it's keyframed, and this can make the IK appear to be broken. In other words, the IK is fine, but the Smart Bone is overriding the leg rotation.
My guess is that your intention was to keyframe only the X movement of some bones in the Smart Bone, so you might want to check that.
For example, here in the GIRO CUERPO Smart Bone timeline, I see rotation keys for the Thigh and Shin bones, and the Thigh bone is keyframed to stay between 180-182 degrees (pointing downward.)
This makes the IK do this in the Mainline...
But after I remove the rotation keyframes to allow the bones to move freely, it looks like this...
The above is more correct, but we probably want the leg to bend the other direction, which is a different issue. To correct this, we need to 'hint' the Thigh bone to bend in that direction, so it looks like this...
To fix this, I made a slight bend in the knee at frame 0, which tells IK to bend the knee in this direction. It's not necessary to 'bend' the artwork to match; the bend is there only to inform the IK. Here's what this looks like...
As you animate the character, you may wish to bend the knee in the other direction. To do this, keyframe the knee rotation to bend the other way, and IK will understand your intention. (It's typically two keyframes near each other: one to hold the pose for the first direction, and a second to transition the bend to the opposite direction.)
Tip: This is just me, but I generally don't use Smart Bones to control the transforms of many bones in my rigs because that can limit the posing possibilities and make performances look mechanical. (Which is fine if that's the intention.)
I suspect there's more to fix here, but I hope this info gives you clues for where to look.
Good luck!