Is there a way to detect which one of six sides was hit by raycast?
The largest absolut value of either x y or z of the hit point vector should tell you which side. For example when Mathf.Abs(y), with y = -5, returns 5 and is the largest value, you know it’s the bottom.
Use raycastHit.normal, which gives you a unit vector perpendicular to the face that was hit. So for example, if you hit the left face of an axis aligned cube, you get Vector3.left.