If direction of current changes the output of circuit should be changed from (high to low) OR (low to high)
You need a zero crossing voltage comparator to turn sine wave voltages into square waves.
You need a zero crossing current comparator that turns the current into square waves.
Feed the two above comparator outputs into an exclusive OR gate.
If voltage and current are exactly in phase XOR output will be continuous low.
If voltage and current are exactly 180 degrees out of phase, XOR output will be continuously high.
High or low indicates direction of power flow.
But.....
There will always be some extra phase shift present due to reactive power factor, so there is not likely to be a steady high or steady low. But there will "almost" be a continuous high or low with some maybe narrow pulses due to the slight phase shift.
What you then do is integrate the output of the XOR gate to get a steady dc voltage, and feed that into yet another voltage comparator, referenced to half way between logic high and low.
That will then give a very reliable logic level indicating power flow direction, and it will still work with up to 90 degrees of possible additional phase error.