What do the bar colors mean, during gym fight?
From my experience with the game, I have theorized this from the colors:
Green
Health is excellent or near full.
Yellow
Health is somewhere around the middle of the bar.
Orange
Can show up at any time during a fight, it indicates how much health a Pokemon is about to lose from an attack.
Red
Health is critically low, and the Pokemon may faint soon.
I'll have to look around and see if there's a concrete source backing this up, but this has been my experience with gyms and the health bar thus far.
The HP bar has three colours depending on how much health a Pokémon has, red for low, yellow for medium and green for high. I do not know at exactly what percentages these change.
A portion of the bar is also coloured orange. This is the amount of damage dealt during the current turn of attacks. On a 1v1 match, it may seem irrelevant, but when you have 2v1 or more, this shows you how much damage is being dealt overall to the defending Pokémon.