The flood account does indeed use very specific numbers for measurements, periods of time, etc. Are the numbers used more in the literal sense, or are they more esoteric in meaning? I think an argument could be made for either; but the expression ‘40 days and 40 nights’ is still idiomatic. To explain why it’s idiomatic is like trying to explain why “raining cats and dogs?” is idiomatic – I don’t have an answer for either; it just is. That’s the way these phases work in these languages – they’re not literal.
The author weaves both the idiom and the number 40 (all by itself) into the narrative. The use of 40 alone seems to carry the more esoteric meaning associated with that number, but the phrase ‘40 days and 40 nights’ is still idiomatic. Chapter 7 verse 24 may provide some clue as to how long this particular period was – seems maybe somewhere around 150 days or so. Could it have been a literal 40 days and nights? Sure, but given the idiomatic use of the phrase, I would think if it were, the author would have provided something to clue the reader in that it wasn’t meant to be taken in the idiomatic sense.
This idiomatic phase seems to occur here and there in Biblical texts – actually, outside of religious texts, there’s really not a whole heck of a lot else with respect to ancient Hebrew literature, writings, or inscriptions, so no – there really are no extra-Biblical examples of its use that I’m aware of, nor has this particular expression survived in the modern language.
As an aside, looking into a possible origin, the idiomatic expression may have arisen from a very ancient way of tracking the year (not just in the Middle East) in 9ths comprising a 40-day cycle. There are numerous ancient writings and artifacts that attest to a 40-day cycle as something once carefully tracked. If indeed this was the case, it’s quite possible this was the origin of the idiomatic expression. So, yes, originally a literal count, but over time came to be used more idiomatically for any long period of time.