local addonName, ns = ...

local cache = {}
local W = ns.Widgets
local C = ns.COLORS

function ns:InitAbout()
    local p = ns.MainFrame.Content

    W:CachedPanel(cache, "frame", p, function(f)
        local _, sc = W:CreateScrollFrame(f, 1200)

        local r, g, b
        if ns.GetClassColor then
            r, g, b = ns.GetClassColor()
        else
            r, g, b = 168/255, 85/255, 247/255
        end
        local ccHex = string.format("%02x%02x%02x", r*255, g*255, b*255)

        -- ── Header ──────────────────────────────────────────────────────────
        W:CreatePageHeader(sc,
            {{ "BRIGHT", C.BLUE }, { "QOL", C.ORANGE }},
            "A quality of life addon built for the modern WoW player.",
            { subtitleFont = "GameFontHighlightSmall", separator = false })

        -- ── Version ─────────────────────────────────────────────────────────
        W:CreateSectionHeader(sc, "Version", -80)

        local stage  = _G.BrightQoL_VersionStage  or "RELEASE"
        local number = _G.BrightQoL_VersionNumber  or "1.0.0"

        local verText = sc:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
        verText:SetPoint("TOPLEFT", 35, -115)
        verText:SetText(string.format(
            "|cff%s%s|r  |cffaaaaaa%s|r", ccHex, stage, number))

        local tocVer = C_AddOns and C_AddOns.GetAddOnMetadata(addonName, "Version") or number
        local tocText = sc:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
        tocText:SetPoint("TOPLEFT", 35, -135)
        tocText:SetText("|cff555555TOC Version:|r |cffcccccc" .. tocVer .. "|r")

        -- ── Author ───────────────────────────────────────────────────────────
        W:CreateSectionHeader(sc, "Author", -165)

        local authorText = sc:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
        authorText:SetPoint("TOPLEFT", 35, -200)
        authorText:SetText(string.format("|cff%sBrightusk|r", ccHex))

        local authorSub = sc:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
        authorSub:SetPoint("TOPLEFT", 35, -218)
        authorSub:SetText("|cff555555Feedback & issues:|r  |cff00cfff/bqol|r")

        local discordText = sc:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
        discordText:SetPoint("TOPLEFT", 35, -238)
        discordText:SetText("|cff555555Discord:|r  |cff5865F2Brightusk|r")


    end)
end
