local addonName, privateDB = ...

-- ============================================================================
-- CONFIG TAB MODULE
-- Settings UI and contributor credits
-- ============================================================================

local CONFIG = privateDB.CONFIG
local L = HDG_L or {}  -- Localization
local HDG_ConfigTab = {}
privateDB.HDG_ConfigTab = HDG_ConfigTab

local mainFrame = nil

-- ============================================================================
-- INITIALIZATION
-- ============================================================================

function HDG_ConfigTab.Init(frame)
    mainFrame = frame
end

-- ============================================================================
-- CREATE PANEL
-- ============================================================================

function HDG_ConfigTab.Create()
    if not mainFrame then return end

    local configFrame = CreateFrame("Frame", nil, mainFrame, "BackdropTemplate")
    configFrame:SetPoint("TOPLEFT", CONFIG.SPACING.PANEL_PADDING, -(CONFIG.BANNER_HEIGHT + CONFIG.TAB_HEIGHT + 8))
    configFrame:SetSize(CONFIG.MAIN_FRAME_WIDTH - (CONFIG.SPACING.PANEL_PADDING * 2), CONFIG.PANEL_HEIGHT)
    configFrame:SetBackdrop({
        bgFile = CONFIG.TEXTURES.WHITE_BG,
        edgeFile = CONFIG.TEXTURES.WHITE_BG,
        tile = false,
        edgeSize = 1,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    })
    configFrame:SetBackdropColor(unpack(CONFIG.COLORS.PANEL_BG))
    configFrame:SetBackdropBorderColor(unpack(HDG_UIHelpers.BORDER_COLOR))
    configFrame:Hide()
    mainFrame.configFrame = configFrame

    -- Header background (matches DecorPreview style)
    local headerBg = CreateFrame("Frame", nil, configFrame, "BackdropTemplate")
    headerBg:SetPoint("TOPLEFT", 1, -1)
    headerBg:SetPoint("TOPRIGHT", -1, -1)
    headerBg:SetHeight(22)
    headerBg:SetBackdrop({ bgFile = CONFIG.TEXTURES.WHITE_BG, tile = false })
    headerBg:SetBackdropColor(unpack(HDG_UIHelpers.BG_HEADER))

    local title = headerBg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    title:SetPoint("CENTER", 0, 0)
    title:SetText("|cFFFFFFFFConfiguration|r")

    -- Create scrollable content frame
    local scrollFrame = CreateFrame("ScrollFrame", nil, configFrame, "UIPanelScrollFrameTemplate")
    scrollFrame:SetPoint("TOPLEFT", 10, -30)
    scrollFrame:SetPoint("BOTTOMRIGHT", -30, 10)

    local scrollChild = CreateFrame("Frame", nil, scrollFrame)
    scrollFrame:SetScrollChild(scrollChild)
    scrollChild:SetWidth(CONFIG.MAIN_FRAME_WIDTH - 60)
    scrollChild:SetHeight(1200) -- Will be adjusted based on content

    -- Apply minimalist scrollbar styling
    if HDG_UIHelpers and HDG_UIHelpers.StyleScrollBar then
        HDG_UIHelpers.StyleScrollBar(scrollFrame)
    end

    local yOffset = -10
    local rightColumnX = 380  -- X position for right column

    -- Helper function to create separator lines
    local function CreateSeparator(yPos)
        local sep = scrollChild:CreateTexture(nil, "ARTWORK")
        sep:SetHeight(1)
        sep:SetPoint("TOPLEFT", 10, yPos)
        sep:SetPoint("TOPRIGHT", -10, yPos)
        sep:SetColorTexture(0.3, 0.3, 0.35, 0.5)
        return sep
    end

    -- ========================================
    -- TWO-COLUMN LAYOUT: General Settings (left) | Lumber Tracking (right)
    -- ========================================

    -- Section headers
    local generalHeader = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    generalHeader:SetPoint("TOPLEFT", 10, yOffset)
    generalHeader:SetText("|cFF14b8a6General|r")

    local lumberHeader = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    lumberHeader:SetPoint("TOPLEFT", rightColumnX, yOffset)
    lumberHeader:SetText("|cFF14b8a6Lumber Tracking|r")

    yOffset = yOffset - 20
    local row1Y = yOffset

    -- === LEFT COLUMN ROW 1: Minimap Button ===
    local minimapCheckbox = CreateFrame("CheckButton", "HDG_MinimapCheckbox", scrollChild, "UICheckButtonTemplate")
    minimapCheckbox:SetPoint("TOPLEFT", 10, row1Y)
    minimapCheckbox:SetSize(26, 26)
    local showMinimap = HDG_Settings.minimap and HDG_Settings.minimap.showMinimapButton
    if showMinimap == nil then showMinimap = true end
    minimapCheckbox:SetChecked(showMinimap)

    local minimapLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    minimapLabel:SetPoint("LEFT", minimapCheckbox, "RIGHT", 5, 0)
    minimapLabel:SetText("|cFFe2e8f0Show Minimap Button|r")

    local minimapHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    minimapHint:SetPoint("TOPLEFT", minimapCheckbox, "BOTTOMLEFT", 26, 2)
    minimapHint:SetText("|cFF888888(Draggable icon around the minimap)|r")

    minimapCheckbox:SetScript("OnClick", function(self)
        local minimap = privateDB.HDG_Minimap
        if minimap and minimap.SetShowMinimapButton then
            minimap.SetShowMinimapButton(self:GetChecked())
        end
    end)

    -- === RIGHT COLUMN ROW 1: Auto-Enable Lumber Tracker ===
    local lumberAutoShowCheckbox = CreateFrame("CheckButton", "HDG_LumberAutoShowCheckbox", scrollChild, "UICheckButtonTemplate")
    lumberAutoShowCheckbox:SetPoint("TOPLEFT", rightColumnX, row1Y)
    lumberAutoShowCheckbox:SetSize(26, 26)
    local autoShow = HDG_Settings.lumberAutoShow
    if autoShow == nil then autoShow = true end
    lumberAutoShowCheckbox:SetChecked(autoShow)

    local lumberAutoShowLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    lumberAutoShowLabel:SetPoint("LEFT", lumberAutoShowCheckbox, "RIGHT", 5, 0)
    lumberAutoShowLabel:SetText("|cFFe2e8f0Auto-Enable Lumber Tracker|r")

    local lumberAutoShowHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    lumberAutoShowHint:SetPoint("TOPLEFT", lumberAutoShowCheckbox, "BOTTOMLEFT", 26, 2)
    lumberAutoShowHint:SetText("|cFF888888(Auto-show tracker when collecting lumber)|r")

    lumberAutoShowCheckbox:SetScript("OnClick", function(self)
        HDG_Settings.lumberAutoShow = self:GetChecked()
    end)

    local row2Y = row1Y - 38

    -- === LEFT COLUMN ROW 2: Addon Compartment ===
    local minimap = privateDB.HDG_Minimap
    local compartmentAvailable = minimap and minimap.IsCompartmentAvailable and minimap.IsCompartmentAvailable()

    local compartmentCheckbox = CreateFrame("CheckButton", "HDG_CompartmentCheckbox", scrollChild, "UICheckButtonTemplate")
    compartmentCheckbox:SetPoint("TOPLEFT", 10, row2Y)
    compartmentCheckbox:SetSize(26, 26)
    local showCompartment = HDG_Settings.minimap and HDG_Settings.minimap.showInCompartment
    if showCompartment == nil then showCompartment = true end
    compartmentCheckbox:SetChecked(showCompartment)

    local compartmentLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    compartmentLabel:SetPoint("LEFT", compartmentCheckbox, "RIGHT", 5, 0)
    compartmentLabel:SetText("|cFFe2e8f0Show in Addon Compartment|r")

    local compartmentHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    compartmentHint:SetPoint("TOPLEFT", compartmentCheckbox, "BOTTOMLEFT", 26, 2)
    compartmentHint:SetText("|cFF888888(Minimap drawer menu - requires /reload)|r")

    if not compartmentAvailable then
        compartmentCheckbox:Disable()
        compartmentCheckbox:SetAlpha(0.5)
        compartmentLabel:SetAlpha(0.5)
        compartmentHint:SetAlpha(0.5)
    end

    compartmentCheckbox:SetScript("OnClick", function(self)
        if HDG_Settings.minimap then
            HDG_Settings.minimap.showInCompartment = self:GetChecked()
        end
        print("|cFFfcd34d[HDG]|r Addon compartment setting changed. Use |cFFFFFFFF/reload|r to apply.")
    end)

    -- === RIGHT COLUMN ROW 2: Auto-Show Lumber Radar ===
    local lumberHUDCheckbox = CreateFrame("CheckButton", "HDG_LumberHUDCheckbox", scrollChild, "UICheckButtonTemplate")
    lumberHUDCheckbox:SetPoint("TOPLEFT", rightColumnX, row2Y)
    lumberHUDCheckbox:SetSize(26, 26)
    local hudEnabled = HDG_Settings.lumberHUDEnabled
    if hudEnabled == nil then hudEnabled = true end
    lumberHUDCheckbox:SetChecked(hudEnabled)

    local lumberHUDLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    lumberHUDLabel:SetPoint("LEFT", lumberHUDCheckbox, "RIGHT", 5, 0)
    lumberHUDLabel:SetText("|cFFe2e8f0Auto-Show Lumber Radar|r")

    local lumberHUDHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    lumberHUDHint:SetPoint("TOPLEFT", lumberHUDCheckbox, "BOTTOMLEFT", 26, 2)
    lumberHUDHint:SetText("|cFF888888(/lumberhud to toggle manually)|r")

    lumberHUDCheckbox:SetScript("OnClick", function(self)
        HDG_Settings.lumberHUDEnabled = self:GetChecked()
        if not self:GetChecked() and privateDB.HDG_LumberHUD then
            privateDB.HDG_LumberHUD.Hide()
        end
    end)

    local row3Y = row2Y - 38

    -- === LEFT COLUMN ROW 3: Profession Window Buttons ===
    local profButtonCheckbox = CreateFrame("CheckButton", "HDG_ProfButtonCheckbox", scrollChild, "UICheckButtonTemplate")
    profButtonCheckbox:SetPoint("TOPLEFT", 10, row3Y)
    profButtonCheckbox:SetSize(26, 26)
    local showProfButtons = HDG_Settings.showProfessionButtons
    if showProfButtons == nil then showProfButtons = true end
    profButtonCheckbox:SetChecked(showProfButtons)

    local profButtonLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    profButtonLabel:SetPoint("LEFT", profButtonCheckbox, "RIGHT", 5, 0)
    profButtonLabel:SetText("|cFFe2e8f0Show Profession Window Buttons|r")

    local profButtonHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    profButtonHint:SetPoint("TOPLEFT", profButtonCheckbox, "BOTTOMLEFT", 26, 2)
    profButtonHint:SetText("|cFF888888(Decor Guide & Filter Decor buttons)|r")

    profButtonCheckbox:SetScript("OnClick", function(self)
        HDG_Settings.showProfessionButtons = self:GetChecked()
        if HDG_UI and HDG_UI.UpdateProfessionButtonVisibility then
            HDG_UI.UpdateProfessionButtonVisibility()
        end
    end)

    -- === RIGHT COLUMN ROW 3: Radar Scale Slider ===
    local radarScaleLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    radarScaleLabel:SetPoint("TOPLEFT", rightColumnX + 26, row3Y)
    radarScaleLabel:SetText("|cFFe2e8f0Radar Scale:|r")

    local radarScaleSlider = CreateFrame("Slider", "HDG_RadarScaleSlider", scrollChild, "OptionsSliderTemplate")
    radarScaleSlider:SetPoint("LEFT", radarScaleLabel, "RIGHT", 8, 0)
    radarScaleSlider:SetSize(100, 16)
    radarScaleSlider:SetMinMaxValues(0.5, 2.5)
    radarScaleSlider:SetValueStep(0.1)
    radarScaleSlider:SetObeyStepOnDrag(true)
    radarScaleSlider:SetValue(HDG_Settings.lumberHUDScale or 1.0)

    radarScaleSlider.Low:SetText("")
    radarScaleSlider.High:SetText("")
    radarScaleSlider.Text:SetText("")

    local radarScaleValueText = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    radarScaleValueText:SetPoint("LEFT", radarScaleSlider, "RIGHT", 6, 0)

    local function UpdateRadarScaleText(value)
        radarScaleValueText:SetText(string.format("|cFF88FF88%.1fx|r", value))
    end
    UpdateRadarScaleText(HDG_Settings.lumberHUDScale or 1.0)

    local radarScaleHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    radarScaleHint:SetPoint("TOPLEFT", rightColumnX + 26, row3Y - 18)
    radarScaleHint:SetText("|cFF888888(0.5x to 2.5x - resize the radar)|r")

    radarScaleSlider:SetScript("OnValueChanged", function(self, value)
        value = math.floor(value * 10 + 0.5) / 10
        HDG_Settings.lumberHUDScale = value
        UpdateRadarScaleText(value)
        if privateDB.HDG_LumberHUD and privateDB.HDG_LumberHUD.UpdateScale then
            privateDB.HDG_LumberHUD.UpdateScale(value)
        end
    end)

    local row4Y = row3Y - 38

    -- === LEFT COLUMN ROW 4: Pin Lumber Tracker ===
    local lumberPinCheckbox = CreateFrame("CheckButton", "HDG_LumberPinCheckbox", scrollChild, "UICheckButtonTemplate")
    lumberPinCheckbox:SetPoint("TOPLEFT", 10, row4Y)
    lumberPinCheckbox:SetSize(26, 26)
    lumberPinCheckbox:SetChecked(HDG_Settings.lumberPinned or false)

    local lumberPinLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    lumberPinLabel:SetPoint("LEFT", lumberPinCheckbox, "RIGHT", 5, 0)
    lumberPinLabel:SetText("|cFFe2e8f0Pin Lumber Tracker|r")

    local lumberPinHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    lumberPinHint:SetPoint("TOPLEFT", lumberPinCheckbox, "BOTTOMLEFT", 26, 2)
    lumberPinHint:SetText("|cFF888888(Floating widget - also via pin button)|r")

    lumberPinCheckbox:SetScript("OnClick", function(self)
        if self:GetChecked() then
            if HDG_LumberTracker and HDG_LumberTracker.ShowPinned then
                HDG_LumberTracker.ShowPinned()
            end
        else
            HDG_Settings.lumberPinned = false
            if HDG_LumberTracker and HDG_LumberTracker.HidePinned then
                HDG_LumberTracker.HidePinned()
            end
            if HDG_UI and HDG_UI.UpdateLumberLayout then
                HDG_UI.UpdateLumberLayout()
            end
        end
    end)

    -- Store reference for external updates
    HDG_ConfigTab.lumberPinCheckbox = lumberPinCheckbox

    -- === RIGHT COLUMN ROW 4: Radar Framerate Slider ===
    local radarFPSLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    radarFPSLabel:SetPoint("TOPLEFT", rightColumnX + 26, row4Y)
    radarFPSLabel:SetText("|cFFe2e8f0Radar FPS:|r")

    local radarFPSSlider = CreateFrame("Slider", "HDG_RadarFPSSlider", scrollChild, "OptionsSliderTemplate")
    radarFPSSlider:SetPoint("LEFT", radarFPSLabel, "RIGHT", 8, 0)
    radarFPSSlider:SetSize(100, 16)
    radarFPSSlider:SetMinMaxValues(10, 30)
    radarFPSSlider:SetValueStep(5)
    radarFPSSlider:SetObeyStepOnDrag(true)
    radarFPSSlider:SetValue(HDG_Settings.lumberHUDFPS or 20)

    radarFPSSlider.Low:SetText("")
    radarFPSSlider.High:SetText("")
    radarFPSSlider.Text:SetText("")

    local radarFPSValueText = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    radarFPSValueText:SetPoint("LEFT", radarFPSSlider, "RIGHT", 6, 0)

    local function UpdateRadarFPSText(value)
        radarFPSValueText:SetText(string.format("|cFF88FF88%d|r", value))
    end
    UpdateRadarFPSText(HDG_Settings.lumberHUDFPS or 20)

    local radarFPSHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    radarFPSHint:SetPoint("TOPLEFT", rightColumnX + 26, row4Y - 18)
    radarFPSHint:SetText("|cFF888888(10-30 fps - smoothness vs CPU)|r")

    radarFPSSlider:SetScript("OnValueChanged", function(self, value)
        value = math.floor(value + 0.5)
        HDG_Settings.lumberHUDFPS = value
        UpdateRadarFPSText(value)
        if privateDB.HDG_LumberHUD and privateDB.HDG_LumberHUD.UpdateFramerate then
            privateDB.HDG_LumberHUD.UpdateFramerate(value)
        end
    end)

    -- Update yOffset to after the 4-row grid
    yOffset = row4Y - 38

    -- Separator after settings grid
    CreateSeparator(yOffset)
    yOffset = yOffset - 18

    -- ========================================
    -- FARMING & CRAFTING QUOTES SECTION
    -- ========================================
    local quotesHeader = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    quotesHeader:SetPoint("TOPLEFT", 10, yOffset)
    quotesHeader:SetText("|cFF14b8a6Farming & Crafting Quotes|r")

    yOffset = yOffset - 20

    -- ========================================
    -- Enable Quotes Master Toggle
    -- ========================================
    local quotesEnabled = HDG_Settings.quotesEnabled
    if quotesEnabled == nil then quotesEnabled = true end

    local quotesCheckbox = CreateFrame("CheckButton", "HDG_QuotesCheckbox", scrollChild, "UICheckButtonTemplate")
    quotesCheckbox:SetPoint("TOPLEFT", 10, yOffset)
    quotesCheckbox:SetSize(26, 26)
    quotesCheckbox:SetChecked(quotesEnabled)

    local quotesLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    quotesLabel:SetPoint("LEFT", quotesCheckbox, "RIGHT", 5, 0)
    quotesLabel:SetText("|cFFe2e8f0Enable Quotes|r")

    local quotesHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    quotesHint:SetPoint("LEFT", quotesLabel, "RIGHT", 8, 0)
    quotesHint:SetText("|cFF888888(Master toggle for quote systems)|r")

    yOffset = yOffset - 24

    -- ========================================
    -- Only Print Quotes to Chat Option
    -- ========================================
    local quotesOnlyChat = HDG_Settings.quotesOnlyChat or false

    local quotesOnlyChatCheckbox = CreateFrame("CheckButton", "HDG_QuotesOnlyChatCheckbox", scrollChild, "UICheckButtonTemplate")
    quotesOnlyChatCheckbox:SetPoint("TOPLEFT", 30, yOffset)  -- Indented under master toggle
    quotesOnlyChatCheckbox:SetSize(26, 26)
    quotesOnlyChatCheckbox:SetChecked(quotesOnlyChat)

    local quotesOnlyChatLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    quotesOnlyChatLabel:SetPoint("LEFT", quotesOnlyChatCheckbox, "RIGHT", 5, 0)
    quotesOnlyChatLabel:SetText("|cFFe2e8f0Only print quotes to chat|r")

    local quotesOnlyChatHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    quotesOnlyChatHint:SetPoint("LEFT", quotesOnlyChatLabel, "RIGHT", 8, 0)
    quotesOnlyChatHint:SetText("|cFF888888(No talking head display)|r")

    quotesOnlyChatCheckbox:SetScript("OnClick", function(self)
        HDG_Settings.quotesOnlyChat = self:GetChecked()
    end)

    yOffset = yOffset - 24

    -- ========================================
    -- Lumber Quotes Sub-Option
    -- ========================================
    local lumberQuotesEnabled = HDG_Settings.lumberQuotesEnabled
    if lumberQuotesEnabled == nil then lumberQuotesEnabled = true end

    local lumberQuotesCheckbox = CreateFrame("CheckButton", "HDG_LumberQuotesCheckbox", scrollChild, "UICheckButtonTemplate")
    lumberQuotesCheckbox:SetPoint("TOPLEFT", 30, yOffset)  -- Indented under master toggle
    lumberQuotesCheckbox:SetSize(26, 26)
    lumberQuotesCheckbox:SetChecked(lumberQuotesEnabled)

    local lumberQuotesLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    lumberQuotesLabel:SetPoint("LEFT", lumberQuotesCheckbox, "RIGHT", 5, 0)
    lumberQuotesLabel:SetText("|cFFe2e8f0Lumber Quotes|r")

    local lumberQuotesHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    lumberQuotesHint:SetPoint("LEFT", lumberQuotesLabel, "RIGHT", 8, 0)
    lumberQuotesHint:SetText("|cFF888888(Vamoose, Squirrel, Gazlowe while lumber farming)|r")

    yOffset = yOffset - 24

    -- Store references for lumber quote sub-options
    local vamooseSlider, vamooseLabel, vamooseValueText, vamooseHint
    local vamooseChatCheckbox, vamooseChatLabel

    -- ========================================
    -- Vamoose Chattiness Slider (under Lumber Quotes)
    -- ========================================
    vamooseLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    vamooseLabel:SetPoint("TOPLEFT", 61, yOffset)  -- Aligned with "Lumber Quotes" label (30 + 26 + 5)
    vamooseLabel:SetText("|cFFe2e8f0Chattiness:|r")

    -- Slider (inline with label)
    vamooseSlider = CreateFrame("Slider", "HDG_VamooseChattinessSlider", scrollChild, "OptionsSliderTemplate")
    vamooseSlider:SetPoint("LEFT", vamooseLabel, "RIGHT", 10, 0)
    vamooseSlider:SetSize(120, 16)
    vamooseSlider:SetMinMaxValues(0, 99)
    vamooseSlider:SetValueStep(1)
    vamooseSlider:SetObeyStepOnDrag(true)
    vamooseSlider:SetValue(HDG_Settings.vamooseChattiness or 30)

    -- Style the slider - hide low/high text, show value instead
    vamooseSlider.Low:SetText("")
    vamooseSlider.High:SetText("")
    vamooseSlider.Text:SetText("")

    -- Current value display (to the right of slider)
    vamooseValueText = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    vamooseValueText:SetPoint("LEFT", vamooseSlider, "RIGHT", 8, 0)

    local function UpdateVamooseValueText(value)
        if value == 0 then
            vamooseValueText:SetText("|cFFFF6666Off|r")
        else
            vamooseValueText:SetText(string.format("|cFF88FF88%d|r", value))
        end
    end

    UpdateVamooseValueText(HDG_Settings.vamooseChattiness or 30)

    vamooseSlider:SetScript("OnValueChanged", function(self, value)
        value = math.floor(value + 0.5)  -- Round to integer
        HDG_Settings.vamooseChattiness = value
        UpdateVamooseValueText(value)
    end)

    vamooseHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    vamooseHint:SetPoint("LEFT", vamooseValueText, "RIGHT", 8, 0)
    vamooseHint:SetText("|cFF888888(0=Off, or quote after 1 to N lumber)|r")

    yOffset = yOffset - 24

    -- ========================================
    -- Craft Quotes Sub-Option
    -- ========================================
    local craftQuotesEnabled = HDG_Settings.craftQuotesEnabled
    if craftQuotesEnabled == nil then craftQuotesEnabled = true end

    local craftQuotesCheckbox = CreateFrame("CheckButton", "HDG_CraftQuotesCheckbox", scrollChild, "UICheckButtonTemplate")
    craftQuotesCheckbox:SetPoint("TOPLEFT", 30, yOffset)  -- Indented under master toggle
    craftQuotesCheckbox:SetSize(26, 26)
    craftQuotesCheckbox:SetChecked(craftQuotesEnabled)

    local craftQuotesLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    craftQuotesLabel:SetPoint("LEFT", craftQuotesCheckbox, "RIGHT", 5, 0)
    craftQuotesLabel:SetText("|cFFe2e8f0Craft Quotes|r")

    local craftQuotesHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    craftQuotesHint:SetPoint("LEFT", craftQuotesLabel, "RIGHT", 8, 0)
    craftQuotesHint:SetText("|cFF888888(When crafting/acquiring decor)|r")

    -- ========================================
    -- Quote Options Update Logic
    -- ========================================
    local function UpdateLumberQuotesSubOptions()
        local enabled = quotesCheckbox:GetChecked() and lumberQuotesCheckbox:GetChecked()
        local alpha = enabled and 1.0 or 0.5

        if vamooseSlider then
            if enabled then vamooseSlider:Enable() else vamooseSlider:Disable() end
            vamooseSlider:SetAlpha(alpha)
        end
        if vamooseLabel then vamooseLabel:SetAlpha(alpha) end
        if vamooseValueText then vamooseValueText:SetAlpha(alpha) end
        if vamooseHint then vamooseHint:SetAlpha(alpha) end
        if vamooseChatCheckbox then
            if enabled then vamooseChatCheckbox:Enable() else vamooseChatCheckbox:Disable() end
            vamooseChatCheckbox:SetAlpha(alpha)
        end
        if vamooseChatLabel then vamooseChatLabel:SetAlpha(alpha) end
    end

    local function UpdateQuotesSubOptions()
        local masterEnabled = quotesCheckbox:GetChecked()
        local subAlpha = masterEnabled and 1.0 or 0.5

        -- Enable/disable "only chat" checkbox
        if masterEnabled then quotesOnlyChatCheckbox:Enable() else quotesOnlyChatCheckbox:Disable() end
        quotesOnlyChatCheckbox:SetAlpha(subAlpha)
        quotesOnlyChatLabel:SetAlpha(subAlpha)
        quotesOnlyChatHint:SetAlpha(subAlpha)

        -- Enable/disable lumber quotes checkbox
        if masterEnabled then lumberQuotesCheckbox:Enable() else lumberQuotesCheckbox:Disable() end
        lumberQuotesCheckbox:SetAlpha(subAlpha)
        lumberQuotesLabel:SetAlpha(subAlpha)
        lumberQuotesHint:SetAlpha(subAlpha)

        -- Enable/disable craft quotes checkbox
        if masterEnabled then craftQuotesCheckbox:Enable() else craftQuotesCheckbox:Disable() end
        craftQuotesCheckbox:SetAlpha(subAlpha)
        craftQuotesLabel:SetAlpha(subAlpha)
        craftQuotesHint:SetAlpha(subAlpha)

        -- Update lumber quote sub-options (slider, chat output)
        UpdateLumberQuotesSubOptions()
    end

    local function SyncMasterQuotesCheckbox()
        -- If both sub-options are unchecked, uncheck master
        local lumberEnabled = lumberQuotesCheckbox:GetChecked()
        local craftEnabled = craftQuotesCheckbox:GetChecked()

        if not lumberEnabled and not craftEnabled then
            quotesCheckbox:SetChecked(false)
            HDG_Settings.quotesEnabled = false
        end

        UpdateQuotesSubOptions()
    end

    quotesCheckbox:SetScript("OnClick", function(self)
        HDG_Settings.quotesEnabled = self:GetChecked()
        UpdateQuotesSubOptions()
    end)

    lumberQuotesCheckbox:SetScript("OnClick", function(self)
        HDG_Settings.lumberQuotesEnabled = self:GetChecked()
        SyncMasterQuotesCheckbox()
    end)

    craftQuotesCheckbox:SetScript("OnClick", function(self)
        HDG_Settings.craftQuotesEnabled = self:GetChecked()
        SyncMasterQuotesCheckbox()
    end)

    -- Apply initial enabled/disabled state based on master toggle
    UpdateQuotesSubOptions()

    yOffset = yOffset - 39
    CreateSeparator(yOffset)
    yOffset = yOffset - 18

    -- ========================================
    -- Locale Override Section
    -- ========================================
    local localeLabel = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    localeLabel:SetPoint("TOPLEFT", 10, yOffset)
    localeLabel:SetText("|cFFe2e8f0" .. (L["LOCALE_OVERRIDE"] or "Language Override") .. ":|r")

    -- Dropdown button
    local localeDropdown = CreateFrame("Frame", "HDG_LocaleDropdown", scrollChild, "BackdropTemplate")
    localeDropdown:SetSize(150, 24)
    localeDropdown:SetPoint("LEFT", localeLabel, "RIGHT", 10, 0)
    localeDropdown:SetBackdrop({
        bgFile = CONFIG.TEXTURES.WHITE_BG,
        edgeFile = CONFIG.TEXTURES.WHITE_BG,
        tile = false,
        edgeSize = 1,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    })
    localeDropdown:SetBackdropColor(0.08, 0.08, 0.1, 1)
    localeDropdown:SetBackdropBorderColor(unpack(HDG_UIHelpers.BORDER_COLOR))

    local localeText = localeDropdown:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
    localeText:SetPoint("LEFT", 8, 0)
    localeText:SetPoint("RIGHT", -20, 0)
    localeText:SetJustifyH("LEFT")
    localeDropdown.text = localeText

    local localeArrow = localeDropdown:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
    localeArrow:SetPoint("RIGHT", -6, 0)
    localeArrow:SetText("v")  -- Simple ASCII arrow (Unicode not supported in WoW fonts)
    localeArrow:SetTextColor(0.6, 0.6, 0.6)

    -- Get available locales and current setting
    local availableLocales = HDG_L:GetAvailableLocales()
    local currentLocale = HDG_Settings.localeOverride or "auto"

    -- Find display name for current locale
    local function GetLocaleDisplayName(code)
        for _, loc in ipairs(availableLocales) do
            if loc.code == code then
                return loc.name
            end
        end
        return code
    end
    localeText:SetText(GetLocaleDisplayName(currentLocale))

    -- Create dropdown menu
    local localeMenu = CreateFrame("Frame", "HDG_LocaleMenu", localeDropdown, "BackdropTemplate")
    localeMenu:SetPoint("TOPLEFT", localeDropdown, "BOTTOMLEFT", 0, -2)
    localeMenu:SetWidth(150)
    localeMenu:SetBackdrop({
        bgFile = CONFIG.TEXTURES.WHITE_BG,
        edgeFile = CONFIG.TEXTURES.WHITE_BG,
        tile = false,
        edgeSize = 1,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    })
    localeMenu:SetBackdropColor(0.1, 0.1, 0.12, 0.98)
    localeMenu:SetBackdropBorderColor(unpack(HDG_UIHelpers.BORDER_COLOR))
    localeMenu:SetFrameStrata("DIALOG")
    localeMenu:Hide()

    -- Create menu items
    local menuYOffset = -4
    for _, loc in ipairs(availableLocales) do
        local item = CreateFrame("Button", nil, localeMenu)
        item:SetHeight(18)
        item:SetPoint("TOPLEFT", 4, menuYOffset)
        item:SetPoint("TOPRIGHT", -4, menuYOffset)

        local itemText = item:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
        itemText:SetPoint("LEFT", 4, 0)
        itemText:SetText(loc.name)
        item.text = itemText

        item:SetScript("OnEnter", function(self)
            self.text:SetTextColor(1, 0.82, 0.3)
        end)
        item:SetScript("OnLeave", function(self)
            self.text:SetTextColor(1, 1, 1)
        end)
        item:SetScript("OnClick", function()
            HDG_Settings.localeOverride = loc.code
            localeText:SetText(loc.name)
            localeMenu:Hide()
            -- Note: Full change requires reload
        end)

        menuYOffset = menuYOffset - 18
    end
    localeMenu:SetHeight(-menuYOffset + 4)

    -- Toggle menu on click
    localeDropdown:EnableMouse(true)
    localeDropdown:SetScript("OnMouseDown", function()
        if localeMenu:IsShown() then
            localeMenu:Hide()
        else
            localeMenu:Show()
        end
    end)

    -- Close menu when clicking elsewhere
    localeMenu:SetScript("OnShow", function()
        localeMenu:SetFrameLevel(100)
    end)

    -- Reload button
    local reloadBtn = CreateFrame("Button", nil, scrollChild, "BackdropTemplate")
    reloadBtn:SetSize(60, 22)
    reloadBtn:SetPoint("LEFT", localeDropdown, "RIGHT", 10, 0)
    reloadBtn:SetBackdrop({
        bgFile = CONFIG.TEXTURES.WHITE_BG,
        edgeFile = CONFIG.TEXTURES.WHITE_BG,
        tile = false,
        edgeSize = 1,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    })
    reloadBtn:SetBackdropColor(0.08, 0.23, 0.23, 1)
    reloadBtn:SetBackdropBorderColor(unpack(HDG_UIHelpers.BORDER_COLOR))

    local reloadText = reloadBtn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    reloadText:SetPoint("CENTER", 0, 0)
    reloadText:SetText("|cFFFFFFFFReload|r")

    reloadBtn:SetScript("OnEnter", function(self)
        self:SetBackdropColor(0.12, 0.35, 0.35, 1)
        GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
        GameTooltip:AddLine("Reload UI", 1, 0.82, 0.3)
        GameTooltip:AddLine("Apply language change immediately", 0.7, 0.7, 0.7)
        GameTooltip:Show()
    end)
    reloadBtn:SetScript("OnLeave", function(self)
        self:SetBackdropColor(0.08, 0.23, 0.23, 1)
        GameTooltip:Hide()
    end)
    reloadBtn:SetScript("OnClick", function()
        ReloadUI()
    end)

    -- Note about locale override limitation
    local localeNote = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    localeNote:SetPoint("TOPLEFT", 10, yOffset - 28)
    localeNote:SetText("|cFF888888" .. (L["LOCALE_NOTE"] or "Only affects addon UI text, not item/recipe names.") .. "|r")

    yOffset = yOffset - 50
    CreateSeparator(yOffset)
    yOffset = yOffset - 18

    -- ========================================
    -- Discord Section
    -- ========================================
    local DISCORD_INVITE = "https://discord.gg/RWZaxJaHFP"

    -- Note about translation contributions (above Discord link)
    local translateNote = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    translateNote:SetPoint("TOPLEFT", 10, yOffset)
    translateNote:SetText("|cFF888888" .. (L["TRANSLATE_NOTE"] or "Help translate! Submit corrections via Discord below.") .. "|r")
    yOffset = yOffset - 18

    -- Discord icon
    local discordIcon = scrollChild:CreateTexture(nil, "ARTWORK")
    discordIcon:SetSize(24, 24)
    discordIcon:SetPoint("TOPLEFT", 10, yOffset)
    discordIcon:SetTexture(CONFIG.ADDON_TEXTURES.DISCORD)

    -- Discord link edit box (copyable)
    local discordEditBox = CreateFrame("EditBox", nil, scrollChild, "BackdropTemplate")
    discordEditBox:SetSize(250, 24)
    discordEditBox:SetPoint("LEFT", discordIcon, "RIGHT", 10, 0)
    discordEditBox:SetBackdrop({
        bgFile = CONFIG.TEXTURES.WHITE_BG,
        edgeFile = CONFIG.TEXTURES.WHITE_BG,
        tile = false,
        edgeSize = 1,
        insets = { left = 0, right = 0, top = 0, bottom = 0 }
    })
    discordEditBox:SetBackdropColor(0.05, 0.05, 0.07, 1)
    discordEditBox:SetBackdropBorderColor(0.35, 0.40, 0.98, 0.6)  -- Discord blurple border
    discordEditBox:SetFontObject("GameFontHighlight")
    discordEditBox:SetText(DISCORD_INVITE)
    discordEditBox:SetAutoFocus(false)
    discordEditBox:SetTextInsets(8, 8, 0, 0)
    discordEditBox:SetScript("OnEditFocusGained", function(self)
        self:HighlightText()
    end)
    discordEditBox:SetScript("OnEscapePressed", function(self)
        self:ClearFocus()
    end)
    discordEditBox:SetScript("OnEnterPressed", function(self)
        self:ClearFocus()
    end)

    -- Hint to the right of the link
    local discordHint = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
    discordHint:SetPoint("LEFT", discordEditBox, "RIGHT", 8, 0)
    discordHint:SetText("|cFF888888Ctrl+C to copy|r")

    yOffset = yOffset - 36
    CreateSeparator(yOffset)
    yOffset = yOffset - 18

    -- ========================================
    -- How to Use Guide
    -- ========================================
    local guideHeader = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
    guideHeader:SetPoint("TOPLEFT", 10, yOffset)
    guideHeader:SetText("|cFF14b8a6How to Use|r")
    yOffset = yOffset - 30

    -- Guide sections with tab explanations
    local guideSections = {
        {
            title = "Recipes Tab",
            lines = {
                "Browse all craftable housing decor organized by profession",
                "Click a recipe to see required materials in the right panel",
                "Click '+' to add items to your crafting queue",
                "|cFFfcd34dGold text|r = known by you, |cFF888888Gray|r = not known by anyone",
                "Toggle 'Raw Mats' to see base gathering materials vs direct recipe mats",
                "Use search box to filter by recipe or material name",
                "Shift-click materials to search in Auctionator",
                "Right-click materials to add to Auctionator shopping list",
                "'Craft These First' section shows intermediate items to craft",
            }
        },
        {
            title = "Crafting Queue",
            lines = {
                "Items automatically grouped by which character can craft them",
                "Your current character's craftable items appear first",
                "'Not Known' section shows recipes none of your alts have",
                "Queue persists across characters - no need to recreate!",
                "Left-click to decrement quantity, right-click to remove",
            }
        },
        {
            title = "Preview Tab",
            lines = {
                "View 3D models of all housing decor items",
                "Drag to rotate models horizontally and vertically",
                "Use Expansion filter + tag to see all decor for that expansion",
                "Example: Filter 'Expansion' then 'Cata' to see all Cata decor",
                "Shift-click any item to add it to your crafting queue",
                "|cFFfcd34dGold Star|r = Known recipe, |cFF888888Gray Check|r = Learnable",
                "Toggle 'Collection' to show ALL decor, not just craftable",
                "Collection view shows live data of what you've collected",
            }
        },
        {
            title = "Alts Tab",
            lines = {
                "View profession skills across all your characters",
                "Colors show if skill meets decor recipe thresholds:",
                "  |cFF2dd4bfTeal|r = Can learn recipes, |cFFfcd34dYellow|r = Below threshold",
                "Hover over skills to see which characters have them",
                "Data updates automatically when you open profession windows",
                "Use the Refresh button to reload all character data",
            }
        },
        {
            title = "Goblin Tab",
            lines = {
                "Analyze profit margins on all housing decor items",
                "Toggle between TSM and Auctionator price sources",
                "Click column headers to sort by profit, margin, etc.",
                "Click a row to expand and see material cost breakdown",
                "Ctrl-click to add profitable items to your queue",
                "Use 'Hide Unprofitable' to focus on money-makers",
                "Red prices = unprofitable, Green prices = profitable",
            }
        },
        {
            title = "Trainers Tab",
            lines = {
                "Find profession trainers for any expansion",
                "Click the waypoint icon to set a TomTom destination",
                "Trainers listed by profession with coordinates",
                "Requires TomTom addon for waypoint functionality",
            }
        },
        {
            title = "Data Tab",
            lines = {
                "View your crafting and acquisition history",
                "Track lumber farming sessions with rate statistics",
                "Export data to CSV for spreadsheet analysis",
                "Click column headers to sort history entries",
                "Session history shows items per hour farming rates",
            }
        },
        {
            title = "Lumber Tracker",
            lines = {
                "Pin the lumber widget to track inventory while playing",
                "Farming sessions start automatically when you gather lumber",
                "Ctrl-click any material in recipes to add to tracking",
                "Focus mode hides other rows while actively farming an item",
                "'Needed' column shows quantity required for your queue",
                "'All Recipes' column shows quantity for all uncollected decor",
            }
        },
        {
            title = "Lumber Radar HUD",
            lines = {
                "A circular radar that tracks your lumber gathering locations",
                "and helps you plan efficient farming routes based on respawn timers.",
                "",
                "|cFFfcd34dHow It Works:|r",
                "  You are always at the center (green dot with direction line)",
                "  Blips show locations where you've gathered lumber",
                "  N/E/S/W labels rotate as you turn - always shows true north",
                "  Blips move around you as you move and rotate",
                "",
                "|cFFfcd34dBlip Colors (Respawn Tracking):|r",
                "  |cFFff3333Red|r = Just cut (0-5 min) - don't return yet",
                "  |cFFffff00Yellow|r = Respawning (5-9 min) - almost ready",
                "  |cFF00ff00Green (pulsing)|r = Ready! (9-10+ min) - safe to return",
                "  |cFF888888Grey (faded)|r = Old (1+ hour) - stale data",
                "",
                "|cFFfcd34dDistance Rings:|r",
                "  Inner ring = 150 yards",
                "  Outer ring = 300 yards",
                "  Maximum range = 450 yards",
                "",
                "|cFFfcd34dConfiguration (in Config tab):|r",
                "  Radar Scale: 0.5x to 2.5x - resize the display",
                "  Radar Framerate: 10-30 fps - balance smoothness vs CPU",
                "",
                "|cFFfcd34dUsage Tips:|r",
                "  Drag the radar to reposition it on screen",
                "  Fly toward green blips - they approach center as you get closer",
                "  Avoid red areas - those nodes are depleted",
                "  Plan circular routes: by the time you return, nodes respawn!",
                "  Routes can be smaller than you think - respawns are fast!",
                "  You can farm efficiently in a circle not much bigger than the radar",
                "",
                "|cFFfcd34dCommands:|r",
                "  |cFF2dd4bf/lumberhud|r or |cFF2dd4bf/hdg hud|r - Toggle radar",
            }
        },
        {
            title = "Example Workflow",
            lines = {
                "Want to craft all Cata decor? Here's how:",
                "1. Go to Preview tab, select 'Expansion' filter, then 'Cata' tag",
                "2. Shift-click each item to add to your crafting queue",
                "3. Switch back to Recipes tab - all items sorted by crafter!",
                "4. Queue persists across characters, no need to recreate",
                "",
                "Want to see ALL decor (not just craftable)?",
                "Toggle 'Collection' in Preview - shows live collection data",
            }
        },
        {
            title = "Tips & Tricks",
            lines = {
                "|cFFfcd34dProfession Window Buttons:|r Open any profession window and",
                "look for 'Filter Decor' and 'Decor Guide' buttons at the top!",
                "  - |cFF2dd4bfFilter Decor|r: Filters to only housing decor items",
                "  - |cFF2dd4bfDecor Guide|r: Opens this addon at that profession",
                "",
                "|cFFfcd34dLumber Auto-Show:|r The lumber tracker automatically appears",
                "when you start farming wood (can be disabled in settings above)",
            }
        },
    }

    for _, section in ipairs(guideSections) do
        -- Section header
        local sectionTitle = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
        sectionTitle:SetPoint("TOPLEFT", 15, yOffset)
        sectionTitle:SetText("|cFFfcd34d" .. section.title .. "|r")
        yOffset = yOffset - 22

        -- Section lines
        for _, line in ipairs(section.lines) do
            local lineText = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
            lineText:SetPoint("TOPLEFT", 30, yOffset)
            lineText:SetWidth(CONFIG.MAIN_FRAME_WIDTH - 100)
            lineText:SetJustifyH("LEFT")
            lineText:SetText("|cFFe2e8f0- " .. line .. "|r")
            yOffset = yOffset - 18
        end

        yOffset = yOffset - 10
    end

    yOffset = yOffset - 10
    CreateSeparator(yOffset)
    yOffset = yOffset - 15

    -- ========================================
    -- Contributors Section (v2.0.2)
    -- ========================================
    local contributorsHeader = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
    contributorsHeader:SetPoint("TOPLEFT", 10, yOffset)
    contributorsHeader:SetText("|cFF5865F2Special Thanks|r")

    yOffset = yOffset - 25

    -- Contributors message
    local contributorsMsg = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    contributorsMsg:SetPoint("TOPLEFT", 10, yOffset)
    contributorsMsg:SetWidth(CONFIG.MAIN_FRAME_WIDTH - 80)
    contributorsMsg:SetJustifyH("LEFT")
    contributorsMsg:SetText("|cFFe2e8f0This addon wouldn't be possible without the amazing community. " ..
        "Special thanks to the following contributors for their feedback, bug reports, and feature suggestions:|r")

    yOffset = yOffset - 50

    -- Contributors list
    local contributors = {
        {name = "Abased", note = "Feature requests & testing"},
        {name = "Filurina", note = "Quality variant bug report"},
        {name = "Fracture93", note = "Goblin Mode feature suggestion"},
        {name = "JodouKast", note = "Community support"},
        {name = "Jonnyne", note = "Early adopter & support"},
        {name = "Rylls", note = "Bug reports & UX feedback"},
    }

    for _, contributor in ipairs(contributors) do
        local line = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
        line:SetPoint("TOPLEFT", 20, yOffset)
        line:SetText(string.format("|cFF2dd4bf-|r |cFFfcd34d%s|r |cFF64748b- %s|r", contributor.name, contributor.note))
        yOffset = yOffset - 18
    end

    yOffset = yOffset - 15

    -- Join us message
    local joinMsg = scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    joinMsg:SetPoint("TOPLEFT", 10, yOffset)
    joinMsg:SetWidth(CONFIG.MAIN_FRAME_WIDTH - 80)
    joinMsg:SetJustifyH("LEFT")
    joinMsg:SetText("|cFF64748bWant to contribute? Join our Discord or report issues on CurseForge!|r")

    yOffset = yOffset - 30

    -- Update scroll child height based on content
    local contentHeight = math.abs(yOffset) + 50
    scrollChild:SetHeight(contentHeight)

    return configFrame
end

-- ============================================================================
-- UPDATE FUNCTIONS
-- ============================================================================

-- Update lumber pin checkbox to match current setting
function HDG_ConfigTab.UpdateLumberPinCheckbox()
    if HDG_ConfigTab.lumberPinCheckbox then
        HDG_ConfigTab.lumberPinCheckbox:SetChecked(HDG_Settings.lumberPinned or false)
    end
end

-- ============================================================================
-- EXPORT TO GLOBAL
-- ============================================================================

_G.HDG_ConfigTab = HDG_ConfigTab

return HDG_ConfigTab
