local ADDON_NAME, WDIGI = ...

------------------------------------------------------------
-- MAIN FRAME
------------------------------------------------------------
local f = CreateFrame("Frame", "WDIGI_MainFrame", UIParent, "BasicFrameTemplateWithInset")
WDIGI.MainFrame = f

f:SetSize(520, 520)
f:SetPoint("CENTER")
f:Hide()

------------------------------------------------------------
-- LOGO + TITLE
------------------------------------------------------------
local logo = f:CreateTexture(nil, "ARTWORK")
logo:SetSize(64, 64)
logo:SetPoint("TOPLEFT", 15, -15)
logo:SetTexture("Interface\\AddOns\\wheredoigetit\\Icons\\WandAndSword")

f.title = f:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
f.title:SetPoint("TOPLEFT", logo, "TOPRIGHT", 10, -5)
f.title:SetText("|cff00ffffWhere Do I Get It?|r  v" .. (WDIGI.VERSION or "1.x"))

------------------------------------------------------------
-- SCROLL FRAME
------------------------------------------------------------
local scroll = CreateFrame("ScrollFrame", "WDIGI_MainScroll", f, "UIPanelScrollFrameTemplate")
scroll:SetPoint("TOPLEFT", 10, -90)
scroll:SetPoint("BOTTOMRIGHT", -30, 10)

------------------------------------------------------------
-- CONTENT FRAME (ANCHOR FIX)
------------------------------------------------------------
local content = CreateFrame("Frame", nil, scroll)
content:SetPoint("TOPLEFT", scroll, "TOPLEFT", 0, 0)   -- IMPORTANT
content:SetWidth(460)

local text = content:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
text:SetPoint("TOPLEFT", content, "TOPLEFT", 0, 0)     -- IMPORTANT
text:SetWidth(460)
text:SetJustifyH("LEFT")
text:SetJustifyV("TOP")

scroll:SetScrollChild(content)

------------------------------------------------------------
-- DOCUMENTATION CONTENT
------------------------------------------------------------
local doc = [[
|cff00ffffWhat is WDIGI?|r

WDIGI adds detailed item source information directly to tooltips:
|cffffff00• Who sells an item|r
|cffffff00• Who drops it|r
|cffffff00• What containers it comes from|r
|cffffff00• Disenchant sources|r
|cffffff00• Coordinates + zone names|r
|cffffff00• Distance to nearest vendor|r

WDIGI is lightweight, fast, and works on over |cff00ff0080,000+|r Retail items.


|cff00ffffHow to Use WDIGI|r

|cffffff00Hover over any item|r
Shows all known sources instantly.

|cffffff00ALT Key Toggle|r
Enable/disable extra tooltip info.

|cffffff00Ctrl + Shift + Left Click|r
Sets a navigation pin to the closest vendor or drop source.

|cffffff00Navigation HUD|r
Shows vendor name, item name, cost, and distance.

|cffffff00Settings Panel|r
Game Menu → Options → AddOns → Where Do I Get It?

Options include:
• ALT hotkey toggle
• Category limits
• Navigation HUD toggle
• Debug HUD


|cff00ffffSlash Commands|r

/wdigi show
/wdigi hide
/wdigi pin
/wdigi nav off
/wdigi version
/wdigi clearcache

Debug:
/wdigi debug on
/wdigi debug off
/wdigi debug level trace|debug|warn|error
/wdigi debug console
/wdigi debug save

Other:
/wdigi reload
/wdigi test


|cff00ffffWhat's New in v1.1.0|r

• Click-to-Pin Navigation
• Navigation HUD
• Faster Tooltip Parsing
• New Settings Panel Options
• Internal Cleanup


|cff00ffffSupport & Links|r

Buy Me a Coffee:
https://buymeacoffee.com/slashzero

Icy-Veins Feature Article:
https://www.icy-veins.com/wow/news/where-do-i-get-it-new-addon-shows-where-items-drop-by-hovering-over-them/

CurseForge Page:
https://www.curseforge.com/wow/addons/where-do-i-get-it
]]

text:SetText(doc)

-- Resize content height to match text height
content:SetHeight(text:GetStringHeight() + 20)

-- Ensure scroll starts at top
C_Timer.After(0, function()
    scroll:SetVerticalScroll(0)
end)
