-- DynamicTooltips: Theme System
-- Complete visual overhaul themes - each one transforms the entire tooltip

local _, DT = ...

DT.Themes = {}

-- ============================================================================
-- THEME DEFINITIONS
-- Each theme is a COMPLETE visual overhaul: backdrop, border, text, everything
-- ============================================================================

DT.Themes.List = {
    -- ========================================================================
    -- DEFAULT (Standard Blizzard tooltip appearance)
    -- ========================================================================
    ["default"] = {
        name = "Default",
        description = "Standard Blizzard tooltip style",

        backdrop = {
            bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
            edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
            tile = true,
            tileSize = 16,
            edgeSize = 16,
            insets = { left = 4, right = 4, top = 4, bottom = 4 },
            bgColor = { r = 0.0, g = 0.0, b = 0.05, a = 0.90 },
            borderColor = { r = 0.5, g = 0.5, b = 0.5, a = 0.9 },
        },

        titleColor  = { r = 1.0, g = 0.82, b = 0.0 },
        bodyColor   = { r = 1.0, g = 1.0, b = 1.0 },
        footerColor = { r = 0.6, g = 0.6, b = 0.6 },

        border = {
            color = { r = 0.5, g = 0.5, b = 0.5, a = 0.9 },
            size = 16,
        },
        background = {
            primary = { r = 0.0, g = 0.0, b = 0.05, a = 0.90 },
        },

        text = {
            title = { r = 1.0, g = 0.82, b = 0.0 },
            rank = { r = 0.5, g = 0.5, b = 0.5 },
            mana = { r = 0.4, g = 0.6, b = 1.0 },
            range = { r = 1.0, g = 1.0, b = 1.0 },
            castTime = { r = 1.0, g = 1.0, b = 1.0 },
            cooldown = { r = 1.0, g = 1.0, b = 1.0 },
            description = { r = 1.0, g = 0.82, b = 0.0 },
            restriction = { r = 1.0, g = 0.13, b = 0.13 },
            footer = { r = 0.6, g = 0.6, b = 0.6 },
            stats = { r = 1.0, g = 1.0, b = 1.0 },
            base = { r = 0.0, g = 0.85, b = 0.0 },
            gold = { r = 1.0, g = 0.82, b = 0.0 },
            spellPower = { r = 1.0, g = 0.82, b = 0.0 },
            dps = { r = 1.0, g = 0.65, b = 0.0 },
            efficiency = { r = 0.5, g = 0.8, b = 1.0 },
            warning = { r = 1.0, g = 0.5, b = 0.0 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "~",
            instant = "!",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = "@",
        },

        dividers = {
            thin = "------------------------------",
            thick = "==============================",
            section = "--- %s ---",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = false,
        },

        layout = {
            padding = 12,
            cornerRadius = 0,
            spacing = 4,
        },
    },

    -- ========================================================================
    -- MEDIEVAL (Clean dark backdrop, ornate DialogFrame border, gold title)
    -- Faithful to the Seconds_to_full addon's look
    -- ========================================================================
    ["medieval"] = {
        name = "Medieval",
        description = "Classic DialogFrame look with gold title",

        -- Complete backdrop definition — exact STF match
        backdrop = {
            bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
            edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
            tile = true,
            tileSize = 32,
            edgeSize = 16,
            insets = { left = 4, right = 4, top = 4, bottom = 4 },
            bgColor = { r = 0, g = 0, b = 0, a = 0.55 },
            borderColor = { r = 1.0, g = 1.0, b = 1.0, a = 1.0 },
        },

        -- Title / body / footer — match STF's GameFontNormal colors
        titleColor  = { r = 1.0, g = 0.82, b = 0.0 },        -- Gold (STF title)
        bodyColor   = { r = 1.0, g = 1.0, b = 1.0 },          -- Clean white (GameFontNormal)
        footerColor = { r = 0.7, g = 0.7, b = 0.7 },          -- Grey (STF details)

        border = {
            color = { r = 1.0, g = 1.0, b = 1.0, a = 1.0 },
            size = 16,
        },
        background = {
            primary = { r = 0, g = 0, b = 0, a = 0.10 },
        },

        text = {
            title = { r = 1.0, g = 0.82, b = 0.0 },
            rank = { r = 0.85, g = 0.72, b = 0.45 },
            mana = { r = 0.45, g = 0.65, b = 1.0 },
            range = { r = 0.90, g = 0.90, b = 0.90 },
            castTime = { r = 0.90, g = 0.90, b = 0.85 },
            cooldown = { r = 0.80, g = 0.80, b = 0.75 },
            description = { r = 1.0, g = 1.0, b = 1.0 },
            restriction = { r = 0.9, g = 0.45, b = 0.35 },
            footer = { r = 0.7, g = 0.7, b = 0.7 },
            stats = { r = 0.85, g = 0.85, b = 0.80 },
            base = { r = 0.40, g = 0.90, b = 0.40 },
            gold = { r = 1.0, g = 0.90, b = 0.40 },
            spellPower = { r = 1.0, g = 0.90, b = 0.40 },
            dps = { r = 1.0, g = 0.70, b = 0.30 },
            efficiency = { r = 0.40, g = 0.85, b = 0.50 },
            warning = { r = 1.0, g = 0.65, b = 0.30 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "~",
            instant = "!",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = "@",
        },

        dividers = {
            thin = "|cffaa8844-----------------------------|r",
            thick = "|cffaa8844============================|r",
            section = "|cffdaa520--- %s ---|r",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = false,  -- STF has no gradient — clean look
        },

        layout = {
            padding = 14,
            cornerRadius = 6,
            spacing = 5,
        },
    },

    -- ========================================================================
    -- CYBERPUNK (Pure black void, hot neon magenta/cyan edges, scanline feel)
    -- ========================================================================
    ["cyberpunk"] = {
        name = "Cyberpunk",
        description = "Neon-lit void with magenta and cyan",

        backdrop = {
            bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
            edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
            tile = true,
            tileSize = 16,
            edgeSize = 16,
            insets = { left = 3, right = 3, top = 3, bottom = 3 },
            bgColor = { r = 0.03, g = 0.0, b = 0.06, a = 0.95 },
            borderColor = { r = 1.0, g = 0.0, b = 0.8, a = 0.9 },
        },

        titleColor = { r = 0.0, g = 1.0, b = 1.0 },          -- Electric cyan
        bodyColor  = { r = 0.85, g = 0.85, b = 0.95 },        -- Cool white
        footerColor = { r = 0.5, g = 0.3, b = 0.7 },          -- Dim purple

        border = {
            color = { r = 1.0, g = 0.0, b = 0.8, a = 0.9 },
            size = 16,
        },
        background = {
            primary = { r = 0.03, g = 0.0, b = 0.06, a = 0.95 },
        },

        text = {
            title = { r = 0.0, g = 1.0, b = 1.0 },
            rank = { r = 1.0, g = 0.0, b = 0.8 },
            mana = { r = 0.0, g = 0.8, b = 1.0 },
            range = { r = 0.75, g = 0.75, b = 0.90 },
            castTime = { r = 1.0, g = 1.0, b = 0.0 },
            cooldown = { r = 0.8, g = 0.3, b = 1.0 },
            description = { r = 0.85, g = 0.85, b = 0.95 },
            restriction = { r = 1.0, g = 0.2, b = 0.4 },
            footer = { r = 0.5, g = 0.3, b = 0.7 },
            stats = { r = 0.7, g = 0.9, b = 1.0 },
            base = { r = 0.0, g = 1.0, b = 0.4 },
            gold = { r = 1.0, g = 0.9, b = 0.0 },
            spellPower = { r = 1.0, g = 0.9, b = 0.0 },
            dps = { r = 1.0, g = 0.4, b = 0.0 },
            efficiency = { r = 0.0, g = 1.0, b = 1.0 },
            warning = { r = 1.0, g = 0.3, b = 0.6 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "~",
            instant = ">>>",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = ":::",
        },

        dividers = {
            thin = "///// ///// ///// ///// ////",
            thick = "<<<<<<<<<<<<<<<<<<<<<<<<<<<<",
            section = "<< %s >>",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = true,
            color = { r = 1.0, g = 0.0, b = 0.8, a = 0.15 },  -- Neon magenta pulse
            height = 28,
        },

        layout = {
            padding = 14,
            cornerRadius = 0,
            spacing = 5,
        },
    },

    -- ========================================================================
    -- NATURE (Deep forest green, earthy brown-green edges, organic)
    -- ========================================================================
    ["nature"] = {
        name = "Nature",
        description = "Deep forest floor with earthy tones",

        backdrop = {
            bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
            edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
            tile = true,
            tileSize = 16,
            edgeSize = 14,
            insets = { left = 4, right = 4, top = 4, bottom = 4 },
            bgColor = { r = 0.04, g = 0.08, b = 0.03, a = 0.93 },
            borderColor = { r = 0.45, g = 0.6, b = 0.3, a = 0.8 },
        },

        titleColor = { r = 0.80, g = 0.95, b = 0.65 },       -- Bright leaf green
        bodyColor  = { r = 0.82, g = 0.88, b = 0.78 },        -- Pale sage
        footerColor = { r = 0.42, g = 0.50, b = 0.35 },       -- Moss

        border = {
            color = { r = 0.45, g = 0.6, b = 0.3, a = 0.8 },
            size = 14,
        },
        background = {
            primary = { r = 0.04, g = 0.08, b = 0.03, a = 0.93 },
        },

        text = {
            title = { r = 0.80, g = 0.95, b = 0.65 },
            rank = { r = 0.6, g = 0.8, b = 0.5 },
            mana = { r = 0.5, g = 0.75, b = 0.9 },
            range = { r = 0.72, g = 0.82, b = 0.68 },
            castTime = { r = 0.8, g = 0.85, b = 0.65 },
            cooldown = { r = 0.7, g = 0.8, b = 0.6 },
            description = { r = 0.82, g = 0.88, b = 0.78 },
            restriction = { r = 0.85, g = 0.5, b = 0.4 },
            footer = { r = 0.42, g = 0.50, b = 0.35 },
            stats = { r = 0.65, g = 0.8, b = 0.55 },
            base = { r = 0.4, g = 0.95, b = 0.35 },
            gold = { r = 0.85, g = 0.9, b = 0.5 },
            spellPower = { r = 0.8, g = 0.9, b = 0.4 },
            dps = { r = 0.7, g = 0.85, b = 0.3 },
            efficiency = { r = 0.5, g = 0.9, b = 0.5 },
            warning = { r = 0.9, g = 0.7, b = 0.4 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "|cff77aa55~|r",
            instant = "|cff88cc44!|r",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = "|cff558844@|r",
        },

        dividers = {
            thin = "~<@>~~<@>~~<@>~~<@>~~<@>~",
            thick = "~=~ ~=~ ~=~ ~=~ ~=~",
            section = "~<@> %s <@>~",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = true,
            color = { r = 0.4, g = 0.8, b = 0.3, a = 0.10 },  -- Forest light filtering through canopy
            height = 30,
        },

        layout = {
            padding = 12,
            cornerRadius = 6,
            spacing = 4,
        },
    },

    -- ========================================================================
    -- FIRE (Smoldering ember pit, red-orange edges, volcanic heat)
    -- ========================================================================
    ["fire"] = {
        name = "Fire",
        description = "Smoldering embers with volcanic heat",

        backdrop = {
            bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
            edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
            tile = true,
            tileSize = 16,
            edgeSize = 18,
            insets = { left = 4, right = 4, top = 4, bottom = 4 },
            bgColor = { r = 0.10, g = 0.03, b = 0.02, a = 0.95 },
            borderColor = { r = 1.0, g = 0.45, b = 0.15, a = 0.90 },
        },

        titleColor = { r = 1.0, g = 0.75, b = 0.30 },        -- Molten gold-orange
        bodyColor  = { r = 0.95, g = 0.88, b = 0.80 },        -- Warm cream
        footerColor = { r = 0.60, g = 0.42, b = 0.30 },       -- Cooled ash

        border = {
            color = { r = 1.0, g = 0.45, b = 0.15, a = 0.90 },
            size = 18,
        },
        background = {
            primary = { r = 0.10, g = 0.03, b = 0.02, a = 0.95 },
        },

        text = {
            title = { r = 1.0, g = 0.75, b = 0.30 },
            rank = { r = 1.0, g = 0.6, b = 0.35 },
            mana = { r = 0.5, g = 0.7, b = 1.0 },
            range = { r = 0.92, g = 0.82, b = 0.72 },
            castTime = { r = 1.0, g = 0.85, b = 0.5 },
            cooldown = { r = 1.0, g = 0.75, b = 0.4 },
            description = { r = 0.95, g = 0.88, b = 0.80 },
            restriction = { r = 1.0, g = 0.3, b = 0.3 },
            footer = { r = 0.60, g = 0.42, b = 0.30 },
            stats = { r = 1.0, g = 0.7, b = 0.5 },
            base = { r = 0.4, g = 0.9, b = 0.4 },
            gold = { r = 1.0, g = 0.9, b = 0.4 },
            spellPower = { r = 1.0, g = 0.85, b = 0.2 },
            dps = { r = 1.0, g = 0.5, b = 0.1 },
            efficiency = { r = 0.5, g = 0.9, b = 0.5 },
            warning = { r = 1.0, g = 0.4, b = 0.3 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "~",
            instant = "!!",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = "@",
        },

        dividers = {
            thin = "~^~^~^~^~^~^~^~^~^~",
            thick = "<~> <~> <~> <~> <~>",
            section = "~~ %s ~~",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = true,
            color = { r = 1.0, g = 0.4, b = 0.1, a = 0.15 },  -- Orange ember glow
            height = 30,
        },

        layout = {
            padding = 14,
            cornerRadius = 4,
            spacing = 4,
        },
    },

    -- ========================================================================
    -- MINIMAL (Semi-transparent, frosted white edges, airy feel)
    -- ========================================================================
    ["minimal"] = {
        name = "Minimal",
        description = "Frosted glass with translucent depth",

        backdrop = {
            bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
            edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
            tile = true,
            tileSize = 16,
            edgeSize = 8,
            insets = { left = 2, right = 2, top = 2, bottom = 2 },
            bgColor = { r = 0.10, g = 0.10, b = 0.12, a = 0.72 },
            borderColor = { r = 0.80, g = 0.80, b = 0.85, a = 0.12 },
        },

        titleColor = { r = 0.96, g = 0.96, b = 0.98 },       -- Bright frost white
        bodyColor  = { r = 0.88, g = 0.88, b = 0.90 },        -- Soft white
        footerColor = { r = 0.52, g = 0.52, b = 0.55 },       -- Glass tint grey

        border = {
            color = { r = 0.80, g = 0.80, b = 0.85, a = 0.12 },
            size = 8,
        },
        background = {
            primary = { r = 0.10, g = 0.10, b = 0.12, a = 0.72 },
        },

        text = {
            title = { r = 0.96, g = 0.96, b = 0.98 },
            rank = { r = 0.72, g = 0.72, b = 0.75 },
            mana = { r = 0.62, g = 0.68, b = 0.78 },
            range = { r = 0.80, g = 0.80, b = 0.82 },
            castTime = { r = 0.85, g = 0.82, b = 0.78 },
            cooldown = { r = 0.72, g = 0.70, b = 0.75 },
            description = { r = 0.88, g = 0.88, b = 0.90 },
            restriction = { r = 0.75, g = 0.55, b = 0.55 },
            footer = { r = 0.52, g = 0.52, b = 0.55 },
            stats = { r = 0.78, g = 0.78, b = 0.80 },
            base = { r = 0.68, g = 0.82, b = 0.68 },
            gold = { r = 0.88, g = 0.82, b = 0.68 },
            spellPower = { r = 0.88, g = 0.82, b = 0.68 },
            dps = { r = 0.85, g = 0.72, b = 0.62 },
            efficiency = { r = 0.68, g = 0.78, b = 0.78 },
            warning = { r = 0.82, g = 0.68, b = 0.58 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "~",
            instant = "!",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = "o",
        },

        dividers = {
            thin = ". . . . . . . . . . . . . . .",
            thick = "_____________________________",
            section = "[ %s ]",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = true,
            color = { r = 0.9, g = 0.9, b = 1.0, a = 0.08 },  -- White frost highlight
            height = 28,
        },

        layout = {
            padding = 12,
            cornerRadius = 12,
            spacing = 4,
        },
    },

    -- ========================================================================
    -- VOID (Deep shadow purple, eldritch whispers from the dark beyond)
    -- ========================================================================
    ["void"] = {
        name = "Void",
        description = "Eldritch shadow from the dark beyond",

        backdrop = {
            bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
            edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
            tile = true,
            tileSize = 16,
            edgeSize = 18,
            insets = { left = 4, right = 4, top = 4, bottom = 4 },
            bgColor = { r = 0.06, g = 0.02, b = 0.10, a = 0.95 },
            borderColor = { r = 0.55, g = 0.30, b = 0.85, a = 0.90 },
        },

        titleColor  = { r = 0.82, g = 0.65, b = 1.0 },       -- Pale violet
        bodyColor   = { r = 0.80, g = 0.78, b = 0.88 },       -- Lavender grey
        footerColor = { r = 0.42, g = 0.35, b = 0.55 },       -- Dim purple

        border = {
            color = { r = 0.55, g = 0.30, b = 0.85, a = 0.90 },
            size = 18,
        },
        background = {
            primary = { r = 0.06, g = 0.02, b = 0.10, a = 0.95 },
        },

        text = {
            title = { r = 0.82, g = 0.65, b = 1.0 },
            rank = { r = 0.65, g = 0.50, b = 0.85 },
            mana = { r = 0.55, g = 0.45, b = 0.90 },
            range = { r = 0.72, g = 0.68, b = 0.82 },
            castTime = { r = 0.78, g = 0.70, b = 0.90 },
            cooldown = { r = 0.60, g = 0.50, b = 0.80 },
            description = { r = 0.80, g = 0.78, b = 0.88 },
            restriction = { r = 0.90, g = 0.40, b = 0.50 },
            footer = { r = 0.42, g = 0.35, b = 0.55 },
            stats = { r = 0.70, g = 0.62, b = 0.88 },
            base = { r = 0.60, g = 0.80, b = 1.0 },
            gold = { r = 0.80, g = 0.70, b = 1.0 },
            spellPower = { r = 0.85, g = 0.65, b = 1.0 },
            dps = { r = 0.75, g = 0.55, b = 0.95 },
            efficiency = { r = 0.60, g = 0.70, b = 0.90 },
            warning = { r = 0.90, g = 0.50, b = 0.70 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "~",
            instant = "|cffaa66ff!|r",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = "o",
        },

        dividers = {
            thin = "|cff7744bb-~-~-~-~-~-~-~-~-~-~-|r",
            thick = "|cff7744bb=~=~=~=~=~=~=~=~=~=~=|r",
            section = "|cffaa77ee-~ %s ~-|r",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = true,
            color = { r = 0.55, g = 0.20, b = 0.90, a = 0.14 },  -- Deep void purple glow
            height = 32,
        },

        layout = {
            padding = 14,
            cornerRadius = 8,
            spacing = 4,
        },
    },

    -- ========================================================================
    -- FROST (Icy blue, frozen crystalline edges, death knight chill)
    -- ========================================================================
    ["frost"] = {
        name = "Frost",
        description = "Frozen crystalline with icy chill",

        backdrop = {
            bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
            edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
            tile = true,
            tileSize = 16,
            edgeSize = 14,
            insets = { left = 3, right = 3, top = 3, bottom = 3 },
            bgColor = { r = 0.03, g = 0.06, b = 0.12, a = 0.94 },
            borderColor = { r = 0.50, g = 0.78, b = 1.0, a = 0.85 },
        },

        titleColor  = { r = 0.75, g = 0.92, b = 1.0 },       -- Ice blue white
        bodyColor   = { r = 0.82, g = 0.88, b = 0.95 },       -- Pale frost
        footerColor = { r = 0.40, g = 0.52, b = 0.62 },       -- Dim slate ice

        border = {
            color = { r = 0.50, g = 0.78, b = 1.0, a = 0.85 },
            size = 14,
        },
        background = {
            primary = { r = 0.03, g = 0.06, b = 0.12, a = 0.94 },
        },

        text = {
            title = { r = 0.75, g = 0.92, b = 1.0 },
            rank = { r = 0.55, g = 0.72, b = 0.88 },
            mana = { r = 0.45, g = 0.65, b = 0.95 },
            range = { r = 0.72, g = 0.82, b = 0.92 },
            castTime = { r = 0.80, g = 0.88, b = 0.95 },
            cooldown = { r = 0.55, g = 0.70, b = 0.85 },
            description = { r = 0.82, g = 0.88, b = 0.95 },
            restriction = { r = 0.85, g = 0.45, b = 0.45 },
            footer = { r = 0.40, g = 0.52, b = 0.62 },
            stats = { r = 0.65, g = 0.80, b = 0.95 },
            base = { r = 0.50, g = 0.85, b = 1.0 },
            gold = { r = 0.72, g = 0.88, b = 1.0 },
            spellPower = { r = 0.65, g = 0.85, b = 1.0 },
            dps = { r = 0.58, g = 0.78, b = 0.95 },
            efficiency = { r = 0.55, g = 0.80, b = 0.90 },
            warning = { r = 0.85, g = 0.60, b = 0.55 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "~",
            instant = "|cff88ddff!|r",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = "*",
        },

        dividers = {
            thin = "|cff66aadd*-*-*-*-*-*-*-*-*-*-*|r",
            thick = "|cff66aadd*=*=*=*=*=*=*=*=*=*=*|r",
            section = "|cff88ccff*- %s -*|r",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = true,
            color = { r = 0.45, g = 0.75, b = 1.0, a = 0.12 }, -- Icy blue chill
            height = 30,
        },

        layout = {
            padding = 14,
            cornerRadius = 6,
            spacing = 4,
        },
    },

    -- ========================================================================
    -- FEL (Sickly green, demonic Burning Legion feel, corrupted edges)
    -- ========================================================================
    ["fel"] = {
        name = "Fel",
        description = "Corrupted demonic fire from the Legion",

        backdrop = {
            bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
            edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
            tile = true,
            tileSize = 16,
            edgeSize = 18,
            insets = { left = 4, right = 4, top = 4, bottom = 4 },
            bgColor = { r = 0.04, g = 0.06, b = 0.02, a = 0.95 },
            borderColor = { r = 0.40, g = 0.95, b = 0.20, a = 0.90 },
        },

        titleColor  = { r = 0.55, g = 1.0, b = 0.30 },       -- Fel green glow
        bodyColor   = { r = 0.78, g = 0.85, b = 0.72 },       -- Sickly pale
        footerColor = { r = 0.38, g = 0.48, b = 0.32 },       -- Dim corrupted

        border = {
            color = { r = 0.40, g = 0.95, b = 0.20, a = 0.90 },
            size = 18,
        },
        background = {
            primary = { r = 0.04, g = 0.06, b = 0.02, a = 0.95 },
        },

        text = {
            title = { r = 0.55, g = 1.0, b = 0.30 },
            rank = { r = 0.50, g = 0.80, b = 0.30 },
            mana = { r = 0.40, g = 0.70, b = 0.85 },
            range = { r = 0.68, g = 0.78, b = 0.62 },
            castTime = { r = 0.72, g = 0.85, b = 0.58 },
            cooldown = { r = 0.55, g = 0.72, b = 0.42 },
            description = { r = 0.78, g = 0.85, b = 0.72 },
            restriction = { r = 0.95, g = 0.40, b = 0.30 },
            footer = { r = 0.38, g = 0.48, b = 0.32 },
            stats = { r = 0.60, g = 0.80, b = 0.50 },
            base = { r = 0.45, g = 0.95, b = 0.35 },
            gold = { r = 0.70, g = 0.95, b = 0.35 },
            spellPower = { r = 0.60, g = 0.95, b = 0.30 },
            dps = { r = 0.55, g = 0.85, b = 0.25 },
            efficiency = { r = 0.50, g = 0.80, b = 0.45 },
            warning = { r = 0.95, g = 0.55, b = 0.25 },
        },

        icons = {
            mana = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\mana:12:12|t",
            castTime = "~",
            instant = "|cff44ff22!|r",
            range = "|TInterface\\AddOns\\DynamicTooltips_Retail\\Data\\range:12:12|t",
            cooldown = "x",
        },

        dividers = {
            thin = "|cff44cc22>->->->->->->->->->->-|r",
            thick = "|cff44cc22>=>=>=>=>=>=>=>=>=>=>=|r",
            section = "|cff55ff33>- %s ->|r",
        },

        fonts = {
            titleSize = 12,
            textSize = 12,
            footerSize = 12,
            outline = "OUTLINE",
        },

        gradient = {
            enabled = true,
            color = { r = 0.35, g = 0.95, b = 0.15, a = 0.12 }, -- Fel green corruption
            height = 30,
        },

        layout = {
            padding = 14,
            cornerRadius = 4,
            spacing = 4,
        },
    },
}

-- ============================================================================
-- THEME MANAGEMENT
-- ============================================================================

local currentTheme = "medieval"

function DT.Themes.GetCurrent()
    return DT.Themes.List[currentTheme] or DT.Themes.List["medieval"]
end

function DT.Themes.GetCurrentName()
    return currentTheme
end

function DT.Themes.Set(themeName)
    if DT.Themes.List[themeName] then
        currentTheme = themeName
        if DT.DB then
            DT.DB.currentTheme = themeName
        end
        
        -- Override Blizzard's default tooltip colors so GameTooltip_OnHide
        -- resets to our theme colors instead of the ugly default.
        -- Uses the theme's own backdrop definition for consistency.
        local theme = DT.Themes.List[themeName]
        local bd = theme.backdrop
        if bd then
            TOOLTIP_DEFAULT_COLOR = CreateColor(
                bd.borderColor.r, bd.borderColor.g, bd.borderColor.b, 1
            )
            TOOLTIP_DEFAULT_BACKGROUND_COLOR = CreateColor(
                bd.bgColor.r, bd.bgColor.g, bd.bgColor.b, 1
            )
        end
        
        -- Trigger theme change event
        if DT.Themes.OnThemeChanged then
            DT.Themes.OnThemeChanged(themeName)
        end
        return true
    end
    return false
end

function DT.Themes.GetList()
    local list = {}
    for name, theme in pairs(DT.Themes.List) do
        table.insert(list, {
            id = name,
            name = theme.name,
            description = theme.description,
        })
    end
    -- Always put Default first, then sort alphabetically
    table.sort(list, function(a, b)
        if a.id == "default" then return true end
        if b.id == "default" then return false end
        return a.name < b.name
    end)
    return list
end

function DT.Themes.GetColor(colorName)
    local theme = DT.Themes.GetCurrent()
    if theme.text and theme.text[colorName] then
        return theme.text[colorName]
    end
    return { r = 1, g = 1, b = 1 }
end

function DT.Themes.GetBackdrop()
    local theme = DT.Themes.GetCurrent()
    return theme.backdrop or DT.Themes.List["medieval"].backdrop
end

function DT.Themes.GetBackground()
    local theme = DT.Themes.GetCurrent()
    return theme.background or DT.Themes.List["medieval"].background
end

function DT.Themes.GetBorder()
    local theme = DT.Themes.GetCurrent()
    return theme.border or DT.Themes.List["medieval"].border
end

function DT.Themes.GetIcon(iconName)
    local theme = DT.Themes.GetCurrent()
    if theme.icons and theme.icons[iconName] then
        return theme.icons[iconName]
    end
    return ""
end

function DT.Themes.GetIcons()
    local theme = DT.Themes.GetCurrent()
    return theme.icons or DT.Themes.List["medieval"].icons
end

function DT.Themes.GetFonts()
    local theme = DT.Themes.GetCurrent()
    return theme.fonts or DT.Themes.List["medieval"].fonts
end

function DT.Themes.GetLayout()
    local theme = DT.Themes.GetCurrent()
    return theme.layout or DT.Themes.List["medieval"].layout
end

function DT.Themes.GetGradient()
    local theme = DT.Themes.GetCurrent()
    return theme.gradient or { enabled = false }
end

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

local function InitializeTheme()
    if DT.DB and DT.DB.currentTheme then
        currentTheme = DT.DB.currentTheme
    end
end

local initFrame = CreateFrame("Frame")
initFrame:RegisterEvent("ADDON_LOADED")
initFrame:SetScript("OnEvent", function(self, event, addonName)
    if addonName == "DynamicTooltips" then
        InitializeTheme()
        self:UnregisterEvent("ADDON_LOADED")
    end
end)
