local API = rawget(_G, "LIDCOUNCIL_API")
local INTERNAL_API = type(API) == "table" and type(API.__internal) == "table" and API.__internal or nil
if type(INTERNAL_API) ~= "table" then
  error("LidCouncil missing internal API registry.")
end

INTERNAL_API.LIDCOUNCIL_CreateLootProfileLayoutHelpers_Impl = function(deps)
  deps = type(deps) == "table" and deps or {}

  local RootDB = deps.RootDB
  local GetResponsiveSectionLayout = deps.GetResponsiveSectionLayout
  local ClampLayoutValue = deps.ClampLayoutValue
  local SetControlWidth = deps.SetControlWidth
  local GetFontStringWidth = deps.GetFontStringWidth
  local FlowLayoutControls = deps.FlowLayoutControls
  local LayoutRollOptionRow = deps.LayoutRollOptionRow
  local LayoutPointRuleRow = deps.LayoutPointRuleRow
  local LayoutLidTableEditorRow = deps.LayoutLidTableEditorRow
  local TrimText = deps.TrimText

  local function RaiseDropdownControl(control, frameLevel)
    if not control then
      return
    end
    if control.SetFrameLevel then
      control:SetFrameLevel(frameLevel)
    end
    if control.button and control.button.SetFrameLevel then
      control.button:SetFrameLevel(frameLevel + 1)
    end
  end

  local function LayoutProfileContent(self, page)
    if not self or not self.lootProfilesRightContent then
      return
    end

    local _, navWidth = GetResponsiveSectionLayout(page, 240, 180, 300, 0.28)
    local navContentWidth = math.max(132, navWidth - 34)
    local profileRowWidth = math.max(116, navContentWidth - 16)
    local addButtonWidth = math.max(62, math.floor((navWidth - 24) / 2))
    local contentWidth = math.max(260, math.floor((self.lootProfilesRightScroll and self.lootProfilesRightScroll:GetWidth() or 560) - 28))
    local textWidth = math.max(220, contentWidth - 36)
    local raidLabelWidth = GetFontStringWidth(self.lootRaidLabel, 84)
    local pointModeLabelWidth = GetFontStringWidth(self.lootPointModeLabel, 92)
    local rollTemplateLabelWidth = GetFontStringWidth(self.lootRollTemplateLabel, 106)
    local raidWidth = ClampLayoutValue(textWidth - raidLabelWidth - 8 - 10 - (self.lootSaveRaidBtn and self.lootSaveRaidBtn:GetWidth() or 96), 120, 260)
    local rollTemplateWidth = ClampLayoutValue(textWidth - rollTemplateLabelWidth - 8, 160, 240)
    local pointModeWidth = ClampLayoutValue(textWidth - pointModeLabelWidth - 8, 120, 180)
    local pointLevelWidth = ClampLayoutValue(math.floor(textWidth * 0.16), 46, 72)
    local pointValueWidth = ClampLayoutValue(math.floor(textWidth * 0.18), 46, 70)
    local pointRuleActionWidth = ClampLayoutValue(math.floor(textWidth * 0.24), 100, 140)
    local pointFormCompact = textWidth < 300
    local pointItemWidth = textWidth - pointValueWidth - pointRuleActionWidth - 20
    if pointFormCompact then
      pointItemWidth = textWidth - pointValueWidth - 10
    end
    pointItemWidth = ClampLayoutValue(pointItemWidth, 88, 280)
    local rollEditWidth = ClampLayoutValue(math.floor(textWidth * 0.42), 120, 220)
    local rollPreviewGap = 18
    local rollPreviewSideBySide = textWidth >= 960
    local rollEditorWidth = rollPreviewSideBySide and math.max(600, math.floor((textWidth - rollPreviewGap) * 0.63)) or textWidth
    local rollPreviewWidth = rollPreviewSideBySide and math.max(320, textWidth - rollEditorWidth - rollPreviewGap) or textWidth
    local useRollSettingsTools = self.lootRollSettingsToolsDropdown and self.lootRollSettingsToolsDropdown.__lidcouncilCustomDropdown
    local rollToolsInline = rollEditorWidth >= 620
    local sectionWidth = textWidth + 16
    local heroPreviewRatio = 0.41
    if sectionWidth < 560 then
      heroPreviewRatio = 0.24
    elseif sectionWidth < 680 then
      heroPreviewRatio = 0.29
    elseif sectionWidth < 820 then
      heroPreviewRatio = 0.35
    end
    local heroPreviewWidth = ClampLayoutValue(math.floor(sectionWidth * heroPreviewRatio), 210, 390)
    local heroTextWidth = math.max(180, sectionWidth - heroPreviewWidth - 34)
    local heroActionButtonWidth = ClampLayoutValue(math.min(heroTextWidth - 16, 144), 110, 144)
    local masterInfoWidth = ClampLayoutValue(textWidth - 226, 110, textWidth - 74)
    local lidPointsWidth, lidItemLevelWidth, lidSetPieceWidth, lidOffSpecWidth, lidTransmogWidth, lidDisenchantWidth
    local heroButtonsHeight

    if self.lootProfilesNavBg then
      self.lootProfilesNavBg:SetWidth(navWidth)
    end
    if self.lootProfilesListContent then
      self.lootProfilesListContent:SetWidth(navContentWidth)
    end
    if self.lootProfilesPageText then
      self.lootProfilesPageText:SetWidth(math.max(48, navWidth - 152))
    end
    if self.lootAddGroupBtn then
      self.lootAddGroupBtn:SetWidth(addButtonWidth)
    end
    if self.lootAddProfileBtn then
      self.lootAddProfileBtn:SetWidth(addButtonWidth)
      self.lootAddProfileBtn:ClearAllPoints()
      self.lootAddProfileBtn:SetPoint("LEFT", self.lootAddGroupBtn, "RIGHT", 8, 0)
    end
    if self.lootDeleteGroupBtn then
      self.lootDeleteGroupBtn:SetWidth(addButtonWidth)
    end
    if self.lootDeleteProfileBtn then
      self.lootDeleteProfileBtn:SetWidth(addButtonWidth)
      self.lootDeleteProfileBtn:ClearAllPoints()
      self.lootDeleteProfileBtn:SetPoint("LEFT", self.lootDeleteGroupBtn, "RIGHT", 8, 0)
    end
    if self.lootProfilesFeedback then
      self.lootProfilesFeedback:SetWidth(navWidth - 16)
    end
    for _, button in ipairs(self.lootProfileButtons or {}) do
      local row = button.__row
      if row and row.type == "profile" then
        button:SetWidth(profileRowWidth)
      else
        button:SetWidth(navContentWidth)
      end
    end

    SetControlWidth(self.lootProfileSummary, heroTextWidth - 16)
    SetControlWidth(self.lootProfileStatusDetail, heroTextWidth - 16)
    SetControlWidth(self.lootRaidHint, textWidth)
    SetControlWidth(self.lootRollOptionsText, textWidth)
    SetControlWidth(self.lootPointRulesText, textWidth)
    SetControlWidth(self.lootProfileAccessSummary, textWidth - 16)
    SetControlWidth(self.lootRaidDropdown, raidWidth)
    SetControlWidth(self.lootRollTemplateDropdown, rollTemplateWidth)
    SetControlWidth(self.lootPointModeDropdown, pointModeWidth)
    SetControlWidth(self.lootPointItemLevelEdit, pointLevelWidth)
    SetControlWidth(self.lootPointItemDropdown, pointItemWidth)
    SetControlWidth(self.lootPointLevelValueEdit or self.lootPointValueEdit, pointValueWidth)
    SetControlWidth(self.lootPointItemValueEdit, pointValueWidth)
    SetControlWidth(self.lootAddPointRuleBtn, pointRuleActionWidth)
    SetControlWidth(self.lootAddItemPointRuleBtn, pointRuleActionWidth)
    SetControlWidth(self.lootRemovePointRuleBtn, pointRuleActionWidth)
    SetControlWidth(self.lootRollOptionEdit, rollEditWidth)
    SetControlWidth(self.lootProfileMasterCardValue, masterInfoWidth)
    SetControlWidth(self.lootProfileMasterCardMeta, masterInfoWidth)
    SetControlWidth(self.lootProfileCouncilCardValue, textWidth - 24)
    SetControlWidth(self.lootProfileCouncilCardMeta, textWidth - 24)
    SetControlWidth(self.lootProfileRaiderSummary, textWidth - 24)
    SetControlWidth(self.lootProfilePermissionPolicySummary, textWidth - 16)
    SetControlWidth(self.lootProfileHeroRaidPreviewLabel, heroPreviewWidth - 20)
    SetControlWidth(self.lootProfileHeroRaidPreviewEmpty, heroPreviewWidth - 20)
    for _, row in ipairs(self.lootProfilePermissionPolicyRows or {}) do
      if row and row.labelText then
        row.labelText:SetWidth(math.max(132, math.min(230, textWidth - 328)))
      end
    end

    for _, row in ipairs(self.lootRollOptionRows or {}) do
      if row:IsShown() then
        LayoutRollOptionRow(row, rollEditorWidth)
      end
    end
    for _, row in ipairs(self.lootPointRuleRows or {}) do
      if row:IsShown() and type(LayoutPointRuleRow) == "function" then
        LayoutPointRuleRow(row, textWidth)
      end
    end
    for _, row in ipairs(self.lootLidTableRows or {}) do
      lidPointsWidth, lidItemLevelWidth, lidSetPieceWidth, lidOffSpecWidth, lidTransmogWidth, lidDisenchantWidth = LayoutLidTableEditorRow(row, textWidth)
    end

    local summaryHeight = math.max(38, math.ceil((self.lootProfileSummary and self.lootProfileSummary:GetStringHeight() or 0)))
    local accessSummaryHeight = math.max(18, math.ceil((self.lootProfileAccessSummary and self.lootProfileAccessSummary:GetStringHeight() or 0)))
    local permissionPolicySummaryHeight = math.max(16, math.ceil((self.lootProfilePermissionPolicySummary and self.lootProfilePermissionPolicySummary:GetStringHeight() or 0)))
    local councilMetaHeight = math.max(18, math.ceil((self.lootProfileCouncilCardMeta and self.lootProfileCouncilCardMeta:GetStringHeight() or 0)))
    local raiderSummaryHeight = math.max(18, math.ceil((self.lootProfileRaiderSummary and self.lootProfileRaiderSummary:GetStringHeight() or 0)))
    local raidHintHeight = math.max(18, math.ceil((self.lootRaidHint and self.lootRaidHint:GetStringHeight() or 0)))
    local raidGalleryEntryCount = math.max(1, tonumber(self.__lootProfileImageGalleryEntryCount) or 1)
    local raidGalleryColumns = sectionWidth >= 620 and 3 or 2
    local raidGalleryGap = 10
    local raidGalleryWidth = math.max(100, math.floor((textWidth - ((raidGalleryColumns - 1) * raidGalleryGap)) / raidGalleryColumns))
    local raidGalleryTileHeight = math.max(92, math.floor(raidGalleryWidth * 0.52) + 24)
    local raidGalleryRows = math.max(1, math.ceil(raidGalleryEntryCount / raidGalleryColumns))
    local raidGalleryHeight = (raidGalleryRows * raidGalleryTileHeight) + ((raidGalleryRows - 1) * raidGalleryGap)
    local rollTextHeight = math.max(18, math.ceil((self.lootRollOptionsText and self.lootRollOptionsText:GetStringHeight() or 0)))
    local rollAccessHintHeight = math.max(14, math.ceil((self.lootRollAccessHint and self.lootRollAccessHint:GetStringHeight() or 0)))
    local rollRowCount = tonumber(self.__lootRollOptionRowCount) or 0
    local rollRowSpacing = 32
    local rollRowsHeight = (rollRowCount > 0) and (((rollRowCount - 1) * rollRowSpacing) + 26) or 0
    local rollPreviewNeedCount = math.max(0, tonumber(self.__lootRollInlinePreviewNeedCount) or 0)
    local rollPreviewGreedCount = math.max(0, tonumber(self.__lootRollInlinePreviewGreedCount) or 0)
    local rollPreviewButtonHeight = 28
    local rollPreviewSectionGap = 8
    local function GetRollPreviewSectionHeight(optionCount)
      return 34 + (math.max(1, optionCount) * rollPreviewButtonHeight) + 6
    end
    local rollPreviewNeedHeight = GetRollPreviewSectionHeight(rollPreviewNeedCount)
    local rollPreviewGreedHeight = GetRollPreviewSectionHeight(rollPreviewGreedCount)
    local rollPreviewFrameHeight = 42 + rollPreviewNeedHeight + rollPreviewSectionGap + rollPreviewGreedHeight + 10
    local pointMode = tostring(self.__lootPointMode or "LIDTABLE")
    local isLidTable = pointMode ~= "CUSTOM"
    local ruleTextHeight = math.max(18, math.ceil((self.lootPointRulesText and self.lootPointRulesText:GetStringHeight() or 0)))
    local pointRuleRowCount = tonumber(self.__lootPointRuleRowCount) or 0
    local pointRuleRowSpacing = 30
    local pointRuleRowsHeight = pointRuleRowCount > 0 and (((pointRuleRowCount - 1) * pointRuleRowSpacing) + 26) or 0
    local lidTableRowSpacing = 26
    local lidTableRowsHeight = (#(self.lootLidTableRows or {}) > 0) and ((((#self.lootLidTableRows) - 1) * lidTableRowSpacing) + 22) or 0
    local councilRowsHeight = tonumber(self.__lootProfileCouncilRowsHeight) or 0
    local raiderRowsHeight = tonumber(self.__lootProfileRaiderRowsHeight) or 0
    local councilRowsOffset = 66 + councilMetaHeight
    local raiderRowsOffset = 70 + raiderSummaryHeight
    local raidersCollapsed = self.__lootProfileRaidersCanCollapse and self.__lootProfileRaidersCollapsed and true or false
    local raiderFrameHeight = raidersCollapsed and math.max(76, 70 + raiderSummaryHeight) or math.max(82, raiderRowsOffset + raiderRowsHeight + 12)
    local councilCardHeight = math.max(78, councilRowsOffset + councilRowsHeight + 12)
    local masterCardHeight = 72
    local permissionPolicyRowCount = tonumber(self.__lootProfilePermissionPolicyRowCount) or #(self.lootProfilePermissionPolicyRows or {})
    local permissionPolicyRowHeight = 28
    local permissionPolicySectionGap = 12
    local permissionPolicyRowsHeight = 0
    local visiblePermissionPolicyRowCount = 0
    for index = 1, permissionPolicyRowCount do
      local row = self.lootProfilePermissionPolicyRows and self.lootProfilePermissionPolicyRows[index] or nil
      if row and not row.__permissionHidden then
        visiblePermissionPolicyRowCount = visiblePermissionPolicyRowCount + 1
      end
    end
    local visiblePermissionPolicyRowIndex = 0
    for index = 1, permissionPolicyRowCount do
      local row = self.lootProfilePermissionPolicyRows and self.lootProfilePermissionPolicyRows[index] or nil
      if row and not row.__permissionHidden then
        visiblePermissionPolicyRowIndex = visiblePermissionPolicyRowIndex + 1
        if visiblePermissionPolicyRowIndex > 1 and row.__isPermissionSection then
          permissionPolicyRowsHeight = permissionPolicyRowsHeight + permissionPolicySectionGap
        end
        permissionPolicyRowsHeight = permissionPolicyRowsHeight + ((visiblePermissionPolicyRowIndex == visiblePermissionPolicyRowCount) and 24 or permissionPolicyRowHeight)
      end
    end

    local heroFrameTop = -16
    local titleTop = heroFrameTop - 14
    local statusTop = heroFrameTop - 40
    local statusDetailTop = heroFrameTop - 58
    local summaryTop = heroFrameTop - 80
    local actionTop = summaryTop - summaryHeight - 14

    self.lootProfilesTitle:ClearAllPoints()
    self.lootProfilesTitle:SetPoint("TOPLEFT", 34, titleTop)

    self.lootProfileStatus:ClearAllPoints()
    self.lootProfileStatus:SetPoint("TOPLEFT", 52, statusTop)

    if self.lootProfileStatusDot then
      self.lootProfileStatusDot:ClearAllPoints()
      self.lootProfileStatusDot:SetPoint("LEFT", self.lootProfileStatus, "LEFT", -16, 0)
    end

    if self.lootProfileStatusDetail then
      self.lootProfileStatusDetail:ClearAllPoints()
      self.lootProfileStatusDetail:SetPoint("TOPLEFT", 52, statusDetailTop)
    end

    self.lootProfileSummary:ClearAllPoints()
    self.lootProfileSummary:SetPoint("TOPLEFT", 34, summaryTop)

    if self.lootProfileActionsHeader then
      self.lootProfileActionsHeader:Hide()
    end

    local heroButtonTop = actionTop
    local heroButtonGap = 8
    heroButtonsHeight = 0
    local visibleHeroButtons = {}
    for _, button in ipairs({
      self.lootActivateProfileBtn,
      self.lootDeactivateProfileBtn,
      self.lootCopyProfileBtn,
      self.lootClearSimulationContentBtn,
    }) do
      if button and button.IsShown and button:IsShown() then
        visibleHeroButtons[#visibleHeroButtons + 1] = button
      end
    end
    local heroButtonCount = #visibleHeroButtons
    local horizontalButtonWidth = heroButtonCount > 0 and math.floor((heroTextWidth - 16 - ((heroButtonCount - 1) * heroButtonGap)) / heroButtonCount) or 0
    local useHorizontalHeroButtons = heroButtonCount > 0 and horizontalButtonWidth >= 84
    local heroButtonLeft = 34
    for _, button in ipairs(visibleHeroButtons) do
      local buttonWidth = useHorizontalHeroButtons and horizontalButtonWidth or heroActionButtonWidth
      button:SetWidth(math.max(80, buttonWidth))
      button:ClearAllPoints()
      button:SetPoint("TOPLEFT", heroButtonLeft, heroButtonTop)
      local buttonHeight = math.floor((button.GetHeight and button:GetHeight()) or 22)
      if useHorizontalHeroButtons then
        heroButtonLeft = heroButtonLeft + buttonWidth + heroButtonGap
        heroButtonsHeight = math.max(heroButtonsHeight, buttonHeight)
      else
        heroButtonTop = heroButtonTop - buttonHeight - heroButtonGap
        heroButtonsHeight = heroButtonsHeight + buttonHeight + heroButtonGap
      end
    end
    if not useHorizontalHeroButtons and heroButtonsHeight > 0 then
      heroButtonsHeight = heroButtonsHeight - heroButtonGap
    end

    local heroFrameHeight = math.max(148, (heroFrameTop - actionTop) + heroButtonsHeight + 22)
    if self.lootProfileHeroFrame then
      self.lootProfileHeroFrame:ClearAllPoints()
      self.lootProfileHeroFrame:SetPoint("TOPLEFT", 18, heroFrameTop)
      self.lootProfileHeroFrame:SetSize(sectionWidth, heroFrameHeight)
    end
    if self.lootProfileHeroRaidPreviewFrame then
      local heroPreviewHeight = ClampLayoutValue(math.floor(heroFrameHeight - 48), 96, 150)
      local heroPreviewFrameWidth = math.min(heroPreviewWidth, math.floor((heroPreviewHeight * 16 / 9) + 0.5))
      self.lootProfileHeroRaidPreviewFrame:ClearAllPoints()
      self.lootProfileHeroRaidPreviewFrame:SetPoint("TOPRIGHT", self.lootProfileHeroFrame, "TOPRIGHT", -14, -22)
      self.lootProfileHeroRaidPreviewFrame:SetSize(heroPreviewFrameWidth, heroPreviewHeight)
      self.lootProfileHeroRaidPreviewFrame:Show()
    end
    if self.lootProfileSizeFrame then
      self.lootProfileSizeFrame:ClearAllPoints()
      if self.lootProfileHeroRaidPreviewFrame then
        self.lootProfileSizeFrame:SetPoint("TOPRIGHT", self.lootProfileHeroRaidPreviewFrame, "BOTTOMRIGHT", 0, -8)
      else
        self.lootProfileSizeFrame:SetPoint("TOPRIGHT", self.lootProfileHeroFrame, "TOPRIGHT", -8, -8)
      end
      local previewFrameWidth = self.lootProfileHeroRaidPreviewFrame and self.lootProfileHeroRaidPreviewFrame:GetWidth() or heroPreviewWidth
      self.lootProfileSizeFrame:SetSize(previewFrameWidth, 18)
      if self.lootProfileSizeText then
        self.lootProfileSizeText:SetWidth(previewFrameWidth)
      end
    end
    if self.lootProfileHeroRaidPreviewTexture then
      self.lootProfileHeroRaidPreviewTexture:ClearAllPoints()
      self.lootProfileHeroRaidPreviewTexture:SetAllPoints(self.lootProfileHeroRaidPreviewFrame)
    end
    if self.lootProfileHeroRaidPreviewEmpty then
      self.lootProfileHeroRaidPreviewEmpty:ClearAllPoints()
      self.lootProfileHeroRaidPreviewEmpty:SetPoint("CENTER", self.lootProfileHeroRaidPreviewFrame, "CENTER", 0, 0)
    end
    if self.lootProfileHeroRaidPreviewLabel then
      self.lootProfileHeroRaidPreviewLabel:ClearAllPoints()
      self.lootProfileHeroRaidPreviewLabel:SetPoint("TOPLEFT", self.lootProfileHeroRaidPreviewTitle, "BOTTOMLEFT", 0, -4)
      self.lootProfileHeroRaidPreviewLabel:SetPoint("RIGHT", self.lootProfileHeroRaidPreviewFrame, "RIGHT", -10, 0)
    end
    if self.lootProfileHeroRaidPreviewButton then
      self.lootProfileHeroRaidPreviewButton:SetAllPoints(self.lootProfileHeroRaidPreviewFrame)
    end

    local sectionButtonHeight = 28
    local sectionButtonGap = 12
    local sectionButtonGapX = 2
    local expandedSectionGap = 18
    local openSection = string.lower(TrimText(self.__lootProfileOpenSection))
    local root = type(RootDB) == "function" and RootDB() or nil
    local importExportFeatureEnabled = type(root) == "table"
      and type(root.ui) == "table"
      and root.ui.developerMode == true
      and root.ui.importExportFeature == true
    if openSection == "transfer" and not importExportFeatureEnabled then
      openSection = "overview"
      self.__lootProfileOpenSection = openSection
    end
    if openSection ~= "overview" and openSection ~= "access" and openSection ~= "raid" and openSection ~= "roll" and openSection ~= "points" and openSection ~= "backups" and openSection ~= "transfer" then
      openSection = "overview"
      self.__lootProfileOpenSection = openSection
    end
    local overviewSelected = openSection == "overview"
    local accessExpanded = openSection == "access"
    local raidExpanded = openSection == "raid"
    local rollExpanded = openSection == "roll"
    local pointsExpanded = openSection == "points"
    local backupExpanded = openSection == "backups"

    local function SetProfileTabState(button, labelText, selected)
      if not button then
        return
      end
      if button.SetText then
        button:SetText(tostring(labelText or button.baseLabel or ""))
      end
      if button.SetButtonState then
        button:SetButtonState(selected and "PUSHED" or "NORMAL")
      end
      if button.LockHighlight and button.UnlockHighlight then
        if selected then
          button:LockHighlight()
        else
          button:UnlockHighlight()
        end
      end
      if button.activeLine then
        button.activeLine:SetShown(selected)
      end
      if button.activeFill then
        button.activeFill:SetShown(selected)
      end
    end

    if self.lootProfileAccessHeader then self.lootProfileAccessHeader:Hide() end
    if self.lootRaidHeader then self.lootRaidHeader:Hide() end
    if self.lootRollHeader then self.lootRollHeader:Hide() end
    if self.lootPointsHeader then self.lootPointsHeader:Hide() end
    if self.lootProfileBackupHeader then self.lootProfileBackupHeader:Hide() end
    local sectionTabsTop = heroFrameTop - heroFrameHeight - 14
    local sectionTabsLeft = 18
    local sectionTabsWidth = sectionWidth
    local sectionTabCount = importExportFeatureEnabled and 7 or 6
    local sectionTabWidth = math.max(54, math.floor((sectionTabsWidth - (sectionButtonGapX * (sectionTabCount - 1))) / sectionTabCount))
    if self.lootProfileTabStrip then
      self.lootProfileTabStrip:ClearAllPoints()
      self.lootProfileTabStrip:SetPoint("TOPLEFT", sectionTabsLeft, sectionTabsTop)
      self.lootProfileTabStrip:SetSize(sectionTabsWidth, sectionButtonHeight + 2)
      self.lootProfileTabStrip:Show()
    end

    if self.lootProfileOverviewToggleBtn then
      self.lootProfileOverviewToggleBtn:ClearAllPoints()
      self.lootProfileOverviewToggleBtn:SetPoint("TOPLEFT", 0, -1)
      self.lootProfileOverviewToggleBtn:SetWidth(sectionTabWidth)
      self.lootProfileOverviewToggleBtn:SetHeight(sectionButtonHeight)
      SetProfileTabState(self.lootProfileOverviewToggleBtn, "Overview", overviewSelected)
      self.lootProfileOverviewToggleBtn:Show()
    end
    if self.lootProfileAccessToggleBtn then
      self.lootProfileAccessToggleBtn:ClearAllPoints()
      self.lootProfileAccessToggleBtn:SetPoint("TOPLEFT", sectionTabWidth + sectionButtonGapX, -1)
      self.lootProfileAccessToggleBtn:SetWidth(sectionTabWidth)
      self.lootProfileAccessToggleBtn:SetHeight(sectionButtonHeight)
      SetProfileTabState(self.lootProfileAccessToggleBtn, "Roles & Rights", accessExpanded)
      self.lootProfileAccessToggleBtn:Show()
    end
    if self.lootProfileRaidToggleBtn then
      self.lootProfileRaidToggleBtn:ClearAllPoints()
      self.lootProfileRaidToggleBtn:SetPoint("TOPLEFT", (sectionTabWidth + sectionButtonGapX) * 2, -1)
      self.lootProfileRaidToggleBtn:SetWidth(sectionTabWidth)
      self.lootProfileRaidToggleBtn:SetHeight(sectionButtonHeight)
      SetProfileTabState(self.lootProfileRaidToggleBtn, "Image", raidExpanded)
      self.lootProfileRaidToggleBtn:Show()
    end
    if self.lootProfileRollToggleBtn then
      self.lootProfileRollToggleBtn:ClearAllPoints()
      self.lootProfileRollToggleBtn:SetPoint("TOPLEFT", (sectionTabWidth + sectionButtonGapX) * 3, -1)
      self.lootProfileRollToggleBtn:SetWidth(sectionTabWidth)
      self.lootProfileRollToggleBtn:SetHeight(sectionButtonHeight)
      SetProfileTabState(self.lootProfileRollToggleBtn, "Rolls", rollExpanded)
      self.lootProfileRollToggleBtn:Show()
    end
    if self.lootProfilePointsToggleBtn then
      self.lootProfilePointsToggleBtn:ClearAllPoints()
      self.lootProfilePointsToggleBtn:SetPoint("TOPLEFT", (sectionTabWidth + sectionButtonGapX) * 4, -1)
      self.lootProfilePointsToggleBtn:SetWidth(sectionTabWidth)
      self.lootProfilePointsToggleBtn:SetHeight(sectionButtonHeight)
      SetProfileTabState(self.lootProfilePointsToggleBtn, "Points", pointsExpanded)
      self.lootProfilePointsToggleBtn:Show()
    end
    if self.lootProfileBackupToggleBtn then
      self.lootProfileBackupToggleBtn:ClearAllPoints()
      self.lootProfileBackupToggleBtn:SetPoint("TOPLEFT", (sectionTabWidth + sectionButtonGapX) * 5, -1)
      self.lootProfileBackupToggleBtn:SetWidth(sectionTabWidth)
      self.lootProfileBackupToggleBtn:SetHeight(sectionButtonHeight)
      SetProfileTabState(self.lootProfileBackupToggleBtn, "Backups", backupExpanded)
      self.lootProfileBackupToggleBtn:Show()
    end
    if self.lootProfileTransferToggleBtn then
      if importExportFeatureEnabled then
        self.lootProfileTransferToggleBtn:ClearAllPoints()
        self.lootProfileTransferToggleBtn:SetPoint("TOPLEFT", (sectionTabWidth + sectionButtonGapX) * 6, -1)
        self.lootProfileTransferToggleBtn:SetWidth(sectionTabWidth)
        self.lootProfileTransferToggleBtn:SetHeight(sectionButtonHeight)
        SetProfileTabState(self.lootProfileTransferToggleBtn, "Transfer", openSection == "transfer")
        self.lootProfileTransferToggleBtn:Show()
      else
        self.lootProfileTransferToggleBtn:Hide()
      end
    end

    local currentSectionTop = sectionTabsTop - sectionButtonHeight - sectionButtonGap

    local profileStatCards = self.lootProfileStatCards or {}
    local profileStatKeys = { "sessions", "items", "participants", "rolls" }
    local profileStatsPerRow = sectionWidth >= 560 and 4 or 2
    local profileStatGap = 8
    local profileStatCardWidth = math.floor(((sectionWidth - 32) - ((profileStatsPerRow - 1) * profileStatGap)) / profileStatsPerRow)
    local profileStatCardHeight = 54
    local profileStatRows = math.ceil(#profileStatKeys / profileStatsPerRow)
    local profileStatsHeight = (profileStatRows * profileStatCardHeight) + math.max(0, profileStatRows - 1) * profileStatGap

    if overviewSelected then
      local activityFrameTop = currentSectionTop
      local activityFrameHeight = 46 + profileStatsHeight + 12
      local profileStatsTop = activityFrameTop - 34
      if self.lootProfileActivityFrame then
        self.lootProfileActivityFrame:ClearAllPoints()
        self.lootProfileActivityFrame:SetPoint("TOPLEFT", 18, activityFrameTop)
        self.lootProfileActivityFrame:SetSize(sectionWidth, activityFrameHeight)
        self.lootProfileActivityFrame:Show()
      end
      if self.lootProfileActivityHeader then
        self.lootProfileActivityHeader:Hide()
      end
      for index, key in ipairs(profileStatKeys) do
        local card = profileStatCards[key]
        if card and card.frame then
          local rowIndex = math.floor((index - 1) / profileStatsPerRow)
          local columnIndex = (index - 1) % profileStatsPerRow
          card.frame:ClearAllPoints()
          card.frame:SetPoint("TOPLEFT", 34 + (columnIndex * (profileStatCardWidth + profileStatGap)), profileStatsTop - (rowIndex * (profileStatCardHeight + profileStatGap)))
          card.frame:SetSize(profileStatCardWidth, profileStatCardHeight)
          card.frame:Show()
        end
      end
      for index, divider in ipairs(self.lootProfileStatDividers or {}) do
        divider:Hide()
        if profileStatsPerRow == 4 then
          divider:ClearAllPoints()
          divider:SetPoint("TOPLEFT", 34 + (index * profileStatCardWidth) + ((index - 1) * profileStatGap) + math.floor(profileStatGap / 2), profileStatsTop - 7)
          divider:Show()
        end
      end

      local membersFrameTop = activityFrameTop - activityFrameHeight - 16
      local masterCardTop = membersFrameTop - 34
      local councilCardTop = masterCardTop - masterCardHeight - 14
      local raiderFrameTop = councilCardTop - councilCardHeight - 14
      local membersFrameHeight = (membersFrameTop - raiderFrameTop) + raiderFrameHeight + 12
      if self.lootProfileMembersFrame then
        self.lootProfileMembersFrame:ClearAllPoints()
        self.lootProfileMembersFrame:SetPoint("TOPLEFT", 18, membersFrameTop)
        self.lootProfileMembersFrame:SetSize(sectionWidth, membersFrameHeight)
        self.lootProfileMembersFrame:Show()
      end
      if self.lootProfileMembersHeader then
        self.lootProfileMembersHeader:Show()
      end
      if self.lootProfileMembersActionHint then
        self.lootProfileMembersActionHint:ClearAllPoints()
        self.lootProfileMembersActionHint:SetPoint("TOPRIGHT", self.lootProfileMembersFrame, "TOPRIGHT", -12, -10)
        self.lootProfileMembersActionHint:SetWidth(math.max(180, sectionWidth - 250))
        self.lootProfileMembersActionHint:Show()
      end
      if self.lootProfileMasterCard and self.lootProfileMasterCard.SetBackdropColor then
        self.lootProfileMasterCard:SetBackdropColor(0.10, 0.08, 0.03, 0.62)
        self.lootProfileMasterCard:SetBackdropBorderColor(0.72, 0.54, 0.16, 0.72)
      end
      if self.lootProfileCouncilCard and self.lootProfileCouncilCard.SetBackdropColor then
        self.lootProfileCouncilCard:SetBackdropColor(0.04, 0.07, 0.11, 0.62)
        self.lootProfileCouncilCard:SetBackdropBorderColor(0.26, 0.52, 0.78, 0.70)
      end
      if self.lootProfileRaiderFrame and self.lootProfileRaiderFrame.SetBackdropColor then
        self.lootProfileRaiderFrame:SetBackdropColor(0.06, 0.08, 0.10, 0.62)
        self.lootProfileRaiderFrame:SetBackdropBorderColor(0.40, 0.48, 0.60, 0.66)
      end
      if self.lootProfileMasterCard then
        self.lootProfileMasterCard:ClearAllPoints()
        self.lootProfileMasterCard:SetPoint("TOPLEFT", 30, masterCardTop)
        self.lootProfileMasterCard:SetSize(sectionWidth - 24, masterCardHeight)
        self.lootProfileMasterCard:Show()
      end
      if self.lootProfileMasterRoleEmblem then
        self.lootProfileMasterRoleEmblem:ClearAllPoints()
        self.lootProfileMasterRoleEmblem:SetPoint("TOPLEFT", self.lootProfileMasterCard, "TOPLEFT", 12, -10)
        self.lootProfileMasterRoleEmblem:SetSize(36, 36)
        self.lootProfileMasterRoleEmblem:Show()
      end
      if self.lootProfileMasterCardTitle then
        self.lootProfileMasterCardTitle:ClearAllPoints()
        self.lootProfileMasterCardTitle:SetPoint("TOPLEFT", self.lootProfileMasterCard, "TOPLEFT", 58, -10)
        self.lootProfileMasterCardTitle:Show()
      end
      if self.lootProfileMasterCardIcon then
        self.lootProfileMasterCardIcon:ClearAllPoints()
        self.lootProfileMasterCardIcon:SetPoint("TOPLEFT", self.lootProfileMasterCard, "TOPLEFT", 58, -30)
        self.lootProfileMasterCardIcon:SetSize(20, 20)
        self.lootProfileMasterCardIcon:Show()
      end
      if self.lootProfileMasterCardValue then
        self.lootProfileMasterCardValue:ClearAllPoints()
        self.lootProfileMasterCardValue:SetPoint("TOPLEFT", self.lootProfileMasterCardIcon, "TOPRIGHT", 8, 0)
        self.lootProfileMasterCardValue:SetWidth(math.max(140, sectionWidth - 232))
        self.lootProfileMasterCardValue:Show()
      end
      if self.lootProfileMasterCardMeta then
        self.lootProfileMasterCardMeta:ClearAllPoints()
        self.lootProfileMasterCardMeta:SetPoint("TOPLEFT", self.lootProfileMasterCardValue, "BOTTOMLEFT", 0, -2)
        self.lootProfileMasterCardMeta:SetWidth(math.max(140, sectionWidth - 232))
        self.lootProfileMasterCardMeta:Show()
      end
      if self.lootProfileTransferMasterBtn then
        self.lootProfileTransferMasterBtn:ClearAllPoints()
        self.lootProfileTransferMasterBtn:SetPoint("TOPRIGHT", self.lootProfileMasterCard, "TOPRIGHT", -12, -12)
      end
      if self.lootProfileCouncilCard then
        self.lootProfileCouncilCard:ClearAllPoints()
        self.lootProfileCouncilCard:SetPoint("TOPLEFT", 30, councilCardTop)
        self.lootProfileCouncilCard:SetSize(sectionWidth - 24, councilCardHeight)
        self.lootProfileCouncilCard:Show()
      end
      if self.lootProfileCouncilRoleEmblem then
        self.lootProfileCouncilRoleEmblem:ClearAllPoints()
        self.lootProfileCouncilRoleEmblem:SetPoint("TOPLEFT", self.lootProfileCouncilCard, "TOPLEFT", 12, -10)
        self.lootProfileCouncilRoleEmblem:SetSize(36, 36)
        self.lootProfileCouncilRoleEmblem:Show()
      end
      if self.lootProfileCouncilCardTitle then
        self.lootProfileCouncilCardTitle:ClearAllPoints()
        self.lootProfileCouncilCardTitle:SetPoint("TOPLEFT", self.lootProfileCouncilCard, "TOPLEFT", 58, -10)
        self.lootProfileCouncilCardTitle:Show()
      end
      if self.lootProfileCouncilCardValue then
        self.lootProfileCouncilCardValue:ClearAllPoints()
        self.lootProfileCouncilCardValue:SetPoint("TOPLEFT", self.lootProfileCouncilCard, "TOPLEFT", 58, -30)
        self.lootProfileCouncilCardValue:SetWidth(math.max(140, sectionWidth - 94))
        self.lootProfileCouncilCardValue:Show()
      end
      if self.lootProfileCouncilCardMeta then
        self.lootProfileCouncilCardMeta:ClearAllPoints()
        self.lootProfileCouncilCardMeta:SetPoint("TOPLEFT", self.lootProfileCouncilCard, "TOPLEFT", 58, -48)
        self.lootProfileCouncilCardMeta:SetWidth(math.max(140, sectionWidth - 94))
        self.lootProfileCouncilCardMeta:Show()
      end
      if self.lootProfileCouncilRowsFrame then
        self.lootProfileCouncilRowsFrame:ClearAllPoints()
        self.lootProfileCouncilRowsFrame:SetPoint("TOPLEFT", self.lootProfileCouncilCard, "TOPLEFT", 12, -councilRowsOffset)
        self.lootProfileCouncilRowsFrame:SetPoint("TOPRIGHT", self.lootProfileCouncilCard, "TOPRIGHT", -12, -councilRowsOffset)
        self.lootProfileCouncilRowsFrame:SetHeight(math.max(1, councilRowsHeight))
      end
      if self.lootProfileRaiderFrame then
        self.lootProfileRaiderFrame:ClearAllPoints()
        self.lootProfileRaiderFrame:SetPoint("TOPLEFT", 30, raiderFrameTop)
        self.lootProfileRaiderFrame:SetSize(sectionWidth - 24, raiderFrameHeight)
        self.lootProfileRaiderFrame:Show()
      end
      if self.lootProfileRaiderToggleBtn then
        self.lootProfileRaiderToggleBtn:SetWidth(sectionWidth - 48)
        self.lootProfileRaiderToggleBtn:ClearAllPoints()
        self.lootProfileRaiderToggleBtn:SetPoint("TOPLEFT", self.lootProfileRaiderFrame, "TOPLEFT", 12, -10)
        self.lootProfileRaiderToggleBtn:SetHeight(40)
        if self.lootProfileRaiderToggleBtn.roleEmblem then
          self.lootProfileRaiderToggleBtn.roleEmblem:ClearAllPoints()
          self.lootProfileRaiderToggleBtn.roleEmblem:SetPoint("LEFT", self.lootProfileRaiderToggleBtn, "LEFT", 2, 0)
          self.lootProfileRaiderToggleBtn.roleEmblem:SetSize(36, 36)
          self.lootProfileRaiderToggleBtn.roleEmblem:Show()
        end
        if self.lootProfileRaiderToggleBtn.arrowText then
          self.lootProfileRaiderToggleBtn.arrowText:ClearAllPoints()
          self.lootProfileRaiderToggleBtn.arrowText:SetPoint("LEFT", self.lootProfileRaiderToggleBtn.roleEmblem, "RIGHT", 6, 0)
        end
        if self.lootProfileRaiderToggleBtn.labelText then
          self.lootProfileRaiderToggleBtn.labelText:ClearAllPoints()
          self.lootProfileRaiderToggleBtn.labelText:SetPoint("LEFT", self.lootProfileRaiderToggleBtn.arrowText, "RIGHT", 6, 0)
          self.lootProfileRaiderToggleBtn.labelText:SetPoint("RIGHT", -10, 0)
        end
      end
      if self.lootProfileRaiderSummary then
        self.lootProfileRaiderSummary:ClearAllPoints()
        self.lootProfileRaiderSummary:SetPoint("TOPLEFT", self.lootProfileRaiderFrame, "TOPLEFT", 12, -58)
      end
      if self.lootProfileRaiderRowsFrame then
        self.lootProfileRaiderRowsFrame:ClearAllPoints()
        self.lootProfileRaiderRowsFrame:SetPoint("TOPLEFT", self.lootProfileRaiderFrame, "TOPLEFT", 12, -raiderRowsOffset)
        self.lootProfileRaiderRowsFrame:SetPoint("TOPRIGHT", self.lootProfileRaiderFrame, "TOPRIGHT", -12, -raiderRowsOffset)
        self.lootProfileRaiderRowsFrame:SetHeight(math.max(1, raidersCollapsed and 0 or raiderRowsHeight))
        self.lootProfileRaiderRowsFrame:SetShown(not raidersCollapsed)
      end
      for index, divider in ipairs(self.lootProfileMemberDividers or {}) do
        local dividerTop = index == 1 and (masterCardTop - masterCardHeight - 7) or (councilCardTop - councilCardHeight - 7)
        divider:ClearAllPoints()
        divider:SetPoint("TOPLEFT", 30, dividerTop)
        divider:SetWidth(sectionWidth - 24)
        divider:Show()
      end
      currentSectionTop = membersFrameTop - membersFrameHeight - 18
    else
      if self.lootProfileActivityFrame then self.lootProfileActivityFrame:Hide() end
      if self.lootProfileActivityHeader then self.lootProfileActivityHeader:Hide() end
      if self.lootProfileMembersFrame then self.lootProfileMembersFrame:Hide() end
      if self.lootProfileMembersHeader then self.lootProfileMembersHeader:Hide() end
      if self.lootProfileMembersActionHint then self.lootProfileMembersActionHint:Hide() end
      for _, card in pairs(profileStatCards) do
        if card and card.frame then card.frame:Hide() end
      end
      for _, divider in ipairs(self.lootProfileStatDividers or {}) do divider:Hide() end
      for _, divider in ipairs(self.lootProfileMemberDividers or {}) do divider:Hide() end
      if self.lootProfileMasterCard then self.lootProfileMasterCard:Hide() end
      if self.lootProfileCouncilCard then self.lootProfileCouncilCard:Hide() end
      if self.lootProfileRaiderFrame then self.lootProfileRaiderFrame:Hide() end
    end

    if accessExpanded then
      local roleContextHeight = 72
      local roleContextTop = currentSectionTop
      local accessFrameTop = roleContextTop - roleContextHeight - 12
      local policySectionTop = -18
      local policyHeadersTop = policySectionTop - 18 - permissionPolicySummaryHeight - 18
      local policyRowsTop = policyHeadersTop - 22

      if self.lootProfileAccessSummary then self.lootProfileAccessSummary:Hide() end
      if self.lootProfileRoleContextFrame then
        self.lootProfileRoleContextFrame:ClearAllPoints()
        self.lootProfileRoleContextFrame:SetPoint("TOPLEFT", 18, roleContextTop)
        self.lootProfileRoleContextFrame:SetSize(sectionWidth, roleContextHeight)
        self.lootProfileRoleContextFrame:Show()
      end
      if self.lootProfileRoleContextIcon then
        self.lootProfileRoleContextIcon:ClearAllPoints()
        self.lootProfileRoleContextIcon:SetPoint("LEFT", self.lootProfileRoleContextFrame, "LEFT", 12, 0)
        self.lootProfileRoleContextIcon:SetSize(48, 48)
        self.lootProfileRoleContextIcon:Show()
      end
      if self.lootProfileRoleContextTitle then
        self.lootProfileRoleContextTitle:ClearAllPoints()
        self.lootProfileRoleContextTitle:SetPoint("TOPLEFT", self.lootProfileRoleContextFrame, "TOPLEFT", 72, -12)
        self.lootProfileRoleContextTitle:Show()
      end
      if self.lootProfileRoleContextDetail then
        self.lootProfileRoleContextDetail:ClearAllPoints()
        self.lootProfileRoleContextDetail:SetPoint("TOPLEFT", self.lootProfileRoleContextFrame, "TOPLEFT", 72, -33)
        self.lootProfileRoleContextDetail:Show()
      end
      if self.lootProfileRoleContextHint then
        self.lootProfileRoleContextHint:ClearAllPoints()
        self.lootProfileRoleContextHint:SetPoint("TOPLEFT", self.lootProfileRoleContextFrame, "TOPLEFT", 72, -50)
        self.lootProfileRoleContextHint:SetWidth(math.max(180, sectionWidth - 208))
        self.lootProfileRoleContextHint:Show()
      end
      if self.lootProfileRoleSessionBadge then
        self.lootProfileRoleSessionBadge:ClearAllPoints()
        self.lootProfileRoleSessionBadge:SetPoint("TOPRIGHT", self.lootProfileRoleContextFrame, "TOPRIGHT", -12, -12)
      end

      local accessFrameHeight = math.max(300, math.abs(policyRowsTop) + permissionPolicyRowsHeight + 78)
      if self.lootProfileAccessFrame then
        self.lootProfileAccessFrame:ClearAllPoints()
        self.lootProfileAccessFrame:SetPoint("TOPLEFT", 18, accessFrameTop)
        self.lootProfileAccessFrame:SetSize(sectionWidth, accessFrameHeight)
        self.lootProfileAccessFrame:Show()
      end
      if self.lootProfilePermissionPolicyTitle then
        self.lootProfilePermissionPolicyTitle:ClearAllPoints()
        self.lootProfilePermissionPolicyTitle:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", 16, policySectionTop)
        self.lootProfilePermissionPolicyTitle:Show()
      end
      if self.lootProfilePermissionPolicySummary then
        self.lootProfilePermissionPolicySummary:ClearAllPoints()
        self.lootProfilePermissionPolicySummary:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", 16, policySectionTop - 18)
        self.lootProfilePermissionPolicySummary:Show()
      end
      if self.lootProfilePermissionPolicyResetBtn then
        self.lootProfilePermissionPolicyResetBtn:Hide()
      end
      local headerLabelX = 16
      local policyCellWidth = ClampLayoutValue(math.floor((sectionWidth - 230) / 4), 62, 84)
      local policyColumnGap = 8
      local policyLabelWidth = math.max(132, sectionWidth - 32 - ((policyCellWidth + policyColumnGap) * 4))
      policyLabelWidth = math.min(policyLabelWidth, 230)
      local masterColumnX = headerLabelX + policyLabelWidth + 10
      local sessionHostColumnX = masterColumnX + policyCellWidth + policyColumnGap
      local councilColumnX = sessionHostColumnX + policyCellWidth + policyColumnGap
      local raiderColumnX = councilColumnX + policyCellWidth + policyColumnGap
      local matrixRightX = raiderColumnX + policyCellWidth
      if self.lootProfilePermissionPolicyHeaderRight then
        self.lootProfilePermissionPolicyHeaderRight:ClearAllPoints()
        self.lootProfilePermissionPolicyHeaderRight:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", headerLabelX, policyHeadersTop)
        self.lootProfilePermissionPolicyHeaderRight:SetWidth(policyLabelWidth)
        self.lootProfilePermissionPolicyHeaderRight:Show()
      end
      if self.lootProfilePermissionPolicyHeaderMaster then
        self.lootProfilePermissionPolicyHeaderMaster:ClearAllPoints()
        self.lootProfilePermissionPolicyHeaderMaster:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", masterColumnX, policyHeadersTop)
        self.lootProfilePermissionPolicyHeaderMaster:SetWidth(policyCellWidth)
        self.lootProfilePermissionPolicyHeaderMaster:Show()
      end
      if self.lootProfilePermissionPolicyHeaderSessionHost then
        self.lootProfilePermissionPolicyHeaderSessionHost:ClearAllPoints()
        self.lootProfilePermissionPolicyHeaderSessionHost:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", sessionHostColumnX, policyHeadersTop)
        self.lootProfilePermissionPolicyHeaderSessionHost:SetWidth(policyCellWidth)
        self.lootProfilePermissionPolicyHeaderSessionHost:Show()
      end
      if self.lootProfilePermissionPolicyHeaderCouncil then
        self.lootProfilePermissionPolicyHeaderCouncil:ClearAllPoints()
        self.lootProfilePermissionPolicyHeaderCouncil:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", councilColumnX, policyHeadersTop)
        self.lootProfilePermissionPolicyHeaderCouncil:SetWidth(policyCellWidth)
        self.lootProfilePermissionPolicyHeaderCouncil:Show()
      end
      if self.lootProfilePermissionPolicyHeaderRaider then
        self.lootProfilePermissionPolicyHeaderRaider:ClearAllPoints()
        self.lootProfilePermissionPolicyHeaderRaider:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", raiderColumnX, policyHeadersTop)
        self.lootProfilePermissionPolicyHeaderRaider:SetWidth(policyCellWidth)
        self.lootProfilePermissionPolicyHeaderRaider:Show()
      end
      local policyFooterTop = policyRowsTop - permissionPolicyRowsHeight - 18
      if self.lootProfilePermissionPolicyFooterDivider then
        self.lootProfilePermissionPolicyFooterDivider:ClearAllPoints()
        self.lootProfilePermissionPolicyFooterDivider:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", 16, policyFooterTop + 8)
        self.lootProfilePermissionPolicyFooterDivider:SetPoint("TOPRIGHT", self.lootProfileAccessFrame, "TOPLEFT", matrixRightX, policyFooterTop + 8)
        self.lootProfilePermissionPolicyFooterDivider:Show()
      end
      if self.lootProfilePermissionPolicyFooter then
        self.lootProfilePermissionPolicyFooter:ClearAllPoints()
        self.lootProfilePermissionPolicyFooter:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", 16, policyFooterTop - 2)
        self.lootProfilePermissionPolicyFooter:Show()
      end
      if self.lootProfilePermissionPolicyResetBtn then
        self.lootProfilePermissionPolicyResetBtn:ClearAllPoints()
        self.lootProfilePermissionPolicyResetBtn:SetPoint("TOPRIGHT", self.lootProfileAccessFrame, "TOPLEFT", matrixRightX, policyFooterTop + 2)
        self.lootProfilePermissionPolicyResetBtn:SetWidth(180)
        self.lootProfilePermissionPolicyResetBtn:Show()
      end
      local permissionPolicyRowCount = tonumber(self.__lootProfilePermissionPolicyRowCount) or 0
      local permissionPolicyRowOffset = 0
      local visiblePermissionPolicyRowIndex = 0
      for index, row in ipairs(self.lootProfilePermissionPolicyRows or {}) do
        if index > permissionPolicyRowCount or row.__permissionHidden then
          row:Hide()
        else
          visiblePermissionPolicyRowIndex = visiblePermissionPolicyRowIndex + 1
          if visiblePermissionPolicyRowIndex > 1 and row.__isPermissionSection then
            permissionPolicyRowOffset = permissionPolicyRowOffset + permissionPolicySectionGap
          end
          local rowTop = policyRowsTop - permissionPolicyRowOffset
          row:ClearAllPoints()
          row:SetPoint("TOPLEFT", self.lootProfileAccessFrame, "TOPLEFT", 16, rowTop)
          row:SetWidth(matrixRightX - 16)
          row:SetHeight(24)
          row:Show()
          if row.labelText then
            row.labelText:ClearAllPoints()
            row.labelText:SetPoint("LEFT", row, "LEFT", 8, 0)
            row.labelText:SetWidth(row.__isPermissionSection and (sectionWidth - 56) or (policyLabelWidth - 8))
          end
          if row.masterCell then
            row.masterCell:ClearAllPoints()
            row.masterCell:SetSize(policyCellWidth, 20)
            row.masterCell:SetPoint("LEFT", row, "LEFT", masterColumnX - 16, 0)
            row.masterCell:SetShown(not row.__isPermissionSection)
          end
          if row.sessionHostCell then
            row.sessionHostCell:ClearAllPoints()
            row.sessionHostCell:SetSize(policyCellWidth, 20)
            row.sessionHostCell:SetPoint("LEFT", row, "LEFT", sessionHostColumnX - 16, 0)
            row.sessionHostCell:SetShown(not row.__isPermissionSection)
          end
          if row.councilCell then
            row.councilCell:ClearAllPoints()
            row.councilCell:SetSize(policyCellWidth, 20)
            row.councilCell:SetPoint("LEFT", row, "LEFT", councilColumnX - 16, 0)
            row.councilCell:SetShown(not row.__isPermissionSection)
          end
          if row.raiderCell then
            row.raiderCell:ClearAllPoints()
            row.raiderCell:SetSize(policyCellWidth, 20)
            row.raiderCell:SetPoint("LEFT", row, "LEFT", raiderColumnX - 16, 0)
            row.raiderCell:SetShown(not row.__isPermissionSection)
          end
          permissionPolicyRowOffset = permissionPolicyRowOffset + permissionPolicyRowHeight
        end
      end
      currentSectionTop = accessFrameTop - accessFrameHeight - expandedSectionGap
    else
      self.lootProfileAccessSummary:Hide()
      if self.lootProfileRoleContextFrame then self.lootProfileRoleContextFrame:Hide() end
      if self.lootProfileAccessFrame then self.lootProfileAccessFrame:Hide() end
      if self.lootProfilePermissionPolicyTitle then self.lootProfilePermissionPolicyTitle:Hide() end
      if self.lootProfilePermissionPolicySummary then self.lootProfilePermissionPolicySummary:Hide() end
      if self.lootProfilePermissionPolicyResetBtn then self.lootProfilePermissionPolicyResetBtn:Hide() end
      if self.lootProfilePermissionPolicyFooterDivider then self.lootProfilePermissionPolicyFooterDivider:Hide() end
      if self.lootProfilePermissionPolicyFooter then self.lootProfilePermissionPolicyFooter:Hide() end
      if self.lootProfilePermissionPolicyHeaderRight then self.lootProfilePermissionPolicyHeaderRight:Hide() end
      if self.lootProfilePermissionPolicyHeaderMaster then self.lootProfilePermissionPolicyHeaderMaster:Hide() end
      if self.lootProfilePermissionPolicyHeaderSessionHost then self.lootProfilePermissionPolicyHeaderSessionHost:Hide() end
      if self.lootProfilePermissionPolicyHeaderCouncil then self.lootProfilePermissionPolicyHeaderCouncil:Hide() end
      if self.lootProfilePermissionPolicyHeaderRaider then self.lootProfilePermissionPolicyHeaderRaider:Hide() end
      for _, row in ipairs(self.lootProfilePermissionPolicyRows or {}) do
        row:Hide()
      end
    end

    if raidExpanded then
      local raidFrameTop = currentSectionTop
      local raidHintTop = -16
      local raidGalleryTitleTop = raidHintTop - raidHintHeight - 14
      local raidGalleryTop = raidGalleryTitleTop - 24
      local raidFrameHeight = math.max(110, math.abs(raidGalleryTop) + raidGalleryHeight + 18)

      if self.lootProfileRaidFrame then
        self.lootProfileRaidFrame:ClearAllPoints()
        self.lootProfileRaidFrame:SetPoint("TOPLEFT", 18, raidFrameTop)
        self.lootProfileRaidFrame:SetSize(sectionWidth, raidFrameHeight)
        self.lootProfileRaidFrame:Show()
      end

      self.lootRaidLabel:Hide()
      self.lootRaidSeasonLabel:Hide()
      self.lootRaidSeasonDropdown:Hide()
      self.lootRaidDropdown:Hide()
      self.lootSaveRaidBtn:Hide()
      self.lootRaidHint:Show()
      if self.lootRaidGalleryTitle then self.lootRaidGalleryTitle:Show() end
      if self.lootRaidGalleryFrame then self.lootRaidGalleryFrame:Show() end

      self.lootRaidHint:ClearAllPoints()
      self.lootRaidHint:SetPoint("TOPLEFT", self.lootProfileRaidFrame, "TOPLEFT", 16, raidHintTop)
      if self.lootRaidGalleryTitle then
        self.lootRaidGalleryTitle:ClearAllPoints()
        self.lootRaidGalleryTitle:SetPoint("TOPLEFT", self.lootProfileRaidFrame, "TOPLEFT", 16, raidGalleryTitleTop)
      end
      if self.lootRaidGalleryFrame then
        self.lootRaidGalleryFrame:ClearAllPoints()
        self.lootRaidGalleryFrame:SetPoint("TOPLEFT", self.lootProfileRaidFrame, "TOPLEFT", 16, raidGalleryTop)
        self.lootRaidGalleryFrame:SetSize(textWidth, raidGalleryHeight)
      end
      for index, tile in ipairs(self.lootProfileImageTiles or {}) do
        if tile and tile:IsShown() then
          local tileIndex = index - 1
          local column = tileIndex % raidGalleryColumns
          local row = math.floor(tileIndex / raidGalleryColumns)
          tile:ClearAllPoints()
          tile:SetPoint("TOPLEFT", self.lootRaidGalleryFrame, "TOPLEFT", column * (raidGalleryWidth + raidGalleryGap), -row * (raidGalleryTileHeight + raidGalleryGap))
          tile:SetSize(raidGalleryWidth, raidGalleryTileHeight)
          if tile.artwork then
            tile.artwork:SetHeight(math.max(54, raidGalleryTileHeight - 28))
          end
        end
      end

      currentSectionTop = raidFrameTop - raidFrameHeight - expandedSectionGap
    else
      if self.lootProfileRaidFrame then self.lootProfileRaidFrame:Hide() end
      self.lootRaidLabel:Hide()
      self.lootRaidSeasonLabel:Hide()
      self.lootRaidSeasonDropdown:Hide()
      self.lootRaidDropdown:Hide()
      self.lootSaveRaidBtn:Hide()
      self.lootRaidHint:Hide()
      if self.lootRaidGalleryTitle then self.lootRaidGalleryTitle:Hide() end
      if self.lootRaidGalleryFrame then self.lootRaidGalleryFrame:Hide() end
      for _, tile in ipairs(self.lootProfileImageTiles or {}) do
        tile:Hide()
      end
    end

    if rollExpanded then
      local rollFrameTop = currentSectionTop
      local rollTextTop = rollFrameTop - 40
      local hasRollText = TrimText(self.lootRollOptionsText and self.lootRollOptionsText:GetText() or "") ~= ""
      local hasRollAccessHint = TrimText(self.lootRollAccessHint and self.lootRollAccessHint:GetText() or "") ~= ""
      if not hasRollText then
        rollTextHeight = 0
      end
      if not hasRollAccessHint then
        rollAccessHintHeight = 0
      end
      local rollAccessHintTop = hasRollText and (rollTextTop - rollTextHeight - 8) or rollTextTop
      local rollTemplateTop = hasRollAccessHint and (rollAccessHintTop - rollAccessHintHeight - 8) or rollAccessHintTop
      local rollHintHeight = math.max(14, math.ceil((self.lootRollResponsiveHint and self.lootRollResponsiveHint:IsShown() and self.lootRollResponsiveHint:GetStringHeight() or 0)))
      local rollHeaderTop = rollTemplateTop - (rollToolsInline and 34 or 62)
      local rollRowsTop = rollHeaderTop - 18
      local rollEditTop = rollRowsTop - rollRowsHeight - 12

      self.lootRollOptionsText:SetShown(hasRollText)
      if self.lootRollAccessHint then
        self.lootRollAccessHint:ClearAllPoints()
        self.lootRollAccessHint:SetPoint("TOPLEFT", 34, rollAccessHintTop)
        self.lootRollAccessHint:SetWidth(rollEditorWidth)
        self.lootRollAccessHint:SetShown(hasRollAccessHint)
      end
      self.lootRollTemplateLabel:Show()
      self.lootRollTemplateDropdown:Show()
      if self.lootRollSettingsToolsDropdown then
        self.lootRollSettingsToolsDropdown:SetShown(useRollSettingsTools and true or false)
      end
      if self.lootRollResponsiveHint then
        self.lootRollResponsiveHint:Hide()
      end
      self.lootRollPriorityHeader:Show()
      if self.lootRollMoveHeader then self.lootRollMoveHeader:Show() end
      self.lootRollDescriptionHeader:Show()
      self.lootRollIconHeader:Hide()
      self.lootRollColorHeader:Hide()
      if self.lootRollAppearanceHeader then self.lootRollAppearanceHeader:Show() end
      self.lootRollPointDetailsHeader:Show()
      self.lootRollCategoryHeader:Show()
      self.lootRollOptionEdit:Show()
      self.lootAddRollOptionBtn:Show()
      self.lootRemoveRollOptionBtn:Show()
      self.lootTestRollPopupBtn:Show()
      self.lootPreviewHostBoardBtn:Show()
      if self.lootRollExportBtn then self.lootRollExportBtn:SetShown(not useRollSettingsTools) end
      if self.lootRollImportStringBtn then self.lootRollImportStringBtn:SetShown(not useRollSettingsTools) end
      if self.lootRollImportProfileDropdown then self.lootRollImportProfileDropdown:SetShown(not useRollSettingsTools) end
      if self.lootRollOptionActionsHeader then self.lootRollOptionActionsHeader:Hide() end
      if self.lootRollPreviewActionsHeader then self.lootRollPreviewActionsHeader:Hide() end
      if self.lootRollTransferActionsHeader then self.lootRollTransferActionsHeader:Hide() end
      if self.lootRollInlinePreviewFrame then self.lootRollInlinePreviewFrame:Show() end
      if self.lootRollInlinePreviewTitle then self.lootRollInlinePreviewTitle:Show() end
      if self.lootRollInlinePreviewHint then self.lootRollInlinePreviewHint:Show() end
      if self.lootRollInlinePreviewEmpty then self.lootRollInlinePreviewEmpty:Hide() end
      if self.lootRollInlinePreviewNeedFrame then self.lootRollInlinePreviewNeedFrame:Show() end
      if self.lootRollInlinePreviewGreedFrame then self.lootRollInlinePreviewGreedFrame:Show() end

      self.lootRollOptionsText:ClearAllPoints()
      self.lootRollOptionsText:SetPoint("TOPLEFT", 34, rollTextTop)
      self.lootRollOptionsText:SetWidth(rollEditorWidth)
      self.lootRollTemplateLabel:ClearAllPoints()
      self.lootRollTemplateLabel:SetPoint("TOPLEFT", 34, rollTemplateTop)
      self.lootRollTemplateDropdown:ClearAllPoints()
      self.lootRollTemplateDropdown:SetPoint("LEFT", self.lootRollTemplateLabel, "RIGHT", 8, 0)
      if self.lootRollSettingsToolsDropdown and useRollSettingsTools then
        self.lootRollSettingsToolsDropdown:ClearAllPoints()
        if rollToolsInline then
          self.lootRollSettingsToolsDropdown:SetPoint("TOPLEFT", 34 + rollEditorWidth - self.lootRollSettingsToolsDropdown:GetWidth(), rollTemplateTop)
        else
          self.lootRollSettingsToolsDropdown:SetPoint("TOPLEFT", 34, rollTemplateTop - 30)
        end
      end
      local rollHeaderMetrics = nil
      for i, row in ipairs(self.lootRollOptionRows or {}) do
        if row.__option then
          row:Show()
        end
        if row:IsShown() then
          row:ClearAllPoints()
          row:SetPoint("TOPLEFT", 34, rollRowsTop - ((i - 1) * rollRowSpacing))
          rollHeaderMetrics = rollHeaderMetrics or row.__layout
        end
      end
      if rollHeaderMetrics and self.lootRollResponsiveHint then
        local compactHint = rollHeaderMetrics.compactHint
        if compactHint and compactHint ~= "" then
          self.lootRollResponsiveHint:SetText(compactHint)
          self.lootRollResponsiveHint:ClearAllPoints()
          local rollHintTop = rollTemplateTop - (rollToolsInline and 30 or 58)
          self.lootRollResponsiveHint:SetPoint("TOPLEFT", 34, rollHintTop)
          self.lootRollResponsiveHint:SetWidth(rollEditorWidth)
          self.lootRollResponsiveHint:Show()
          rollHintHeight = math.max(14, math.ceil(self.lootRollResponsiveHint:GetStringHeight() or 0))
          rollHeaderTop = rollHintTop - rollHintHeight - 8
          rollRowsTop = rollHeaderTop - 18
          rollEditTop = rollRowsTop - rollRowsHeight - 12
          for i, row in ipairs(self.lootRollOptionRows or {}) do
            if row:IsShown() then
              row:ClearAllPoints()
              row:SetPoint("TOPLEFT", 34, rollRowsTop - ((i - 1) * rollRowSpacing))
            end
          end
        end
      end
      if rollHeaderMetrics then
        self.lootRollPriorityHeader:ClearAllPoints()
        self.lootRollPriorityHeader:SetPoint("TOPLEFT", 34 + (rollHeaderMetrics.priorityX or 0), rollHeaderTop)
        self.lootRollPriorityHeader:Show()
        if self.lootRollMoveHeader then
          self.lootRollMoveHeader:ClearAllPoints()
          self.lootRollMoveHeader:SetPoint("TOPLEFT", 34 + (rollHeaderMetrics.moveX or 50), rollHeaderTop)
          self.lootRollMoveHeader:SetWidth(rollHeaderMetrics.moveWidth or 46)
          self.lootRollMoveHeader:Show()
        end
        self.lootRollDescriptionHeader:ClearAllPoints()
        self.lootRollDescriptionHeader:SetPoint("TOPLEFT", 34 + (rollHeaderMetrics.descriptionX or 88), rollHeaderTop)
        self.lootRollDescriptionHeader:Show()
        if self.lootRollAppearanceHeader and (rollHeaderMetrics.showIcon or rollHeaderMetrics.showColor) then
          local appearanceX = rollHeaderMetrics.iconX or rollHeaderMetrics.colorX or 0
          local appearanceEnd = rollHeaderMetrics.pointDetailsX or (appearanceX + 80)
          self.lootRollAppearanceHeader:ClearAllPoints()
          self.lootRollAppearanceHeader:SetPoint("TOPLEFT", 34 + appearanceX, rollHeaderTop)
          self.lootRollAppearanceHeader:SetWidth(math.max(54, appearanceEnd - appearanceX - 4))
          self.lootRollAppearanceHeader:Show()
        elseif self.lootRollAppearanceHeader then
          self.lootRollAppearanceHeader:Hide()
        end
        if rollHeaderMetrics.showPointDetails then
          self.lootRollPointDetailsHeader:ClearAllPoints()
          self.lootRollPointDetailsHeader:SetPoint("TOPLEFT", 34 + (rollHeaderMetrics.pointDetailsX or 0), rollHeaderTop)
          self.lootRollPointDetailsHeader:Show()
        else
          self.lootRollPointDetailsHeader:Hide()
        end
        if rollHeaderMetrics.showCategory then
          self.lootRollCategoryHeader:ClearAllPoints()
          self.lootRollCategoryHeader:SetPoint("TOPLEFT", 34 + (rollHeaderMetrics.categoryX or 0), rollHeaderTop)
          self.lootRollCategoryHeader:Show()
        else
          self.lootRollCategoryHeader:Hide()
        end
      end
      local actionToolbarTop = rollEditTop
      if self.lootRollOptionSaveStatus then
        self.lootRollOptionSaveStatus:ClearAllPoints()
        self.lootRollOptionSaveStatus:SetPoint("TOPLEFT", 34, actionToolbarTop)
        self.lootRollOptionSaveStatus:SetShown(self.__lootRollOptionSaveNoticeToken ~= nil)
        if self.__lootRollOptionSaveNoticeToken ~= nil then
          actionToolbarTop = actionToolbarTop - 18
        end
      end
      local actionToolbarLeft = 34
      if self.lootRollNewOptionLabel then
        local newOptionLabelWidth = GetFontStringWidth(self.lootRollNewOptionLabel, 72)
        self.lootRollNewOptionLabel:ClearAllPoints()
        self.lootRollNewOptionLabel:SetPoint("TOPLEFT", actionToolbarLeft, actionToolbarTop - 4)
        self.lootRollNewOptionLabel:Show()
        actionToolbarLeft = actionToolbarLeft + newOptionLabelWidth + 8
      end
      local editToolbarHeight = FlowLayoutControls({
        self.lootRollOptionEdit,
        self.lootAddRollOptionBtn,
        self.lootRemoveRollOptionBtn,
      }, actionToolbarLeft, actionToolbarTop, rollEditorWidth - (actionToolbarLeft - 34) - 16, 10, 8)
      local previewToolbarTop = actionToolbarTop - editToolbarHeight - 8
      local previewToolbarWidth = (self.lootTestRollPopupBtn and self.lootTestRollPopupBtn:GetWidth() or 0)
        + (self.lootPreviewHostBoardBtn and self.lootPreviewHostBoardBtn:GetWidth() or 0)
        + 10
      local previewToolbarLeft = math.max(34, 34 + rollEditorWidth - 16 - previewToolbarWidth)
      local previewToolbarHeight = FlowLayoutControls({
        self.lootTestRollPopupBtn,
        self.lootPreviewHostBoardBtn,
      }, previewToolbarLeft, previewToolbarTop, rollEditorWidth - (previewToolbarLeft - 34) - 16, 10, 8)
      local editorContentBottom = previewToolbarTop - previewToolbarHeight
      if not useRollSettingsTools then
        local transferToolbarTop = editorContentBottom - 8
        local transferToolbarHeight = FlowLayoutControls({
          self.lootRollExportBtn,
          self.lootRollImportStringBtn,
          self.lootRollImportProfileDropdown,
        }, 34, transferToolbarTop, rollEditorWidth - 16, 10, 8)
        editorContentBottom = transferToolbarTop - transferToolbarHeight
      end
      local inlinePreviewTop = rollPreviewSideBySide and rollTemplateTop or (editorContentBottom - 16)
      local inlinePreviewFrameWidth = rollPreviewSideBySide and rollPreviewWidth or textWidth
      local inlinePreviewLeft = rollPreviewSideBySide and (34 + rollEditorWidth + rollPreviewGap) or 34
      if self.lootRollInlinePreviewFrame then
        self.lootRollInlinePreviewFrame:ClearAllPoints()
        self.lootRollInlinePreviewFrame:SetPoint("TOPLEFT", inlinePreviewLeft, inlinePreviewTop)
        self.lootRollInlinePreviewFrame:SetSize(inlinePreviewFrameWidth, rollPreviewFrameHeight)
      end
      if self.lootRollInlinePreviewHint then
        self.lootRollInlinePreviewHint:SetWidth(inlinePreviewFrameWidth - 20)
      end
      if self.lootRollInlinePreviewNeedFrame and self.lootRollInlinePreviewFrame then
        self.lootRollInlinePreviewNeedFrame:ClearAllPoints()
        self.lootRollInlinePreviewNeedFrame:SetPoint("TOPLEFT", self.lootRollInlinePreviewFrame, "TOPLEFT", 10, -42)
        self.lootRollInlinePreviewNeedFrame:SetSize(inlinePreviewFrameWidth - 20, rollPreviewNeedHeight)
      end
      if self.lootRollInlinePreviewGreedFrame and self.lootRollInlinePreviewNeedFrame then
        self.lootRollInlinePreviewGreedFrame:ClearAllPoints()
        self.lootRollInlinePreviewGreedFrame:SetPoint("TOPLEFT", self.lootRollInlinePreviewNeedFrame, "BOTTOMLEFT", 0, -rollPreviewSectionGap)
        self.lootRollInlinePreviewGreedFrame:SetSize(inlinePreviewFrameWidth - 20, rollPreviewGreedHeight)
      end
      local needPreviewIndex = 0
      local greedPreviewIndex = 0
      for _, previewButton in ipairs(self.lootRollInlinePreviewButtons or {}) do
        if previewButton and previewButton:IsShown() then
          local isNeed = previewButton.__popupSection == "NEED"
          if isNeed then
            needPreviewIndex = needPreviewIndex + 1
          else
            greedPreviewIndex = greedPreviewIndex + 1
          end
          local rowIndex = isNeed and needPreviewIndex or greedPreviewIndex
          previewButton:ClearAllPoints()
          previewButton:SetPoint("TOPLEFT", previewButton:GetParent(), "TOPLEFT", 10, -28 - ((rowIndex - 1) * rollPreviewButtonHeight))
          previewButton:SetSize(inlinePreviewFrameWidth - 40, 24)
        end
      end
      local previewContentBottom = inlinePreviewTop - rollPreviewFrameHeight
      local rollContentBottom = math.min(editorContentBottom, previewContentBottom)
      local rollFrameHeight = math.max(134, (rollFrameTop - rollContentBottom) + 18)
      if self.lootProfileRollFrame then
        self.lootProfileRollFrame:ClearAllPoints()
        self.lootProfileRollFrame:SetPoint("TOPLEFT", 18, rollFrameTop)
        self.lootProfileRollFrame:SetSize(sectionWidth, rollFrameHeight)
        self.lootProfileRollFrame:Show()
      end
      currentSectionTop = rollFrameTop - rollFrameHeight - expandedSectionGap
    else
      if self.lootProfileRollFrame then self.lootProfileRollFrame:Hide() end
      self.lootRollOptionsText:Hide()
      if self.lootRollAccessHint then self.lootRollAccessHint:Hide() end
      self.lootRollTemplateLabel:Hide()
      self.lootRollTemplateDropdown:Hide()
      if self.lootRollSettingsToolsDropdown then self.lootRollSettingsToolsDropdown:Hide() end
      if self.lootRollResponsiveHint then self.lootRollResponsiveHint:Hide() end
      self.lootRollPriorityHeader:Hide()
      if self.lootRollMoveHeader then self.lootRollMoveHeader:Hide() end
      self.lootRollDescriptionHeader:Hide()
      self.lootRollIconHeader:Hide()
      self.lootRollColorHeader:Hide()
      if self.lootRollAppearanceHeader then self.lootRollAppearanceHeader:Hide() end
      self.lootRollPointDetailsHeader:Hide()
      self.lootRollCategoryHeader:Hide()
      self.lootRollOptionEdit:Hide()
      if self.lootRollNewOptionLabel then self.lootRollNewOptionLabel:Hide() end
      self.lootAddRollOptionBtn:Hide()
      self.lootRemoveRollOptionBtn:Hide()
      self.lootTestRollPopupBtn:Hide()
      self.lootPreviewHostBoardBtn:Hide()
      if self.lootRollExportBtn then self.lootRollExportBtn:Hide() end
      if self.lootRollImportStringBtn then self.lootRollImportStringBtn:Hide() end
      if self.lootRollImportProfileDropdown then self.lootRollImportProfileDropdown:Hide() end
      if self.lootRollOptionActionsHeader then self.lootRollOptionActionsHeader:Hide() end
      if self.lootRollOptionSaveStatus then self.lootRollOptionSaveStatus:Hide() end
      if self.lootRollPreviewActionsHeader then self.lootRollPreviewActionsHeader:Hide() end
      if self.lootRollTransferActionsHeader then self.lootRollTransferActionsHeader:Hide() end
      if self.lootRollInlinePreviewFrame then self.lootRollInlinePreviewFrame:Hide() end
      if self.lootRollInlinePreviewTitle then self.lootRollInlinePreviewTitle:Hide() end
      if self.lootRollInlinePreviewHint then self.lootRollInlinePreviewHint:Hide() end
      if self.lootRollInlinePreviewEmpty then self.lootRollInlinePreviewEmpty:Hide() end
      if self.lootRollInlinePreviewNeedFrame then self.lootRollInlinePreviewNeedFrame:Hide() end
      if self.lootRollInlinePreviewGreedFrame then self.lootRollInlinePreviewGreedFrame:Hide() end
      for _, previewButton in ipairs(self.lootRollInlinePreviewButtons or {}) do
        previewButton:Hide()
      end
      for _, row in ipairs(self.lootRollOptionRows or {}) do
        row:Hide()
      end
    end

    if pointsExpanded then
      local pointsFrameTop = currentSectionTop
      local pointModeTop = pointsFrameTop - 40
      local pointTransferHeaderTop = pointModeTop - 34
      local pointImportTop = pointTransferHeaderTop - 20
      local pointImportHeight = 0
      local lidTableColumnsTop = pointImportTop - 34
      local lidTableRowsTop = lidTableColumnsTop - 24
      local customRulesHeaderTop = pointImportTop - 34
      local ruleTextTop = (isLidTable and (lidTableRowsTop - lidTableRowsHeight - 14) or (customRulesHeaderTop - 36))

      self.lootPointModeLabel:Show()
      self.lootPointModeDropdown:Show()
      self.lootPointRulesText:Show()
      if self.lootPointExportBtn then self.lootPointExportBtn:Show() end
      if self.lootPointImportStringBtn then self.lootPointImportStringBtn:Show() end
      if self.lootPointImportProfileDropdown then self.lootPointImportProfileDropdown:Show() end

      if self.lootPointTransferHeader then
        self.lootPointTransferHeader:ClearAllPoints()
        self.lootPointTransferHeader:SetPoint("TOPLEFT", 34, pointTransferHeaderTop)
        self.lootPointTransferHeader:Show()
      end

      self.lootPointModeLabel:ClearAllPoints()
      self.lootPointModeLabel:SetPoint("TOPLEFT", 34, pointModeTop)
      self.lootPointModeDropdown:ClearAllPoints()
      self.lootPointModeDropdown:SetPoint("LEFT", self.lootPointModeLabel, "RIGHT", 8, 0)
      self.lootPointsHint:Hide()
      pointImportHeight = FlowLayoutControls({
        self.lootPointExportBtn,
        self.lootPointImportStringBtn,
        self.lootPointImportProfileDropdown,
      }, 34, pointImportTop, textWidth - 16, 10, 8)
      lidTableColumnsTop = pointImportTop - pointImportHeight - 12
      lidTableRowsTop = lidTableColumnsTop - 24
      customRulesHeaderTop = pointImportTop - pointImportHeight - 16
      ruleTextTop = (isLidTable and (lidTableRowsTop - lidTableRowsHeight - 14) or (customRulesHeaderTop - 36))
      local pointContentBottom = ruleTextTop - ruleTextHeight

      local lidTableLayout = nil
      if self.lootLidTableRows and self.lootLidTableRows[1] then
        lidTableLayout = self.lootLidTableRows[1].__layout
      end
      local showSetPiece = (lidTableLayout == nil) or (lidTableLayout.showSetPiece ~= false)
      local showOffSpec = (lidTableLayout == nil) or (lidTableLayout.showOffSpec ~= false)
      local showTransmog = (lidTableLayout == nil) or (lidTableLayout.showTransmog ~= false)
      local showDisenchant = (lidTableLayout == nil) or (lidTableLayout.showDisenchant ~= false)
      local pointsX = 84
      local itemLevelX = 64 + (lidPointsWidth or 52) + 10
      local setPieceX = itemLevelX + (lidItemLevelWidth or 68) + 10
      local offSpecX = setPieceX + (lidSetPieceWidth or 72) + 10
      local transmogX = offSpecX + (lidOffSpecWidth or 72) + 10
      local disenchantX = transmogX + (lidTransmogWidth or 72) + 10

      self.lootLidTablePointsLabel:ClearAllPoints()
      self.lootLidTablePointsLabel:SetPoint("TOPLEFT", pointsX, lidTableColumnsTop)
      self.lootLidTableItemLevelLabel:ClearAllPoints()
      self.lootLidTableItemLevelLabel:SetPoint("TOPLEFT", itemLevelX, lidTableColumnsTop)
      if showSetPiece then
        self.lootLidTableSetPieceLabel:ClearAllPoints()
        self.lootLidTableSetPieceLabel:SetPoint("TOPLEFT", setPieceX, lidTableColumnsTop)
      end
      if showOffSpec then
        self.lootLidTableOffSpecLabel:ClearAllPoints()
        self.lootLidTableOffSpecLabel:SetPoint("TOPLEFT", offSpecX, lidTableColumnsTop)
      end
      if showTransmog then
        self.lootLidTableTransmogLabel:ClearAllPoints()
        self.lootLidTableTransmogLabel:SetPoint("TOPLEFT", transmogX, lidTableColumnsTop)
      end
      if showDisenchant then
        self.lootLidTableDisenchantLabel:ClearAllPoints()
        self.lootLidTableDisenchantLabel:SetPoint("TOPLEFT", disenchantX, lidTableColumnsTop)
      end

      for i, row in ipairs(self.lootLidTableRows or {}) do
        row:ClearAllPoints()
        row:SetPoint("TOPLEFT", 34, lidTableRowsTop - ((i - 1) * lidTableRowSpacing))
        if isLidTable then
          row:Show()
        else
          row:Hide()
        end
      end

      if isLidTable then
        if self.lootPointCustomRulesHeader then self.lootPointCustomRulesHeader:Hide() end
        if self.lootPointItemLevelLabel then self.lootPointItemLevelLabel:Hide() end
        if self.lootPointLevelPointsLabel then self.lootPointLevelPointsLabel:Hide() end
        if self.lootPointItemLabel then self.lootPointItemLabel:Hide() end
        if self.lootPointItemPointsLabel then self.lootPointItemPointsLabel:Hide() end
        if self.lootPointExistingRulesHeader then self.lootPointExistingRulesHeader:Hide() end
        if self.lootPointRuleFeedback then self.lootPointRuleFeedback:Hide() end
        if self.lootPointRuleSelectHeader then self.lootPointRuleSelectHeader:Hide() end
        if self.lootPointRuleDescriptionHeader then self.lootPointRuleDescriptionHeader:Hide() end
        if self.lootPointRulePointsHeader then self.lootPointRulePointsHeader:Hide() end
        for _, row in ipairs(self.lootPointRuleRows or {}) do
          row:Hide()
        end
        self.lootLidTablePointsLabel:Show()
        self.lootLidTableItemLevelLabel:Show()
        self.lootLidTableSetPieceLabel:SetShown(showSetPiece)
        self.lootLidTableOffSpecLabel:SetShown(showOffSpec)
        self.lootLidTableTransmogLabel:SetShown(showTransmog)
        self.lootLidTableDisenchantLabel:SetShown(showDisenchant)
        self.lootPointItemLevelEdit:Hide()
        self.lootPointItemDropdown:Hide()
        if self.lootPointLevelValueEdit then self.lootPointLevelValueEdit:Hide() end
        if self.lootPointItemValueEdit then self.lootPointItemValueEdit:Hide() end
        self.lootAddPointRuleBtn:Hide()
        self.lootAddItemPointRuleBtn:Hide()
        self.lootRemovePointRuleBtn:Hide()
      else
        self.lootLidTablePointsLabel:Hide()
        self.lootLidTableItemLevelLabel:Hide()
        self.lootLidTableSetPieceLabel:Hide()
        self.lootLidTableOffSpecLabel:Hide()
        self.lootLidTableTransmogLabel:Hide()
        self.lootLidTableDisenchantLabel:Hide()
        if self.lootPointCustomRulesHeader then
          self.lootPointCustomRulesHeader:ClearAllPoints()
          self.lootPointCustomRulesHeader:SetPoint("TOPLEFT", 34, customRulesHeaderTop)
          self.lootPointCustomRulesHeader:Show()
        end
        self.lootPointItemLevelEdit:Show()
        self.lootPointItemDropdown:Show()
        if self.lootPointLevelValueEdit then self.lootPointLevelValueEdit:Show() end
        if self.lootPointItemValueEdit then self.lootPointItemValueEdit:Show() end
        self.lootAddPointRuleBtn:Show()
        self.lootAddItemPointRuleBtn:Show()
        self.lootRemovePointRuleBtn:Show()

        local levelLabelTop = customRulesHeaderTop - 20
        local levelInputTop = levelLabelTop - 18
        local itemLabelTop = levelInputTop - (pointFormCompact and 56 or 30)
        local itemInputTop = itemLabelTop - 18
        local pointRuleFeedbackTop = itemInputTop - (pointFormCompact and 56 or 30)
        local existingRulesHeaderTop = pointRuleFeedbackTop - 22
        local levelPointsEdit = self.lootPointLevelValueEdit or self.lootPointValueEdit

        if self.lootPointItemLevelLabel then
          self.lootPointItemLevelLabel:ClearAllPoints()
          self.lootPointItemLevelLabel:SetPoint("TOPLEFT", 34, levelLabelTop)
          self.lootPointItemLevelLabel:SetWidth(pointLevelWidth)
          self.lootPointItemLevelLabel:Show()
        end
        if self.lootPointLevelPointsLabel then
          self.lootPointLevelPointsLabel:ClearAllPoints()
          self.lootPointLevelPointsLabel:SetPoint("TOPLEFT", 34 + pointLevelWidth + 10, levelLabelTop)
          self.lootPointLevelPointsLabel:SetWidth(pointValueWidth)
          self.lootPointLevelPointsLabel:Show()
        end
        self.lootPointItemLevelEdit:ClearAllPoints()
        self.lootPointItemLevelEdit:SetPoint("TOPLEFT", 34, levelInputTop)
        if levelPointsEdit then
          levelPointsEdit:ClearAllPoints()
          levelPointsEdit:SetPoint("LEFT", self.lootPointItemLevelEdit, "RIGHT", 10, 0)
        end
        self.lootAddPointRuleBtn:ClearAllPoints()
        if pointFormCompact then
          self.lootAddPointRuleBtn:SetPoint("TOPLEFT", 34, levelInputTop - 28)
        elseif levelPointsEdit then
          self.lootAddPointRuleBtn:SetPoint("LEFT", levelPointsEdit, "RIGHT", 10, 0)
        end

        if self.lootPointItemLabel then
          self.lootPointItemLabel:ClearAllPoints()
          self.lootPointItemLabel:SetPoint("TOPLEFT", 34, itemLabelTop)
          self.lootPointItemLabel:SetWidth(pointItemWidth)
          self.lootPointItemLabel:Show()
        end
        if self.lootPointItemPointsLabel then
          self.lootPointItemPointsLabel:ClearAllPoints()
          self.lootPointItemPointsLabel:SetPoint("TOPLEFT", 34 + pointItemWidth + 10, itemLabelTop)
          self.lootPointItemPointsLabel:SetWidth(pointValueWidth)
          self.lootPointItemPointsLabel:Show()
        end
        self.lootPointItemDropdown:ClearAllPoints()
        self.lootPointItemDropdown:SetPoint("TOPLEFT", 34, itemInputTop)
        if self.lootPointItemValueEdit then
          self.lootPointItemValueEdit:ClearAllPoints()
          self.lootPointItemValueEdit:SetPoint("LEFT", self.lootPointItemDropdown, "RIGHT", 10, 0)
        end
        self.lootAddItemPointRuleBtn:ClearAllPoints()
        if pointFormCompact then
          self.lootAddItemPointRuleBtn:SetPoint("TOPLEFT", 34, itemInputTop - 28)
        elseif self.lootPointItemValueEdit then
          self.lootAddItemPointRuleBtn:SetPoint("LEFT", self.lootPointItemValueEdit, "RIGHT", 10, 0)
        end

        if self.lootPointRuleFeedback then
          self.lootPointRuleFeedback:ClearAllPoints()
          self.lootPointRuleFeedback:SetPoint("TOPLEFT", 34, pointRuleFeedbackTop)
          self.lootPointRuleFeedback:SetWidth(textWidth)
          local feedbackText = tostring(self.lootPointRuleFeedback:GetText() or "")
          self.lootPointRuleFeedback:SetShown(feedbackText ~= "")
        end
        if self.lootPointExistingRulesHeader then
          self.lootPointExistingRulesHeader:ClearAllPoints()
          self.lootPointExistingRulesHeader:SetPoint("TOPLEFT", 34, existingRulesHeaderTop)
          self.lootPointExistingRulesHeader:Show()
        end
        self.lootRemovePointRuleBtn:ClearAllPoints()
        self.lootRemovePointRuleBtn:SetPoint("TOPLEFT", 34 + textWidth - pointRuleActionWidth, existingRulesHeaderTop + 4)
        ruleTextTop = existingRulesHeaderTop - 22
        local hasPointRuleRows = pointRuleRowCount > 0
        if hasPointRuleRows then
          local ruleRowsTop = ruleTextTop - 20
          self.lootPointRulesText:Hide()
          if self.lootPointRuleSelectHeader then
            self.lootPointRuleSelectHeader:ClearAllPoints()
            self.lootPointRuleSelectHeader:SetPoint("TOPLEFT", 34, ruleTextTop)
            self.lootPointRuleSelectHeader:Show()
          end
          if self.lootPointRuleDescriptionHeader then
            self.lootPointRuleDescriptionHeader:ClearAllPoints()
            self.lootPointRuleDescriptionHeader:SetPoint("TOPLEFT", 86, ruleTextTop)
            self.lootPointRuleDescriptionHeader:Show()
          end
          if self.lootPointRulePointsHeader then
            self.lootPointRulePointsHeader:ClearAllPoints()
            self.lootPointRulePointsHeader:SetPoint("TOPLEFT", 34 + textWidth - 90, ruleTextTop)
            self.lootPointRulePointsHeader:SetWidth(90)
            self.lootPointRulePointsHeader:Show()
          end
          for index, row in ipairs(self.lootPointRuleRows or {}) do
            if row.__rule then
              row:ClearAllPoints()
              row:SetPoint("TOPLEFT", 34, ruleRowsTop - ((index - 1) * pointRuleRowSpacing))
              row:Show()
            else
              row:Hide()
            end
          end
          pointContentBottom = ruleRowsTop - pointRuleRowsHeight
        else
          if self.lootPointRuleSelectHeader then self.lootPointRuleSelectHeader:Hide() end
          if self.lootPointRuleDescriptionHeader then self.lootPointRuleDescriptionHeader:Hide() end
          if self.lootPointRulePointsHeader then self.lootPointRulePointsHeader:Hide() end
          for _, row in ipairs(self.lootPointRuleRows or {}) do
            row:Hide()
          end
          self.lootPointRulesText:Show()
          pointContentBottom = ruleTextTop - ruleTextHeight
        end
      end

      self.lootPointRulesText:ClearAllPoints()
      self.lootPointRulesText:SetPoint("TOPLEFT", 34, ruleTextTop)

      local pointsFrameHeight = math.max(168, (pointsFrameTop - pointContentBottom) + 18)
      if self.lootProfilePointsFrame then
        self.lootProfilePointsFrame:ClearAllPoints()
        self.lootProfilePointsFrame:SetPoint("TOPLEFT", 18, pointsFrameTop)
        self.lootProfilePointsFrame:SetSize(sectionWidth, pointsFrameHeight)
        self.lootProfilePointsFrame:Show()
      end
      currentSectionTop = pointsFrameTop - pointsFrameHeight - expandedSectionGap
    else
      if self.lootProfilePointsFrame then self.lootProfilePointsFrame:Hide() end
      self.lootPointModeLabel:Hide()
      self.lootPointModeDropdown:Hide()
      self.lootPointsHint:Hide()
      if self.lootPointExportBtn then self.lootPointExportBtn:Hide() end
      if self.lootPointImportStringBtn then self.lootPointImportStringBtn:Hide() end
      if self.lootPointImportProfileDropdown then self.lootPointImportProfileDropdown:Hide() end
      self.lootLidTablePointsLabel:Hide()
      self.lootLidTableItemLevelLabel:Hide()
      self.lootLidTableSetPieceLabel:Hide()
      self.lootLidTableOffSpecLabel:Hide()
      self.lootLidTableTransmogLabel:Hide()
      self.lootLidTableDisenchantLabel:Hide()
      self.lootPointItemLevelEdit:Hide()
      self.lootPointItemDropdown:Hide()
      if self.lootPointLevelValueEdit then self.lootPointLevelValueEdit:Hide() end
      if self.lootPointItemValueEdit then self.lootPointItemValueEdit:Hide() end
      self.lootAddPointRuleBtn:Hide()
      self.lootAddItemPointRuleBtn:Hide()
      self.lootRemovePointRuleBtn:Hide()
      self.lootPointRulesText:Hide()
      if self.lootPointTransferHeader then self.lootPointTransferHeader:Hide() end
      if self.lootPointCustomRulesHeader then self.lootPointCustomRulesHeader:Hide() end
      if self.lootPointItemLevelLabel then self.lootPointItemLevelLabel:Hide() end
      if self.lootPointLevelPointsLabel then self.lootPointLevelPointsLabel:Hide() end
      if self.lootPointItemLabel then self.lootPointItemLabel:Hide() end
      if self.lootPointItemPointsLabel then self.lootPointItemPointsLabel:Hide() end
      if self.lootPointExistingRulesHeader then self.lootPointExistingRulesHeader:Hide() end
      if self.lootPointRuleFeedback then self.lootPointRuleFeedback:Hide() end
      if self.lootPointRuleSelectHeader then self.lootPointRuleSelectHeader:Hide() end
      if self.lootPointRuleDescriptionHeader then self.lootPointRuleDescriptionHeader:Hide() end
      if self.lootPointRulePointsHeader then self.lootPointRulePointsHeader:Hide() end
      for _, row in ipairs(self.lootPointRuleRows or {}) do
        row:Hide()
      end
      for _, row in ipairs(self.lootLidTableRows or {}) do
        row:Hide()
      end
    end

    if backupExpanded then
      local backupFrameTop = currentSectionTop
      local backupTextTop = backupFrameTop - 40
      local backupTextHeight = math.max(32, math.ceil((self.lootProfileBackupText and self.lootProfileBackupText:GetStringHeight() or 0)))
      local backupCreateHeaderTop = backupTextTop - backupTextHeight - 18
      local backupSaveTop = backupCreateHeaderTop - 20
      local backupSavedHeaderTop = backupSaveTop - 34
      local backupSavedControlsTop = backupSavedHeaderTop - 20
      local backupSavedControlsHeight = 0

      if self.lootProfileBackupFrame then
        self.lootProfileBackupFrame:ClearAllPoints()
        self.lootProfileBackupFrame:SetPoint("TOPLEFT", 18, backupFrameTop)
        self.lootProfileBackupFrame:SetSize(sectionWidth, 130)
        self.lootProfileBackupFrame:Show()
      end
      if self.lootProfileBackupHeader then
        self.lootProfileBackupHeader:ClearAllPoints()
        self.lootProfileBackupHeader:SetPoint("TOPLEFT", 34, backupTextTop + 20)
        self.lootProfileBackupHeader:Show()
      end
      if self.lootProfileBackupText then
        self.lootProfileBackupText:ClearAllPoints()
        self.lootProfileBackupText:SetPoint("TOPLEFT", 34, backupTextTop)
        self.lootProfileBackupText:SetWidth(textWidth)
        self.lootProfileBackupText:Show()
      end
      if self.lootProfileSaveBackupBtn then self.lootProfileSaveBackupBtn:Show() end
      if self.lootProfileBackupDropdown then self.lootProfileBackupDropdown:Show() end
      if self.lootProfileLoadBackupBtn then self.lootProfileLoadBackupBtn:Show() end
      if self.lootProfileDeleteBackupBtn then self.lootProfileDeleteBackupBtn:Show() end
      if self.lootProfileBackupCreateHeader then
        self.lootProfileBackupCreateHeader:ClearAllPoints()
        self.lootProfileBackupCreateHeader:SetPoint("TOPLEFT", 34, backupCreateHeaderTop)
        self.lootProfileBackupCreateHeader:Show()
      end
      if self.lootProfileSaveBackupBtn then
        self.lootProfileSaveBackupBtn:ClearAllPoints()
        self.lootProfileSaveBackupBtn:SetPoint("TOPLEFT", 34, backupSaveTop)
      end
      if self.lootProfileBackupSavedHeader then
        self.lootProfileBackupSavedHeader:ClearAllPoints()
        self.lootProfileBackupSavedHeader:SetPoint("TOPLEFT", 34, backupSavedHeaderTop)
        self.lootProfileBackupSavedHeader:Show()
      end
      backupSavedControlsHeight = FlowLayoutControls({
        self.lootProfileBackupDropdown,
        self.lootProfileLoadBackupBtn,
        self.lootProfileDeleteBackupBtn,
      }, 34, backupSavedControlsTop, textWidth - 16, 10, 8)
      local backupFrameHeight = math.max(176, (backupFrameTop - backupSavedControlsTop) + backupSavedControlsHeight + 20)
      if self.lootProfileBackupFrame then
        self.lootProfileBackupFrame:SetSize(sectionWidth, backupFrameHeight)
      end
      currentSectionTop = backupFrameTop - backupFrameHeight - expandedSectionGap
    else
      if self.lootProfileBackupFrame then self.lootProfileBackupFrame:Hide() end
      if self.lootProfileBackupHeader then self.lootProfileBackupHeader:Hide() end
      if self.lootProfileBackupText then self.lootProfileBackupText:Hide() end
      if self.lootProfileBackupCreateHeader then self.lootProfileBackupCreateHeader:Hide() end
      if self.lootProfileBackupSavedHeader then self.lootProfileBackupSavedHeader:Hide() end
      if self.lootProfileSaveBackupBtn then self.lootProfileSaveBackupBtn:Hide() end
      if self.lootProfileBackupDropdown then self.lootProfileBackupDropdown:Hide() end
      if self.lootProfileLoadBackupBtn then self.lootProfileLoadBackupBtn:Hide() end
      if self.lootProfileDeleteBackupBtn then self.lootProfileDeleteBackupBtn:Hide() end
    end

    if type(INTERNAL_API.LIDCOUNCIL_ProfileTransferPage_Impl) == "table" then
      currentSectionTop = INTERNAL_API.LIDCOUNCIL_ProfileTransferPage_Impl.Layout(
        self,
        importExportFeatureEnabled and openSection == "transfer",
        currentSectionTop,
        sectionWidth,
        textWidth,
        expandedSectionGap
      )
    end

    local dropdownFrameLevel = ((self.lootProfilesRightContent and self.lootProfilesRightContent.GetFrameLevel and self.lootProfilesRightContent:GetFrameLevel()) or 1) + 10
    if type(self.__lidcouncilCustomDropdowns) == "table" then
      for _, dropdown in ipairs(self.__lidcouncilCustomDropdowns) do
        RaiseDropdownControl(dropdown, dropdownFrameLevel)
      end
    end

    local contentBottom = math.abs(currentSectionTop) + 24
    page.__contentHeight = 1
    self.lootProfilesRightContent:SetSize(contentWidth, math.max(1, contentBottom))
    if self.lootProfilesRightScroll and self.lootProfilesRightScroll.UpdateScrollChildRect then
      self.lootProfilesRightScroll:UpdateScrollChildRect()
    end
    if self.lootProfilesListScroll and self.lootProfilesListScroll.UpdateScrollChildRect then
      self.lootProfilesListScroll:UpdateScrollChildRect()
    end
  end

  return {
    LayoutProfileContent = LayoutProfileContent,
  }
end
