Might this be The Valley of the Wolves (2000) by Laura Gallego García?
It seems the original, Spanish version of the book was published in 2000, and the English version in 2006.
According to this review, the protagonist grew up on a farm, with a boy only she could see as her friend, until a mysterious magician showed up one day, offering to take her away and make her his apprentice:
Beautiful elves, loyal dwarves, secret unicorns and vengeful ghosts pepper this colorful but hollow coming-of-age fairytale.
Dana is born on a dark and stormy night, when fierce winds pelt her tiny farmhouse, and the midwife sees sparks in her sapphire eyes. She grows up with only one friend, Kai, whom no one else can see—except a mysterious stranger, who arrives in Dana’s drought-plagued village and buys her from her loving parents. Dana becomes a magician’s apprentice in a remote tower surrounded by vicious wolves. Ambitious, Dana absorbs herself in her education, spending less and less time with Kai. If their friendship suffers a little, isn’t that a fair price to pay for gaining a magician’s golden tunic?
Dana’s coming-of-age quest is somewhat intriguing, but she herself is unfortunately flat. Like the similarly stock characters who people this world, she is a collection of traits rather than a character: born with power; budding sexuality; forced to choose between loyalty and ambition. Nonetheless, though shallow as a novel, Dana’s story makes a sweet fairytale.
This review also mentions something about a unicorn's treasure:
In this fantasy imported from Spain, Dana and Kai have been best friends since they were six; the fact that no one else can see Kai is of little concern to Dana, who finds comfort in his friendship. Comfort becomes something more when Dana eventually discovers, as she and Kai become adolescents, that her growing romantic love for him is reciprocated.
A rare opportunity to study as the apprentice of the powerful but distant Maestro leads Dana to a mysterious tower where she spends the next several years, accompanied by Kai. Even while her own power grows under the tutelage of the Maestro, Dana cannot quell her misgivings about his true motives as she also struggles to reconcile her impossible love for the incorporeal Kai.
Although the mystery of a unicorn's treasure adds a glossy twist to the novel and Kai as guardian angel/ghost diverges from the typical love interest, there are few new elements in this oft-told story of bold, magical teen girl fighting not only for the boy she loves but also to prove her strength and worth. However, the well-developed and convincing bond between Dana and Kai and the successful balance between action and introspection give the familiar theme added energy.