“and the lamp of God had not yet gone out.” So it was very late in the night but not yet the morning, as we might say, “in the wee hours of the morning.” The menorah lamp in the Tent of Meeting (the “Tabernacle”) was lit every night and gave light until the olive oil ran out about morning (Exod. 27:21; 30:8; Lev. 24:2-3; 2 Chron. 13:11). So this tells us that God appeared to Samuel some time before dawn.
Since Eli’s eyes were growing dim (1 Sam. 3:2), it makes sense that Eli could not see at night and would call Samuel for assistance if he needed help, and old men often wake up at night for various reasons. So when Samuel heard his name being called, and never before having heard the direct voice of Yahweh, it makes perfect sense that he would assume that Eli was calling him (1 Sam. 3:4-8). Since it was fairly close to dawn it also makes sense that after Yahweh appeared to Samuel, he could not get back to sleep and lay awake until the dawn (1 Sam. 3:15).