local addonName, SinsToolkit = ...

SinsToolkit.UI = SinsToolkit.UI or {}
SinsToolkit.UI.Pages = SinsToolkit.UI.Pages or {}

local PageBase = SinsToolkit.UI.Pages.Base or {}
local Helpers = SinsToolkit.UI.Pages.Helpers or {}
local Page = {}
setmetatable(Page, { __index = PageBase })
SinsToolkit.UI.Pages.UITweaks = Page
Page.density = Helpers.GetDefaultDensity and Helpers.GetDefaultDensity() or "compact"

function Page:Create(CreateScrollablePage, Window, CreateWrappedText)
    local getGV = Helpers.GetGV
    local setGV = Helpers.SetGV

    local tweaksPage = Helpers.CreateContentPage(Window, "UI Tweaks")
    local twHeader = Window:CreateSectionHeader(tweaksPage, "UI Tweaks & Automation")
    CreateWrappedText(tweaksPage, {"TOPLEFT", twHeader, "BOTTOMLEFT", 0, -8}, 720, "Small interface behavior changes and optional automation helpers. This page keeps supported Blizzard panels open, cleans up repeated interactions, and keeps the Druid form helpers in one place.", "GameFontHighlightSmall")
    local cbPanels = Window:CreateCheckbox(tweaksPage, "No Auto Close Panels", getGV("keepPanelsOpen"), setGV("keepPanelsOpen"), "Uses Sin's Toolkit No Auto Close behavior so standard Blizzard UI panels can stay open together. Reload after disabling if a Blizzard panel keeps its old position.")
    cbPanels:SetPoint("TOPLEFT", twHeader, "BOTTOMLEFT", 0, -48)
    CreateWrappedText(tweaksPage, {"TOPLEFT", cbPanels, "BOTTOMLEFT", 0, -10}, 600, "Keeps supported Blizzard panels open together using Sin's Toolkit standalone panel handling.", "GameFontHighlightSmall")
    local cbAutoGossipTweaks = Window:CreateCheckbox(tweaksPage, "Automate Gossip", getGV("automateGossip"), setGV("automateGossip"), "Automatically selects safe single-option gossip while avoiding city direction, trainer, bank, auction house, and storyteller-style gossip.")
    cbAutoGossipTweaks:SetPoint("TOPLEFT", cbPanels, "BOTTOMLEFT", 0, -48)
    local btnGossipModTweaks = Helpers.CreateOptionGroup(Window, tweaksPage, "Gossip Bypass Modifier", Helpers.MODIFIER_OPTIONS, getGV("automateGossipModifier"), setGV("automateGossipModifier"), "Hold this modifier key to temporarily bypass auto-gossip. None means auto-gossip has no modifier bypass.")
    btnGossipModTweaks:SetPoint("TOPLEFT", cbAutoGossipTweaks, "BOTTOMLEFT", 4, -16)
    local cbAutoUnshiftTweaks = Window:CreateCheckbox(tweaksPage, "Auto Unshift for Druids", getGV("gseAutoUnshift"), setGV("gseAutoUnshift"), Helpers.AUTO_UNSHIFT_TOOLTIP)
    cbAutoUnshiftTweaks:SetPoint("TOPLEFT", btnGossipModTweaks, "BOTTOMLEFT", -4, -16)
    local cbFlightTweaks = Window:CreateCheckbox(tweaksPage, "Druid Auto Flight Form", getGV("druidAutoFlightForm"), setGV("druidAutoFlightForm"), "When you are a Druid in ground Travel Form and move into an outdoor flyable area, Sin's Toolkit helps move you toward Flight Form on your next safe travel-form action. It never runs in combat, instances, challenge modes, while flying, or while submerged.")
    cbFlightTweaks:SetPoint("TOPLEFT", cbAutoUnshiftTweaks, "BOTTOMLEFT", 0, -8)

    self.frame = tweaksPage
    return tweaksPage
end

Page:Register("UI Tweaks")

return Page