if not AiB_Content then AiB_Content = {} end

AiB_Content["Sprocketmonger Lockenstock"] = function(frame)
    local container = CreateFrame("Frame", nil, frame)
    container:SetAllPoints()

    -----------------------------------------------------------------------
    -- TITEL
    -----------------------------------------------------------------------
    local title = container:CreateFontString(nil, "OVERLAY")
    title:SetFont("Fonts\\ARIALN.TTF", 14, "OUTLINE")
    title:SetText("Sprocketmonger Lockenstock")
    title:SetTextColor(1, 1, 1, 1)
    title:SetPoint("TOP", container, "TOP", 0, -20)

    -----------------------------------------------------------------------
    -- GROSSES BILD LINKS (Beispiel: 360×400)
    -- Passe Dateiname / Größe nach deinen Dateien an.
    -----------------------------------------------------------------------
    local bigImage = container:CreateTexture(nil, "ARTWORK")
    bigImage:SetTexture("Interface\\AddOns\\AiB\\textures\\sheet\\aib_sprocket.tga")
    bigImage:SetSize(360, 530)
    bigImage:SetPoint("TOPLEFT", container, "TOPLEFT", 10, -60)
    bigImage:EnableMouse(true)
    bigImage:SetScript("OnMouseUp", function(self, button)
        if button == "LeftButton" then
            local popup = CreateFrame("Frame", "AiB_ImagePopup", UIParent, "BackdropTemplate")
            popup:SetSize(800, 1178)  -- Beispiel: 800 × 888
            popup:SetPoint("CENTER")
            popup:SetFrameStrata("FULLSCREEN_DIALOG")
            popup:SetFrameLevel(100)
            popup:SetToplevel(true)
            popup:SetMovable(true)
            popup:EnableMouse(true)
            popup:RegisterForDrag("LeftButton")
            popup:SetScript("OnDragStart", popup.StartMoving)
            popup:SetScript("OnDragStop", popup.StopMovingOrSizing)
            popup:Raise()

            popup:SetBackdrop({
                bgFile = "Interface\\Buttons\\WHITE8x8",
                edgeFile = "Interface\\Buttons\\WHITE8x8",
                edgeSize = 2,
                insets = { left = 2, right = 2, top = 2, bottom = 2 }
            })
            popup:SetBackdropBorderColor(1, 1, 1, 1)
            popup:SetBackdropColor(0.2, 0.2, 0.2, 1)

            local popupImage = popup:CreateTexture(nil, "ARTWORK")
            popupImage:SetTexture("Interface\\AddOns\\AiB\\textures\\sheet\\aib_sprocket.tga")
            popupImage:SetSize(800, 1178)  -- Entspr. dem Popup-Fenster
            popupImage:SetPoint("CENTER", popup, "CENTER", 0, 0)

            local closeButton = CreateFrame("Button", nil, popup, "UIPanelCloseButton")
            closeButton:SetPoint("TOPRIGHT", popup, "TOPRIGHT", -5, -5)
        end
    end)

    -----------------------------------------------------------------------
    -- MARKER-BILD (300×170) – RECHTS VOM GROSSEN BILD
    -----------------------------------------------------------------------
    local markerImage = container:CreateTexture(nil, "ARTWORK")
    markerImage:SetTexture("Interface\\AddOns\\AiB\\textures\\marker\\aib_sprocket_marker.tga")
    markerImage:SetSize(300, 334)
    markerImage:SetPoint("TOPLEFT", bigImage, "TOPRIGHT", 30, 0)
    markerImage:EnableMouse(true)
    markerImage:SetScript("OnMouseUp", function(self, button)
        if button == "LeftButton" then
            local popup = CreateFrame("Frame", "AiB_MarkerPopup", UIParent, "BackdropTemplate")
            popup:SetSize(800, 891)  -- Beispiel: 1380 × 770
            popup:SetPoint("CENTER")
            popup:SetFrameStrata("FULLSCREEN_DIALOG")
            popup:SetFrameLevel(100)
            popup:SetToplevel(true)
            popup:SetMovable(true)
            popup:EnableMouse(true)
            popup:RegisterForDrag("LeftButton")
            popup:SetScript("OnDragStart", popup.StartMoving)
            popup:SetScript("OnDragStop", popup.StopMovingOrSizing)
            popup:Raise()

            popup:SetBackdrop({
                bgFile = "Interface\\Buttons\\WHITE8x8",
                edgeFile = "Interface\\Buttons\\WHITE8x8",
                edgeSize = 2,
                insets = { left = 2, right = 2, top = 2, bottom = 2 }
            })
            popup:SetBackdropBorderColor(1, 1, 1, 1)
            popup:SetBackdropColor(0.2, 0.2, 0.2, 1)

            local popupImage = popup:CreateTexture(nil, "ARTWORK")
            popupImage:SetTexture("Interface\\AddOns\\AiB\\textures\\marker\\aib_sprocket_marker.tga")
            popupImage:SetSize(800, 891)
            popupImage:SetPoint("CENTER", popup, "CENTER", 0, 0)

            local closeButton = CreateFrame("Button", nil, popup, "UIPanelCloseButton")
            closeButton:SetPoint("TOPRIGHT", popup, "TOPRIGHT", -5, -5)
        end
    end)

    -----------------------------------------------------------------------
    -- RAIDCOMP & BL TIMING – RECHTS VOM MARKER-BILD
    -----------------------------------------------------------------------
    local headingRaidcomp = container:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
    headingRaidcomp:SetText("Raidcomp & BL Timing")
    headingRaidcomp:SetTextColor(1, 1, 1, 1)
    headingRaidcomp:SetPoint("TOPLEFT", markerImage, "TOPRIGHT", 30, 0)

    -- Unterüberschrift: "Raidcomp"
    local subheadingRaidcomp = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    subheadingRaidcomp:SetText("Raidcomp")
    subheadingRaidcomp:SetTextColor(1, 1, 1, 1)
    subheadingRaidcomp:SetPoint("TOPLEFT", headingRaidcomp, "BOTTOMLEFT", 0, -10)

    -- Tanks
    local lineTanks = CreateFrame("Frame", nil, container)
    lineTanks:SetSize(200, 20)
    lineTanks:SetPoint("TOPLEFT", subheadingRaidcomp, "BOTTOMLEFT", 0, -5)

    local iconTanks = lineTanks:CreateTexture(nil, "ARTWORK")
    iconTanks:SetTexture("Interface\\AddOns\\AiB\\textures\\icons\\tank.tga")
    iconTanks:SetSize(20, 20)
    iconTanks:SetPoint("LEFT", lineTanks, "LEFT", 0, 0)

    local textTanks = lineTanks:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    textTanks:SetText("Tanks 2")
    textTanks:SetTextColor(1, 1, 1, 1)
    textTanks:SetPoint("LEFT", iconTanks, "RIGHT", 5, 0)

    -- Healer
    local lineHealer = CreateFrame("Frame", nil, container)
    lineHealer:SetSize(200, 20)
    lineHealer:SetPoint("TOPLEFT", lineTanks, "BOTTOMLEFT", 0, -5)

    local iconHealer = lineHealer:CreateTexture(nil, "ARTWORK")
    iconHealer:SetTexture("Interface\\AddOns\\AiB\\textures\\icons\\healer.tga")
    iconHealer:SetSize(20, 20)
    iconHealer:SetPoint("LEFT", lineHealer, "LEFT", 0, 0)

    local textHealer = lineHealer:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    textHealer:SetText("Healer 4")
    textHealer:SetTextColor(1, 1, 1, 1)
    textHealer:SetPoint("LEFT", iconHealer, "RIGHT", 5, 0)

    -- DPS
    local lineDPS = CreateFrame("Frame", nil, container)
    lineDPS:SetSize(250, 20)
    lineDPS:SetPoint("TOPLEFT", lineHealer, "BOTTOMLEFT", 0, -5)

    local iconRDPS = lineDPS:CreateTexture(nil, "ARTWORK")
    iconRDPS:SetTexture("Interface\\AddOns\\AiB\\textures\\icons\\rdps.tga")
    iconRDPS:SetSize(20, 20)
    iconRDPS:SetPoint("LEFT", lineDPS, "LEFT", 0, 0)

    local iconMDPS = lineDPS:CreateTexture(nil, "ARTWORK")
    iconMDPS:SetTexture("Interface\\AddOns\\AiB\\textures\\icons\\mdps.tga")
    iconMDPS:SetSize(20, 20)
    iconMDPS:SetPoint("LEFT", iconRDPS, "RIGHT", 5, 0)

    local textDPS = lineDPS:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    textDPS:SetText("Dps 14")
    textDPS:SetTextColor(1, 1, 1, 1)
    textDPS:SetPoint("LEFT", iconMDPS, "RIGHT", 5, 0)

    -- BL Timing
    local subheadingBLTiming = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    subheadingBLTiming:SetText("BL Timing")
    subheadingBLTiming:SetTextColor(1, 1, 1, 1)
    subheadingBLTiming:SetPoint("TOPLEFT", lineDPS, "BOTTOMLEFT", 0, -10)

    local lineBL = CreateFrame("Frame", nil, container)
    lineBL:SetSize(300, 20)
    lineBL:SetPoint("TOPLEFT", subheadingBLTiming, "BOTTOMLEFT", 0, -5)

    local iconBL = lineBL:CreateTexture(nil, "ARTWORK")
    iconBL:SetTexture("Interface\\AddOns\\AiB\\textures\\icons\\bloodlust.tga")
    iconBL:SetSize(20, 20)
    iconBL:SetPoint("LEFT", lineBL, "LEFT", 0, 0)

    local textBL = lineBL:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    textBL:SetText("Bloodlust at Pull!")
    textBL:SetTextColor(1, 1, 1, 1)
    textBL:SetPoint("LEFT", iconBL, "RIGHT", 5, 0)

    local lastRaidInfoLine = lineBL

    -----------------------------------------------------------------------
    -- WEB-LINKS (Finale Version)
    -----------------------------------------------------------------------
    local links = {
        { name = "Boss-Taktik",      url = "https://www.wowhead.com/guide/the-war-within/raids/liberation-of-undermine/sprocketmonger-boss-strategy" },
        { name = "Log-Analyse Dps",  url = "https://www.warcraftlogs.com/zone/rankings/42?boss=3013" },
        { name = "Log-Analyse Heal", url = "https://www.warcraftlogs.com/zone/rankings/42?boss=3013&metric=hps" },
        { name = "Raid-Plan",        url = "https://raidplan.io/plan/MskVl_NcaAL9OvcK" }
    }

    local lastAnchor = nil
    for i, link in ipairs(links) do
        local urlButton = CreateFrame("Button", nil, container, "UIPanelButtonTemplate")
        urlButton:SetText(link.name)
        urlButton:GetFontString():SetTextColor(1, 1, 1)
        urlButton:SetSize(160, 30)
        urlButton:SetNormalFontObject("GameFontNormal")
        urlButton:SetHighlightFontObject("GameFontHighlight")

        local urlButtonBg = urlButton:CreateTexture(nil, "BACKGROUND")
        urlButtonBg:SetAllPoints()
        urlButtonBg:SetColorTexture(0.1, 0.1, 0.1, 1)
        urlButton.bg = urlButtonBg

        if i == 1 then
            urlButton:SetPoint("TOPLEFT", lastRaidInfoLine, "BOTTOMLEFT", 0, -20)
        else
            urlButton:SetPoint("TOPLEFT", lastAnchor, "BOTTOMLEFT", 0, -5)
        end
        lastAnchor = urlButton

        urlButton:SetScript("OnClick", function()
            if AiB_LinkPopup then
                AiB_LinkPopup:Hide()
            end

            local popup = CreateFrame("Frame", "AiB_LinkPopup", UIParent, "BackdropTemplate")
            popup:SetSize(500, 200)
            popup:SetPoint("CENTER")
            popup:SetFrameStrata("FULLSCREEN_DIALOG")
            popup:SetFrameLevel(100)
            popup:SetToplevel(true)
            popup:SetMovable(true)
            popup:EnableMouse(true)
            popup:RegisterForDrag("LeftButton")
            popup:SetScript("OnDragStart", popup.StartMoving)
            popup:SetScript("OnDragStop", popup.StopMovingOrSizing)
            popup:Raise()

            popup:SetBackdrop({
                bgFile = "Interface\\Buttons\\WHITE8x8",
                edgeFile = "Interface\\Buttons\\WHITE8x8",
                edgeSize = 2,
                insets = { left = 2, right = 2, top = 2, bottom = 2 }
            })
            popup:SetBackdropBorderColor(1, 1, 1, 1)
            popup:SetBackdropColor(0.2, 0.2, 0.2, 1)

            local popupTitle = popup:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
            popupTitle:SetPoint("TOP", popup, "TOP", 0, -10)
            popupTitle:SetText("Kopiere den Link")

            local editBox = CreateFrame("EditBox", nil, popup, "InputBoxTemplate")
            editBox:SetSize(400, 30)
            editBox:SetPoint("CENTER", popup, "CENTER", 0, 20)
            editBox:SetAutoFocus(true)
            editBox:SetText(link.url)
            editBox:HighlightText()

            local closeButton = CreateFrame("Button", nil, popup, "UIPanelCloseButton")
            closeButton:SetPoint("TOPRIGHT", popup, "TOPRIGHT", -5, -5)
            closeButton:SetScript("OnClick", function() popup:Hide() end)

            local closeButtonBottom = CreateFrame("Button", nil, popup, "UIPanelButtonTemplate")
            closeButtonBottom:SetSize(140, 40)
            local buttonBg = closeButtonBottom:CreateTexture(nil, "BACKGROUND")
            buttonBg:SetColorTexture(0.2, 0.2, 0.2, 1)
            buttonBg:SetAllPoints()
            closeButtonBottom:SetNormalTexture(buttonBg)

            local buttonText = closeButtonBottom:CreateFontString(nil, "OVERLAY")
            buttonText:SetFont("Fonts\\ARIALN.TTF", 18, "OUTLINE")
            buttonText:SetTextColor(0.6, 0, 0, 1)
            buttonText:SetText("Schließen")
            buttonText:SetPoint("CENTER", closeButtonBottom, "CENTER")
            closeButtonBottom:SetFontString(buttonText)
            closeButtonBottom:SetPoint("BOTTOM", popup, "BOTTOM", 0, 10)
            closeButtonBottom:SetScript("OnClick", function() popup:Hide() end)

            -- Escape/Enter Handling
            editBox:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
            editBox:SetScript("OnEnterPressed", function(self) self:HighlightText() end)

            AiB_LinkPopup = popup
        end)
    end
end
