Context : A guy wakes up and a girl tells him that he slept with her during the night (the girl is his friend) ,he denies and says: Since you've tempted me so much until now, I would've done everything I could imagine throughout the night, so there's no way you would be so energetic right now. By could does he mean everything he could (can) imagine (while he's speaking) or everything he could imagine during the night ? because I know that sometimes we use could like can and I'm not sure which one is the correct one here,thanks.
"Could" is the correct word here. He is talking about something in the past and so the past tense of "can" needs to be used. Colloquially there would not be a problem using "can" in this sentence though. But it does not refer to him thinking of all the things he can do right now (as he speaks). It means he would have thought of them while the act was occurring last night.
He cannot technically think of things to do now, that relate to that specific act, that happened last night. Let's back up, he can logically think of things now, that he is speaking about, but he can't make them happen last night.
I would have done everything I could imagine last night...
I would have done everything I can imagine last night...
The second one is colloquially okay. But the first is correct.
Imagine this one:
"Yesterday I would have spilled the drink on you if I can." (obviously this sounds ridiculous b/c it's using the modal verb "can" in the present tense for an event that happens yesterday).
"Yesterday I would have spilled the drink on you if I could." (this is correct now)
But if we change the structure slightly and add some content (similar to your question):
"Yesterday I would have done everything I can to spill the drink on you." (it's incorrect but most native speakers would not harass you for this usage.)
"Yesterday I would have done everything I could to spill the drink on you." (now it's technically correct).
It's very subtle but when we speak about past events if the sentence structure is such that we have a clause in the first part of the sentence that speaks about a past tense event followed by a pronoun (like everything, anything, nobody, etc) then we can sometimes get away with using the present tense modal form of "can".
I would advise not doing this and always use the past tense "could" if you are talking about an event in the past.