I'm afraid you do have a problem.
As such, the vent connection needs to be a fitting in the "trap arm" that is vertical or no more than 45 degrees off vertical that goes to the vent line.
As this is a tub, you can use 1 1/2" pipe as you mentioned. I'm not sure of the geometry, but if you use 1 1/2" pipe and fittings, you
might be able to fit the following layout in your space.
Run a line from the P-trap location directly to the drop to the sewer. Install that line as low as possible and put a Sanitary Tee on its back with the branch connection rolled at a 45-degree angle. Use a street fitting into the Sanitary Tee branch connection to get the vent over to the wall. The vent line needs to be sloped at 1/4" per foot just like the drain line. You should also put a clean out with access in the vertical portion of the vent line.
You might also help yourself if you rotate the P-trap 180 degrees so that the discharge is going towards the wall. That would shorten the distance to the vent location saving some fractions of an inch that you may need to fit this into your location.
Another option would be to leave you piping as it is and run a sink drain into the "vent" line. That looks difficult to do, but I thought I would throw that out there. If you could accomplish that, the horizontal portion of the existing line becomes a "wet vent" for the tub, along with the vertical portion up to where the sink ties into it.
The code issue is that without any flow going through the horizontal portion shown in your current layout, it can become plugged. Will it work as is, highly likely for many years. Is it per code, no. Will an inspector allow it, perhaps and perhaps not.