Optocoupler conducts without LED supply
Typically its best to connect the optocoupler in a low side configuration(rather then a high side. The diagram below should help you restructure your circuit:







simulate this circuit &ndash; Schematic created using CircuitLab

Hopefully this way, the internal transistor inside optoucoupler fully turns on when 12V is available and arduino would get 0V. When 12V is not available, Arduino would get 5V at the input.(You can invert the input in logic for the sake of simplicity)