Looking for Cartoon movie, it was all a dream.

So when I was younger during the 2000s to 2010s I watched a movie, it was on DVD but not in a plastic case, it was one of those paper cases (like the dick van dyke show DVD case, doubt that helps). The premise of the movie is that the main character is coming to a new city to visit his friend (who is practically a cartoon version of obi-wan). They bump into this girl who sells flowers and the friends go on a weird adventure with mines and mine workers (maybe there was something about a bull statue) anyway they meet up with the girl again and continue there adventure. The main character wears blue and I vaguely remember that his friend wore brown. Heres the spoiler, in the end all of that didn't happen and it was all a dream that the main character was having because he hit his head in the BEGINNING OF MOVIE! Like minutes before he bumps/meats both the girl ,who was the main love interest, and his friend. He also apparently after waking up from his dreams see other people and recognizes them by name. This is not a conspiracy movie where the government experimented or nothing. This is set mid pre industrialization I want to say Mexico it could be Spain. I remember practically everything except the name.🤦🤦🤦🤦