Filter a query based on multiple checkbox formgroups

Hello.
Based on this example from @Teodor Filtering Database Query with Multiple Checkboxes

I want to execute the same but with multiple categories of checkboxes.
In the above example, @Teodor is using one block of checkboxes (with the class form-group)
What if I have more than one form-group

For example I have several checkbox groups
One for size (S,M,L)
One for color (Red, Green, Blue)

And want all of them to be filtered by the same array just like in Teodor’s example.

Hope I explained it ok.

Thank you!