My answer is that absolutely it’s okay and appreciated 🙂
In the case when a book was no longer in print, I gave the only copy that I could get my hands on. It was in good condition. Usually, I prefer to purchase a Very Good or Like New condition book as a gift.
as long as the condition looks like brand new then why not, the person getting the gift does not need to know where you got it from, to him let him think you just got it brand new from the store