-- ============================================================================
-- AIOS CopyBox - Configuration Variables
-- ============================================================================
AIOS_CopyBox_Config = {
    -- Version and Compatibility
    version = {
        warWithinBuild = 100000, 
        currentBuild = select(4, GetBuildInfo()),
        isRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE,
        isClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC,
        isBCC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC,
        isWotLK = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC,
        isWarWithinOrHigher = function(self)
            return self.isRetail and self.currentBuild >= self.warWithinBuild
        end
    },
    
    -- Frame Configuration
    frame = {
        width = 600,
        originalHeight = 500,
        expandedHeight = 750,
        position = "CENTER",
        strata = "DIALOG",
        movable = true
    },
    
    -- Roomier layout used by current Retail clients.
    frame_warwithin = {
        width = 650,
        originalHeight = 550,
        expandedHeight = 800,
        position = "CENTER",
        strata = "DIALOG", 
        movable = true,
        buttonSpacing = 10
    },
    
    -- Chat Configuration  
    chat = {
        maxLines = 250,
        updateInterval = 2,
        maxProcessedMessages = 1000,
        maxChatFrames = 10,
        autoScroll = true,
        scrollThreshold = 10
    },
    
    -- UI Element Sizes
    ui = {
        buttonSize = 24,
        logoSize = 32,
        dividerHeight = 3,
        textInsets = {left = 5, right = 5, top = 5, bottom = 5},
        
        -- Positions and Offsets
        headerOffset = -10,
        dividerTopOffset = -46,
        scrollFrameTopOffset = -54,
        scrollFrameBottomOffset = 45,
        footerDividerOffset = 45,
        buttonAreaOffset = 25,
        bottomDividerOffset = 20,
        footerTextOffset = 10
    },
    
    -- Current Retail spacing and offsets.
    ui_warwithin = {
        buttonSize = 24,
        logoSize = 32,
        dividerHeight = 3,
        textInsets = {left = 5, right = 5, top = 5, bottom = 5},
        
        -- Positions and Offsets
        headerOffset = -15,
        dividerTopOffset = -52,
        scrollFrameTopOffset = -60,
        scrollFrameBottomOffset = 50,
        footerDividerOffset = 45,
        buttonAreaOffset = 30,
        bottomDividerOffset = 22,
        footerTextOffset = 10,
        buttonSpacing = 15
    },
    
    -- Colors
    colors = {
        -- Text Colors
        title = "|cff66ccff",
        normalText = "|cffffffff", 
        channelText = "|cff66ccff",
        hoverText = "|cff00ff00",
        
        -- UI Colors
        divider = {r = 0.4, g = 0.6, b = 0.8, a = 0.8},
        background = {r = 0.1, g = 0.1, b = 0.2, a = 0.9},
        
        -- Button States
        buttonNormal = {r = 1, g = 1, b = 1, a = 1},
        buttonHover = {r = 0, g = 1, b = 0, a = 1},
        buttonCloseHover = {r = 1, g = 0, b = 0, a = 1}
    },
    
    -- Texture Paths
    textures = {
        logo = {
            "Interface\\AddOns\\AIOS_CopyBox\\Assets\\AIOS_Logo.tga",
            "Interface\\AddOns\\AIOS_CopyBox\\Textures\\AIOS_Logo.tga",
            "Interface\\AddOns\\AIOS_CopyBox\\AIOS_Logo.tga",
            "Interface\\AddOns\\AIOS_CopyBox\\Textures\\AIOS_Logo.blp",
            "Interface\\AddOns\\AIOS_CopyBox\\AIOS_Logo.blp",
            "Interface\\Icons\\INV_Misc_Note_01"
        },
        -- Advanced textures available on modern Retail clients.
        advanced = {
            bluebg = "Interface\\AddOns\\AIOS_CopyBox\\Assets\\bluebg.png",
            darkgreybg = "Interface\\AddOns\\AIOS_CopyBox\\Assets\\darkgreybg.blp", 
            greenbg = "Interface\\AddOns\\AIOS_CopyBox\\Assets\\greenbg.png",
            mainui = "Interface\\AddOns\\AIOS_CopyBox\\Assets\\Mainui.blp",
            smokybg = "Interface\\AddOns\\AIOS_CopyBox\\Assets\\smokybg.png"
        },
        gloss = "Interface\\AddOns\\AIOS_CopyBox\\Textures\\Gloss",
        fallback = {
            logo = "Interface\\Icons\\INV_Misc_Note_01",
            gloss = "Interface\\Buttons\\WHITE8x8",
            background = "Interface\\Tooltips\\UI-Tooltip-Background",
            border = "Interface\\DialogFrame\\UI-DialogBox-Border"
        }
    },
    
    -- Behavior Settings
    behavior = {
        enableChatButtons = true,
        enableLiveUpdates = true,
        enableTooltips = true,
        enableHyperlinks = true,
        showChatFrameNumbers = true,
        debugMode = false,
        forceAdvancedThemes = false -- For testing
    },
    
    -- Tooltip Content
    tooltips = {
        channelSelector = {
            title = "Channel Selector",
            leftClick = "Left-click: Next channel",
            rightClick = "Right-click: Previous channel"
        },
        themeSelector = {
            title = "Theme Selector",
            leftClick = "Left-click: Next theme", 
            rightClick = "Right-click: Previous theme"
        },
        copyBox = {
            title = "CopyBox",
            description = "Click to open/close CopyBox"
        },
        openClose = {
            open = "Expand frame height",
            close = "Collapse frame height" 
        }
    },
    
    -- Default Messages
    messages = {
        noMessages = "-- No recent messages in %s --",
        noValidChatFrame = "No valid chat frame found",
        channelNotFound = "Invalid channel ID: %s",
        welcome = "AIOS CopyBox v%s loaded - /copybox or /cb to open",
        opened = "CopyBox opened",
        closed = "CopyBox closed",
        expanded = "Frame expanded",
        collapsed = "Frame collapsed"
    }
}

-- Helper function to check if advanced themes are available
function AIOS_CopyBox_Config:HasAdvancedThemes()
    return self.behavior.forceAdvancedThemes or self.version:isWarWithinOrHigher()
end

-- Helper function to get appropriate frame config
function AIOS_CopyBox_Config:GetFrameConfig()
    if self:HasAdvancedThemes() then
        return self.frame_warwithin
    else
        return self.frame
    end
end

-- Helper function to get appropriate UI config  
function AIOS_CopyBox_Config:GetUIConfig()
    if self:HasAdvancedThemes() then
        return self.ui_warwithin
    else
        return self.ui
    end
end
