Hi.
If the phase of your 230 VAC cicuit is the same to permanently supply a shelly (important !), you can realize this with a Shelly 1 Gen3.
The shelly needs 230 VAC permanently at L-N to operate.
The 230 VAC circuit with is going on and off goes to SW. The 12 VDC circuit goes to I and O.
In "Input/Output settings" set "Select input mode for Input (0)" to switch and "Action on power on for Relais" to "Turn ON".
Now add a new action. Set "Event condition" to "Input toggled off" and add a local action. Set "Action" to "Control Output" and "Set Output State property" to "Off". Set "Set Flip value after property" to 2-5 seconds.
That should do the job. If the 230 VAC circuit goes off, the 12 VDC circuit switches off and turned on again after 2-5 seconds.