local addonName, privateDB = ...
local HDG = _G.HousingDecorGuide

-- ============================================================================
-- CONFIGURATION MODULE
-- Constants, Settings Validation, Logging
-- ============================================================================

-- Addon version (dynamically read from .toc file - single source of truth)
local ADDON_VERSION = C_AddOns.GetAddOnMetadata(addonName, "Version") or "Unknown"
privateDB.ADDON_VERSION = ADDON_VERSION

-- Database version - increment this to force shopping list clear on update
local DB_VERSION = 4 -- v2.0.2: Force refresh for crafting history field name changes

-- Configuration Constants
local CONFIG = {
    -- UI Sizes (OPTIMIZED for v1.0.8 - with tabs and proper spacing)
    MAIN_FRAME_WIDTH = 870,
    MAIN_FRAME_HEIGHT = 704, -- banner(34) + tabs(32) + gap(8) + panels(612) + footer(18)
    TAB_HEIGHT = 32,
    BANNER_HEIGHT = 34, -- 12:1 aspect ratio banner (408x34)
    ICON_SIZE = 32,  -- Standard icon size for buttons and tabs

    -- Panel widths (3-panel layout maintained)
    -- With 4px padding on each side and 8px gaps: 870 - 8 - 16 = 846 / 3 = 282
    LEFT_PANEL_WIDTH = 282,
    MIDDLE_PANEL_WIDTH = 282,
    RIGHT_PANEL_WIDTH = 282,

    PANEL_HEIGHT = 612, -- banner(34) + tabs(32) + gap(8) + panels + footer(18) = 704

    -- Recipe elements
    RECIPE_BUTTON_WIDTH = 238, -- Reduced to avoid scrollbar (was 250)
    RECIPE_BUTTON_HEIGHT = 30, -- was 35 (tighter)
    PROFESSION_HEADER_HEIGHT = 24,

    -- Shopping elements
    SHOPPING_ITEM_HEIGHT = 24, -- Match MATERIAL_ITEM_HEIGHT for visual consistency
    SHOPPING_ITEM_WIDTH = 240, -- Fits "Valdrakken Hanging Cauldron" in 270px panel

    -- Materials elements
    MATERIAL_ITEM_HEIGHT = 24, -- was 30 (tighter)
    MATERIAL_ITEM_WIDTH = 250, -- Reduced for compact 280px panel

    -- Lumber sections
    LUMBER_WIDGET_HEIGHT = 120, -- Bottom of recipe panel (reduced from 140)
    LUMBER_ITEM_HEIGHT = 20,    -- Individual lumber items (reduced from 22)

    -- Lumber Column Widths (New for alignment)
    LUMBER_COL_1 = 90, -- Type
    LUMBER_COL_2 = 76, -- Needed
    LUMBER_COL_3 = 76, -- In Stock

    -- Base Color Palette (single source of truth for RGB values)
    -- Alpha values are applied in COLORS below
    PALETTE = {
        SLATE_DARK = { 0.12, 0.12, 0.14 },       -- Main backgrounds (#1E1E24)
        SLATE_MED = { 0.15, 0.15, 0.16 },        -- Panels, headers (#252526)
        SLATE_HOVER = { 0.20, 0.20, 0.22 },      -- Hover states
        SLATE_BORDER = { 0.29, 0.33, 0.41 },     -- Borders (#4a5568)
        TEAL_DARK = { 0.11, 0.31, 0.31 },        -- Active states (#1d4e4f)
        TEAL_HOVER = { 0.15, 0.40, 0.40 },       -- Hover active
        TEAL_BORDER = { 0, 0.3, 0.3 },           -- Teal border color
        TEAL_BORDER_BRIGHT = { 0, 0.5, 0.5 },    -- Bright teal for active
        TEAL_ACCENT = { 0.08, 0.72, 0.65 },      -- Primary teal accent (#14b8a6)
        TEAL_BUTTON = { 0.08, 0.45, 0.42 },      -- Teal button background
        TEAL_PROGRESS = { 0.18, 0.80, 0.44 },    -- Progress bar teal
        TEAL_PROGRESS_FULL = { 0.17, 0.48, 0.48 }, -- Progress bar at 100%
        BLUE_KNOWN = { 0.37, 0.67, 0.86 },       -- Known recipe indicator (#5FABDC)
        GRAY_DARK = { 0.1, 0.1, 0.1 },           -- Dark backgrounds
        GRAY_INACTIVE = { 0.18, 0.22, 0.24 },    -- Inactive states
        GRAY_HOVER = { 0.22, 0.28, 0.30 },       -- Hover on inactive
        TAB_INACTIVE = { 0.10, 0.10, 0.12 },     -- Inactive tab background
    },

    -- Colors (Modern Slate Theme)
    COLORS = {
        -- Recipe colors
        KNOWN_RECIPE = { 0.15, 0.15, 0.16, 0.8 },   -- Dark slate for known
        UNKNOWN_RECIPE = { 0.12, 0.12, 0.14, 0.0 }, -- Transparent/Main BG

        -- Header colors
        HEADER_NORMAL = { 0.15, 0.15, 0.16, 1.0 },
        HEADER_HOVER = { 0.20, 0.20, 0.22, 1.0 },
        HEADER_TEXT = { 0.89, 0.91, 0.94, 1.0 }, -- Cool White/Light Grey (#e2e8f0) for accessibility

        -- Text colors
        KNOWN_TEXT = { 0.37, 0.67, 0.86, 1.0 }, -- Soft Blue (#5FABDC)
        UNKNOWN_TEXT = { 0.8, 0.8, 0.8, 1.0 },  -- Light Grey

        -- Main frame background
        MAIN_BG = { 0.12, 0.12, 0.14, 0.98 },    -- Dark Slate (#1E1E24)
        MAIN_BORDER = { 0.29, 0.33, 0.41, 1.0 }, -- Lighter Slate Border (#4a5568)

        -- Panel colors
        PANEL_BG = { 0.15, 0.15, 0.16, 0.6 },     -- Lighter Slate (#252526)
        PANEL_BORDER = { 0.29, 0.33, 0.41, 0.6 }, -- Lighter Slate Border (#4a5568)
        SECTION_BG = { 0.12, 0.12, 0.14, 0.8 },   -- Darker section

        -- Item backgrounds
        ITEM_KNOWN_BG = { 0.37, 0.67, 0.86, 0.2 }, -- Translucent Blue
        ITEM_KNOWN_HOVER = { 0.37, 0.67, 0.86, 0.4 },
        ITEM_UNKNOWN_BG = { 0.0, 0.0, 0.0, 0.2 },
        ITEM_UNKNOWN_HOVER = { 0.25, 0.25, 0.27, 0.4 },
        ITEM_SELECTED_BG = { 0.37, 0.67, 0.86, 0.3 },

        -- Sticky header
        STICKY_HEADER_BG = { 0.15, 0.15, 0.16, 1.0 },

        -- Lumber section
        LUMBER_BG = { 0.12, 0.12, 0.14, 0.8 },
        LUMBER_BORDER = { 0.29, 0.33, 0.41, 0.8 }, -- Lighter Slate (#4a5568)
        LUMBER_HOVER = { 0.20, 0.20, 0.22, 0.6 },

        -- Border
        BORDER = { 0.29, 0.33, 0.41, 1 }, -- Lighter Slate (#4a5568)

        -- Tab colors
        TAB_ACTIVE = { 0.15, 0.15, 0.16, 1.0 },
        TAB_INACTIVE = { 0.10, 0.10, 0.12, 0.9 },
        TAB_HOVER = { 0.20, 0.20, 0.22, 0.9 },
        TAB_TEXT_ACTIVE = { 0.9, 0.9, 0.9 },   -- White
        TAB_TEXT_INACTIVE = { 0.6, 0.6, 0.6 }, -- Grey

        -- Progress bar colors
        PROGRESS_COMPLETE = { 0.2, 0.7, 0.3, 0.7 },   -- Muted Green
        PROGRESS_INCOMPLETE = { 0.8, 0.3, 0.3, 0.7 }, -- Muted Red
        PROGRESS_BG = { 0.10, 0.10, 0.12, 0.7 },

        -- Material colors
        MATERIAL_HAVE_BG = { 0.10, 0.10, 0.12, 0.5 },
        MATERIAL_HAVE_HOVER = { 0.20, 0.20, 0.22, 0.6 },
        MATERIAL_HAVE_TEXT = { 1.0, 1.0, 1.0 }, -- White Text (was green)
        MATERIAL_NEED_BG = { 0.10, 0.10, 0.12, 0.5 },
        MATERIAL_NEED_HOVER = { 0.20, 0.20, 0.22, 0.6 },
        MATERIAL_NEED_TEXT = { 1.0, 1.0, 1.0 }, -- White Text
    },

    -- Spacing (TIGHTER)
    SPACING = {
        PANEL_PADDING = 4,  -- was 8, tightened for more compact layout
        PANEL_GAP = 8,      -- Between panels
        PROFESSION_GAP = 6, -- was 10
        RECIPE_GAP = 2,     -- was 5 (very tight)
        HEADER_HEIGHT = 26,
        RECIPE_HEIGHT = 32, -- was 40
        SECTION_GAP = 8,
        ITEM_PADDING = 4,   -- Internal item padding
    },

    -- Textures (WoW UI)
    TEXTURES = {
        CHECKMARK = "Interface\\RAIDFRAME\\ReadyCheck-Ready",
        XMARK = "Interface\\RAIDFRAME\\ReadyCheck-NotReady",
        WHITE_BG = "Interface\\Buttons\\WHITE8x8",
        TOOLTIP_BORDER = "Interface\\Tooltips\\UI-Tooltip-Border",
        STATUSBAR = "Interface\\Buttons\\WHITE8x8", -- Flatter texture
    },

    -- Custom Addon Textures (in textures/ folder)
    -- This is the canonical list of textures used by the addon
    ADDON_TEXTURES = {
        -- Main icon
        MINIMAP_ICON = "Interface\\AddOns\\HousingDecorGuide\\textures\\HousingDecorIcon",
        -- Tab buttons (full button style)
        TAB_RECIPES = "Interface\\AddOns\\HousingDecorGuide\\textures\\recipebutton",
        TAB_GOBLIN = "Interface\\AddOns\\HousingDecorGuide\\textures\\goblinbutton",
        TAB_PREVIEW = "Interface\\AddOns\\HousingDecorGuide\\textures\\previewbutton",
        TAB_TRAINERS = "Interface\\AddOns\\HousingDecorGuide\\textures\\trainerbutton",
        TAB_ALTS = "Interface\\AddOns\\HousingDecorGuide\\textures\\altsbutton",
        TAB_DATA = "Interface\\AddOns\\HousingDecorGuide\\textures\\databutton",
        TAB_CONFIG = "Interface\\AddOns\\HousingDecorGuide\\textures\\configbutton",
        -- UI buttons
        CLOSE = "Interface\\AddOns\\HousingDecorGuide\\textures\\close",
        REFRESH = "Interface\\AddOns\\HousingDecorGuide\\textures\\refresh",
        HELP = "Interface\\AddOns\\HousingDecorGuide\\textures\\helpbutton",
        PIN = "Interface\\AddOns\\HousingDecorGuide\\textures\\strongpin",
        CSV_EXPORT = "Interface\\AddOns\\HousingDecorGuide\\textures\\csvexportbutton",
        -- Icons
        READY_TO_CRAFT = "Interface\\AddOns\\HousingDecorGuide\\textures\\readytocraft",
        SORT_ARROW = "Interface\\AddOns\\HousingDecorGuide\\textures\\sort-arrow",
        DISCORD = "Interface\\AddOns\\HousingDecorGuide\\textures\\discord",
        TITLE_BANNER = "Interface\\AddOns\\HousingDecorGuide\\textures\\hdg_banner",
        PINNED_ICON = "Interface\\AddOns\\HousingDecorGuide\\textures\\hdg_icon",
        TRACKER_TITLE = "Interface\\AddOns\\HousingDecorGuide\\textures\\tracker_title",
    },

    -- Progress bars
    PROGRESS_BAR = {
        WIDTH = 70, -- Narrower to prevent overlap
        HEIGHT = 11,
        SHOW_BARS = true,
        CHAR_FILLED = "|",
        CHAR_EMPTY = ".",
        BLOCKS = 10,
    },

    -- Positioning constants (NEW - Phase 1)
    POSITIONING = {
        PROGRESS_BAR_MATERIALS_X = -125,
        PROGRESS_BAR_LUMBER_LEFT_X = -80,
        PROGRESS_BAR_LUMBER_RIGHT_X = -120,
        TITLE_BAR_Y = -12,
        RECIPE_ICON_LEFT = 18,
        RECIPE_TEXT_LEFT = 6,
        MATERIAL_NAME_LEFT = 6,
        MATERIAL_NAME_WIDTH = 140,
    },

    -- Font sizes
    FONTS = {
        TITLE = 14,
        HEADER = 12,
        NORMAL = 11, -- was 12 (slightly smaller)
        SMALL = 10,
    },

    -- Text color codes (v1.9.5 - centralized)
    TEXT_COLORS = {
        -- Primary colors
        TITLE = "|cFFe2e8f0",      -- Cool white for titles (#e2e8f0)
        ACCENT = "|cFF14b8a6",     -- Teal accent (#14b8a6)
        GOLD = "|cFFfcd34d",       -- Gold/yellow for highlights (#fcd34d)
        WHITE = "|cFFFFFFFF",      -- Pure white

        -- Status colors
        SUCCESS = "|cFF00FF00",    -- Green for success/positive
        ERROR = "|cFFFF0000",      -- Red for errors
        WARNING = "|cFFFFAA00",    -- Orange for warnings

        -- Muted colors
        MUTED = "|cFF888888",      -- Gray for secondary text
        DARK_MUTED = "|cFF666666", -- Darker gray
        LIGHT_MUTED = "|cFF999999", -- Lighter gray
        SUBTLE = "|cFFAAAAAA",     -- Very light gray

        -- Special colors
        KNOWN = "|cFF88FF88",      -- Light green for "have/known"
        NEED = "|cFFFF5555",       -- Light red for "need"
        LINK = "|cFFAAAAFF",       -- Light blue for clickable/links

        -- Reset
        RESET = "|r",
    },

    -- Padding constants (v1.9.5 - centralized magic numbers)
    PADDING = {
        TIGHT = 4,
        STANDARD = 8,
        LOOSE = 12,
        COLUMN_GAP = 2,
        TITLE_OFFSET = -12,
        SECTION_GAP = 6,
    },

    -- Common sizes (v1.9.5 - centralized magic numbers)
    SIZES = {
        ROW_HEIGHT = 18,
        BUTTON_HEIGHT = 22,
        ICON_SMALL = 16,
        ICON_MEDIUM = 24,
        ICON_LARGE = 32,
    },

    -- ============================================================================
    -- PREVIEW TAB CONSTANTS (Phase 3 refactor)
    -- ============================================================================
    PREVIEW_TAB = {
        CACHE_TTL = 300,              -- 5 minutes cache for decor list
        SEARCH_BOX_WIDTH = 140,
        SEARCH_BOX_HEIGHT = 18,
        TOGGLE_CONTAINER_WIDTH = 80,
        TOGGLE_CONTAINER_HEIGHT = 34,
        TOGGLE_BUTTON_HEIGHT = 16,
        MODEL_PANEL_HEIGHT = 410,
        ITEM_ROW_HEIGHT = 24,
        ITEM_ROW_SPACING = 26,        -- Row height + gap
        LIST_PANEL_WIDTH = 260,
        LIST_CONTENT_WIDTH = 230,
        FILTER_ROW_HEIGHT = 20,
        TAG_ROW_HEIGHT = 18,
        TAG_BUTTON_MAX_WIDTH = 70,
        CATEGORY_BUTTON_MAX_WIDTH = 80,
        FILTER_LABEL_OFFSET = 38,     -- Offset after "Filter:" label
        MAX_FILTER_WIDTH = 780,       -- Max width for filter buttons row
        -- Zoom settings
        ZOOM_SPEED = 0.1,
        ZOOM_MIN = 0.3,
        ZOOM_MAX = 3.0,
        MODEL_SCALE_MIN = 0.1,
        MODEL_SCALE_MAX = 5.0,
        -- Icon sizes
        STATUS_ICON_SIZE = 12,
        ITEM_ICON_SIZE = 20,
    },

    -- ============================================================================
    -- TRAINERS TAB CONSTANTS (Phase 3 refactor)
    -- ============================================================================
    TRAINERS_TAB = {
        -- Column widths
        FACTION_COL = 46,
        NAME_COL = 160,
        ZONE_COL = 140,
        COORDS_COL = 70,
        -- Row dimensions
        ROW_HEIGHT = 22,
        ENTRY_PADDING = 24,
        EXPANSION_INDENT = 12,
        EXPANSION_HEIGHT = 20,
        HEADER_HEIGHT = 28,
        ACCENT_BAR_WIDTH = 3,
        ACCENT_BAR_HEIGHT = 16,
        -- Faction indicator
        FACTION_BOX_WIDTH = 20,
        FACTION_BOX_HEIGHT = 16,
        -- Buttons
        WAYPOINT_BTN_SIZE = 16,
    },

    -- ============================================================================
    -- UI CONSTANTS (Phase 3 refactor)
    -- ============================================================================
    UI = {
        COMPACT_BTN_SIZE = 24,
        CLOSE_BTN_OFFSET = -5,
        TAB_HEIGHT = 32,
        HEADER_BG_HEIGHT = 22,
        DISCORD_BTN_WIDTH = 80,
        DISCORD_BTN_HEIGHT = 20,
    },

    -- ============================================================================
    -- TOOLTIP SETTINGS
    -- ============================================================================
    TOOLTIP = {
        DEFAULT_ANCHOR = "ANCHOR_TOPRIGHT",  -- Tooltip above-right of cursor (cursor at bottom-left)
    },
}

-- Store config in privateDB
privateDB.CONFIG = CONFIG

-- Logging System
local LOG_LEVEL = {
    DEBUG = 1,
    INFO = 2,
    WARN = 3,
    ERROR = 4,
}

local currentLogLevel = LOG_LEVEL.WARN -- Production version

local function Log(level, message, ...)
    if level >= currentLogLevel then
        local prefix = {
            [LOG_LEVEL.DEBUG] = "|cFF888888[HDG-DEBUG]|r",
            [LOG_LEVEL.INFO] = "|cFF00FF00[HDG-INFO]|r",
            [LOG_LEVEL.WARN] = "|cFFFFFF00[HDG-WARN]|r",
            [LOG_LEVEL.ERROR] = "|cFFFF0000[HDG-ERROR]|r",
        }
        print(prefix[level], string.format(message, ...))
    end
end

-- Export Log to privateDB
privateDB.Log = Log
privateDB.LOG_LEVEL = LOG_LEVEL

-- Settings Validation
function privateDB.ValidateSettings()
    -- Ensure HDG_Settings exists
    _G.HDG_Settings = _G.HDG_Settings or {}
    local settings = _G.HDG_Settings

    local defaults = {
        shoppingList = {},
        scale = 1.0,
        minimapButton = { hide = false },
        professionFilter = "All", -- Default to showing all professions
        collapsedMaterials = {},  -- Track collapsed material categories
        trainersCollapsed = {},   -- Track collapsed professions in Trainers tab
        framePosition = nil,      -- Will be set dynamically
        dbVersion = 0,            -- Track database version for migration
        craftingHistory = {},     -- v1.9.5: Track crafted decor items
        craftableFilter = false,  -- v1.9.5: "What Can I Craft?" filter mode
        -- v2.0: Multi-character profession tracking
        characters = {},          -- { ["CharName-RealmName"] = { professions = {...}, lastUpdated = timestamp } }
        -- v2.0.1: Lumber tracker pinned state
        lumberPinned = false,     -- Whether pinned lumber window is open
        -- v2.0.2: Independent pinned lumber widget
        pinnedLumberPosition = nil,   -- Position of independent pinned lumber frame
        showLumberMaterials = false,  -- Show all materials (not just lumber) in pinned widget
        -- v2.0.3: UI settings
        showProfessionButtons = true, -- Show quick-access buttons on profession window
        -- v2.0.8: Power Crafting
        showRawMaterials = false,     -- Show expanded raw materials instead of direct reagents
        -- v2.1.1: Price addon preference
        preferredPriceAddon = nil,    -- nil = auto (TSM first), "TSM", or "Auctionator"
        lumberFocusMode = true,       -- Focus mode: only show farmed lumber when farming starts
        lumberAutoShow = true,        -- Auto-show pinned lumber tracker when lumber collected
        quotesEnabled = true,         -- Master toggle for all quotes (lumber, craft, etc.)
        vamooseChattiness = 30,       -- Vamoose quote frequency (0=off, 1-99=lumber collected between quotes)
        vamooseChatOutput = false,    -- Also output Vamoose quotes to chat window
        trackedReagents = {},         -- Gathering Tracker: {[itemID] = {name, targetQty, addedTime}}
        lumberQuotesEnabled = true,   -- Show lumber quotes (Vamoose, Squirrel, Gazlowe) while farming
        craftQuotesEnabled = true,    -- Show profession-specific quotes when crafting/acquiring decor items
        quotesOnlyChat = false,       -- Only print quotes to chat (no talking head display)
        closeProfWindowAfterCraft = true, -- Close profession window after crafting completes
        -- v2.2.0: Lumber Compass HUD
        lumberHUDEnabled = true,      -- Enable lumber compass HUD (auto-show when farming)
        lumberHUDPosition = nil,      -- Saved position {point, relativePoint, x, y}
        lumberHUDVisible = false,     -- Current visibility state
    }

    -- Ensure all required keys exist
    for key, defaultValue in pairs(defaults) do
        if settings[key] == nil then
            settings[key] = defaultValue
            Log(LOG_LEVEL.INFO, "Initialized missing setting: %s", key)
        end
    end

    -- v2.0.7: Remove deprecated settings from legacy users
    -- These settings are no longer used but may exist in SavedVariables
    local deprecatedSettings = { "compactMode", "compactPosition", "collapsedProfessions" }
    for _, key in ipairs(deprecatedSettings) do
        if settings[key] ~= nil then
            settings[key] = nil
            Log(LOG_LEVEL.INFO, "Removed deprecated setting: %s", key)
        end
    end

    -- Check for database version change - migrate shopping list if outdated
    if settings.dbVersion ~= DB_VERSION then
        Log(LOG_LEVEL.INFO, "Database version changed from %d to %d - migrating shopping list",
            settings.dbVersion or 0, DB_VERSION)

        -- Migrate shopping list items to use correct IDs from new database
        if HDG_DecorDB and settings.shoppingList then
            local migratedList = {}
            local migratedCount = 0

            for _, item in ipairs(settings.shoppingList) do
                local found = false
                -- Find matching recipe by name in the new database
                for dbKey, recipe in pairs(HDG_DecorDB) do
                    if recipe.name and item.name and recipe.name == item.name then
                        -- Convert reagents from database format to addon format
                        local convertedReagents = {}
                        if recipe.reagents then
                            for reagentID, reagentData in pairs(recipe.reagents) do
                                -- Look up source from HDG_ReagentsDB table
                                local source = (HDG_ReagentsDB and HDG_ReagentsDB[reagentID]) or "Unknown"
                                table.insert(convertedReagents, {
                                    id = reagentID,
                                    amount = reagentData.qty,
                                    source = source
                                })
                            end
                        end

                        -- Update item with correct data from new database
                        table.insert(migratedList, {
                            id = recipe.itemID,
                            name = recipe.name,
                            spell = recipe.spellID,
                            reagents = convertedReagents,
                            expansion = item.expansion,
                            quantity = item.quantity or 1
                        })
                        migratedCount = migratedCount + 1
                        found = true
                        break
                    end
                end

                if not found and item.id and item.quantity then
                    -- Keep item as-is if we can't migrate it
                    table.insert(migratedList, item)
                end
            end

            settings.shoppingList = migratedList
            if migratedCount > 0 then
                print(string.format(
                    "|cFF00FF00[Housing Decor Guide]|r Database updated! Migrated %d shopping list items.", migratedCount))
            end
        end

        settings.dbVersion = DB_VERSION
    end

    -- Validate shopping list structure
    if type(settings.shoppingList) ~= "table" then
        Log(LOG_LEVEL.WARN, "Invalid shoppingList, resetting to empty")
        settings.shoppingList = {}
    end

    -- Clean invalid shopping list entries
    local validList = {}
    for i, item in ipairs(settings.shoppingList) do
        if type(item) == "table" and item.id and item.quantity then
            if item.quantity > 0 then
                table.insert(validList, item)
            else
                Log(LOG_LEVEL.WARN, "Removed item with invalid quantity: %s", tostring(item.id))
            end
        else
            Log(LOG_LEVEL.WARN, "Removed malformed shopping list item at index %d", i)
        end
    end
    settings.shoppingList = validList

    -- Validate scale
    if type(settings.scale) ~= "number" or settings.scale < 0.5 or settings.scale > 2.0 then
        Log(LOG_LEVEL.WARN, "Invalid scale value, resetting to 1.0")
        settings.scale = 1.0
    end

    Log(LOG_LEVEL.DEBUG, "Settings validation complete")
end
