local function CreateBD(f, a)
	f:SetBackdrop({
		bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
		edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
		edgeSize = 1,
	})
	f:SetBackdropColor(0, 0, 0, a or .5)
	f:SetBackdropBorderColor(0, 0, 0)
end

LootFramePortraitOverlay:Hide()
select(2, LootFrame:GetRegions()):Hide()
LootCloseButton:GetNormalTexture():SetDesaturated(1)

LootFrame.bg = CreateFrame("Frame", nil, LootFrame)
LootFrame.bg:SetFrameLevel(LootFrame:GetFrameLevel()-1)
LootFrame.bg:SetPoint("TOPLEFT", LootFrame, "TOPLEFT", 20, -12)
LootFrame.bg:SetPoint("BOTTOMRIGHT", LootFrame, "BOTTOMRIGHT", -66, 12)

CreateBD(LootFrame.bg)

select(3, LootFrame:GetRegions()):SetPoint("TOP", LootFrame.bg, "TOP", 0, -8)

for i = 1, LOOTFRAME_NUMBUTTONS do
	local bu = _G["LootButton"..i]
	local ic = _G["LootButton"..i.."IconTexture"]
	_G["LootButton"..i.."IconQuestTexture"]:SetAlpha(0)
	local _, _, _, _, _, _, _, bg = bu:GetRegions()

	bu:SetNormalTexture("")
	bu:SetPushedTexture("")

	local bd = CreateFrame("Frame", nil, bu)
	bd:SetPoint("TOPLEFT")
	bd:SetPoint("BOTTOMRIGHT", 126, 0)
	bd:SetFrameLevel(bu:GetFrameLevel()-1)
	CreateBD(bd, .25)

	ic:SetTexCoord(.08, .92, .08, .92)
	ic.bg = bu:CreateTexture(nil, "BACKGROUND")
	ic.bg:SetPoint("TOPLEFT", ic, -1, 1)
	ic.bg:SetPoint("BOTTOMRIGHT", ic, 1, -1)
	ic.bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
	ic.bg:SetVertexColor(0, 0, 0)

	bg:Hide()
end

hooksecurefunc("LootFrame_UpdateButton", function(index)
	local ic = _G["LootButton"..index.."IconTexture"]
	if select(6, GetLootSlotInfo(index)) then
		ic.bg:SetVertexColor(1, 0, 0)
	else
		ic.bg:SetVertexColor(0, 0, 0)
	end
end)