-- ============================================================================
-- HDG Localization - enUS (Base)
-- ============================================================================
-- Bootstrap file: creates the L table, defines all English keys, attaches
-- accessor methods, and exports as _G.HDG_L. Override locale files register
-- into _G.HDG_Locales[code] and are applied via L:ApplyOverride().
-- ============================================================================

local addonName, privateDB = ...

-- Override locale registry (populated by HDG_Locale_*.lua files)
_G.HDG_Locales = {}

-- Create the active localization table
local L = {}

-- ============================================================================
-- ENGLISH (Default/Fallback)
-- ============================================================================
--
-- LAYOUT POLICY: Short labels that live in fixed-width contexts (column
-- headers, compact buttons) stay English in ALL locales. Translated strings
-- that are longer than the English can break column alignment and overflow
-- buttons. Only translate strings that have room to grow: panel headers,
-- status messages, tooltips, and full-line text.
--
-- Keys marked "-- ENGLISH ONLY" below must NOT appear in override files.
-- If they do, the English value is used anyway (override files should
-- simply omit them so they fall through to the base).
-- ============================================================================

-- Tab Names
L["TAB_RECIPES"] = "Recipes"
L["TAB_ACQUIRE"] = "Acquire"
L["TAB_GOBLIN"] = "Goblin"
L["TAB_PREVIEW"] = "Preview"
L["TAB_TRAINERS"] = "Trainers"
L["TAB_ALTS"] = "Alts"
L["TAB_STYLES"] = "Style"
L["TAB_DATA"] = "Data"
L["TAB_CONFIG"] = "Config"

-- Panel Headers
L["HEADER_CRAFTING_QUEUE"] = "Crafting Queue"
L["HEADER_SHOPPING_LIST"] = "Shopping List"
L["HEADER_MATERIALS"] = "Materials"
L["HEADER_REQUIRED_MATERIALS"] = "Required Materials"
L["HEADER_RAW_MATERIALS"] = "Raw Materials"
L["HEADER_DIRECT_MATERIALS"] = "Direct Materials"
L["HEADER_LUMBER"] = "Lumber"
L["HEADER_TRACKED_REAGENTS"] = "Tracked Reagents"
L["HEADER_CRAFTING_HISTORY"] = "Decor Crafting / Acquisition History"
L["HEADER_FARMING_HISTORY"] = "Farming History"
L["HEADER_ACCOUNT_SUMMARY"] = "Account Summary"
L["HEADER_PROFIT_ANALYSIS"] = "Profit Analysis"

-- Column Headers -- ENGLISH ONLY (fixed-width table cells)
L["COL_TYPE"] = "Type"
L["COL_NEEDED"] = "Needed"
L["COL_IN_STOCK"] = "In Stock"
L["COL_ALL"] = "All"
L["COL_TIME"] = "Time"
L["COL_ITEM"] = "Item"
L["COL_COST"] = "Cost"
L["COL_SOURCE"] = "Source"
L["COL_CHARACTER"] = "Character"
L["COL_COLLECTED"] = "Collected"
L["COL_RATE"] = "Rate"
L["COL_DURATION"] = "Duration"
L["COL_ZONE"] = "Zone"
L["COL_SELL_PRICE"] = "Sell"
L["COL_MAT_COST"] = "Mat Cost"
L["COL_PROFIT"] = "Profit"
L["COL_MARGIN"] = "Margin"
L["COL_LUMBER_VALUE"] = "$/Lum"
L["COL_TOTAL_LUMBER"] = "Lum Total"
L["COL_SALE_RATE"] = "Sale Rate"
L["COL_MARKET_VALUE"] = "Market"
L["COL_AH_QTY"] = "# AH"

-- Buttons -- short labels ENGLISH ONLY; longer labels safe to translate
L["BTN_CLEAR"] = "Clear"       -- ENGLISH ONLY
L["BTN_CLOSE"] = "Close"       -- ENGLISH ONLY
L["BTN_EXPORT"] = "Export"     -- ENGLISH ONLY
L["BTN_REFRESH"] = "Refresh"   -- ENGLISH ONLY
L["BTN_ALL"] = "All"           -- ENGLISH ONLY
L["BTN_READY"] = "Ready"       -- ENGLISH ONLY
L["BTN_DIRECT"] = "Direct"     -- ENGLISH ONLY
L["BTN_RAW"] = "Raw"           -- ENGLISH ONLY
L["BTN_FILTER_DECOR"] = "Filter Decor"
L["BTN_DECOR_GUIDE"] = "Decor Guide"
L["BTN_END_SESSION"] = "End Session"
L["BTN_STOP_TRACKING"] = "Stop Tracking"
L["BTN_SCAN_AH"] = "Scan AH"
L["BTN_ADD_TO_AUCTIONATOR"] = "Add to Auctionator"
L["BTN_ADD_ALL_AUCTIONATOR"] = "Add All to Auctionator"
L["BTN_ADD_ALL_AUCTIONATOR_RAW"] = "Add All to Auctionator (Raw Mats)"
L["BTN_ADD_TO_TSM"] = "Add to TSM Shopping"
L["BTN_MY_COLLECTION"] = "My Collection"

-- Checkboxes / Toggles
L["CHECK_UNCOLLECTED_ONLY"] = "Uncollected"
L["CHECK_INCLUDE_MATS"] = "+Mats"  -- ENGLISH ONLY
L["CHECK_HIDE_UNPROFITABLE"] = "Hide Unprofitable"
L["CHECK_ONLY_KNOWN"] = "My Recipes"
L["CHECK_KNOWN_BY_ALTS"] = "All Known Recipes"
L["CHECK_SHOW_PROFESSION_BUTTONS"] = "Show Profession Window Buttons"
L["CHECK_SHOW_MINIMAP_BUTTON"] = "Show Minimap Button"
L["CHECK_SHOW_IN_COMPARTMENT"] = "Show in Addon Compartment"
L["HINT_MINIMAP_BUTTON"] = "(Draggable icon around the minimap)"
L["HINT_COMPARTMENT"] = "(Minimap drawer menu - requires /reload)"
L["HINT_COMPARTMENT_UNAVAILABLE"] = "(Not available - requires WoW 10.0+)"

-- Locale Override
L["LOCALE_OVERRIDE"] = "Language Override"
L["LOCALE_AUTO"] = "Auto (Client)"
L["LOCALE_HINT"] = "Requires /reload to apply"
L["LOCALE_NOTE"] = "Note: Only affects addon UI text. Recipe and item names match your client's locale."
L["TRANSLATE_NOTE"] = "Help translate! Submit corrections via Discord below."

-- Filter Labels
L["FILTER_PROFESSION"] = "Profession"
L["FILTER_EXPANSION"] = "Expansion"
L["FILTER_ALL_PROFESSIONS"] = "All Professions"
L["FILTER_ALL_EXPANSIONS"] = "All Expansions"
L["FILTER_TAGS"] = "Tags"
L["FILTER_CATEGORY"] = "Filter"

-- Preview Tab Categories
L["CAT_ALL"] = "All"
L["CAT_CRAFTED"] = "Crafted"
L["CAT_SIZES"] = "Sizes"
L["CAT_FACTIONS"] = "Factions"
L["CAT_STYLES"] = "Styles"
L["CAT_EXPANSIONS"] = "Expansions"
L["CAT_OTHER"] = "Other"

-- Status Messages
L["STATUS_LOADING"] = "Loading..."
L["STATUS_NO_DATA"] = "No data available"
L["STATUS_NO_RECIPES"] = "No recipes found"
L["STATUS_NO_HISTORY"] = "No crafting/acquisition history yet."
L["STATUS_NO_FARMING_HISTORY"] = "No farming sessions recorded yet."
L["STATUS_NO_CHARACTER_DATA"] = "No character data yet. Open a profession window to scan skill levels."
L["STATUS_ALL_LUMBER_COLLECTED"] = "All lumber collected!"
L["STATUS_NO_MATERIALS_QUEUED"] = "No materials in crafting queue"
L["STATUS_HAVE_ALL_MATERIALS"] = "Have all materials!"
L["STATUS_INSTALL_PRICE_ADDON"] = "Install TSM/Auctionator for prices"

-- Tab Tooltip Descriptions
L["TIP_TAB_RECIPES"] = "View all housing decor recipes"
L["TIP_TAB_ACQUIRE"] = "Vendor shopping guide - find where to buy decorations"
L["TIP_TAB_GOBLIN"] = "Profit analysis - find the most profitable crafts"
L["TIP_TAB_PREVIEW"] = "Preview decorations"
L["TIP_TAB_TRAINERS"] = "Find recipe trainers"
L["TIP_TAB_ALTS"] = "View profession data across all characters"
L["TIP_TAB_DATA"] = "View farming history and statistics"
L["TIP_TAB_CONFIG"] = "Configure addon settings and minimap icon"

-- Tooltips
L["TIP_CLICK_TO_PREVIEW"] = "Click to preview"
L["TIP_CLICK_HEADERS_TO_SORT"] = "Click headers to sort"
L["TIP_CTRL_CLICK_ADD_QUEUE"] = "Ctrl-click to add to queue"
L["TIP_SHIFT_CLICK_SEARCH_AH"] = "Shift-click to search AH"
L["TIP_RIGHT_CLICK_OPTIONS"] = "Right-click for options"
L["TIP_DRAG_TO_MOVE"] = "Drag to move"
L["TIP_CLOSE_MAIN_WINDOW"] = "Close Main Window"
L["TIP_OPEN_MAIN_WINDOW"] = "Open Main Window"
L["TIP_SHOW_MATERIALS"] = "Show Materials"
L["TIP_HIDE_MATERIALS"] = "Hide Materials"
L["TIP_MATERIALS_UNAVAILABLE"] = "Materials Unavailable"
L["TIP_END_FARMING_SESSION"] = "End Farming Session"
L["TIP_ENDS_SESSION_TRACKING"] = "Ends the current farming session tracking"
L["TIP_SELECT_ALL_COPY"] = "Select all (Ctrl+A) then copy (Ctrl+C)"

-- Export
L["EXPORT_CRAFTING_TITLE"] = "Export Crafting History"
L["EXPORT_FARMING_TITLE"] = "Export Farming History"

-- Crafting Queue
L["QUEUE_NOT_KNOWN"] = "Not Known"
L["QUEUE_YOU"] = "(you)"
L["QUEUE_NEEDS_TRAINING"] = "Not Learned"
L["QUEUE_KNOWN_BY"] = "Known by"

-- Farming Tracker
L["FARM_SESSION_ENDED"] = "farming session ended"
L["FARM_COLLECTED"] = "collected"
L["FARM_THIS_SESSION"] = "this session"
L["FARM_FIRST_TO_LAST"] = "(first to last)"

-- Materials
L["MAT_GATHERED"] = "Gathered"
L["MAT_CRAFTED"] = "Crafted"
L["MAT_VENDOR"] = "Vendor"
L["MAT_DROPPED"] = "Dropped"
L["MAT_SPECIAL"] = "Special"

-- Material Source Categories
L["MAT_FROM_VENDOR"] = "From Vendor"
L["MAT_FROM_GATHERING"] = "From Gathering / AH"
L["MAT_FROM_CRAFTING"] = "From Crafting / AH"

-- Acquisition Sources
L["SOURCE_CRAFTED"] = "Crafted"
L["SOURCE_LEARNED"] = "Learned"

-- Collection Status
L["STATUS_COLLECTED"] = "Collected"
L["STATUS_COLLECTION"] = "All Decor"
L["STATUS_UNCOLLECTED"] = "Unknown"
L["STATUS_NOT_COLLECTED"] = "Not Collected"
L["TIP_MY_COLLECTION"] = "My Collection"
L["TIP_SHOW_ALL_DECOR"] = "Show ALL housing decor items from the catalog"
L["TIP_NOT_JUST_CRAFTABLE"] = "(not just craftable recipes)."
L["TIP_UNCOLLECTED_ONLY"] = "Uncollected Only"
L["TIP_HIDE_COLLECTED"] = "Hide items you've already collected"

-- Skill Thresholds Legend
L["LEGEND_CAN_LEARN"] = "Can learn decor recipes"
L["LEGEND_BELOW_THRESHOLD"] = "Below threshold"
L["LEGEND_NO_DECOR_RECIPES"] = "No decor recipes"

-- Profession Window
L["PROF_NOT_LEARNED"] = "Not Learned"

-- Profession Names (for filters)
L["PROF_ALL"] = "All"
L["PROF_ALCHEMY"] = "Alchemy"
L["PROF_BLACKSMITHING"] = "Blacksmithing"
L["PROF_COOKING"] = "Cooking"
L["PROF_ENCHANTING"] = "Enchanting"
L["PROF_ENGINEERING"] = "Engineering"
L["PROF_INSCRIPTION"] = "Inscription"
L["PROF_JEWELCRAFTING"] = "Jewelcrafting"
L["PROF_LEATHERWORKING"] = "Leatherworking"
L["PROF_TAILORING"] = "Tailoring"
L["PROF_HERBALISM"] = "Herbalism"
L["PROF_MINING"] = "Mining"
L["PROF_SKINNING"] = "Skinning"
L["PROF_FISHING"] = "Fishing"

-- Misc
L["MISC_UNKNOWN"] = "Unknown"
L["MISC_ITEMS"] = "items"
L["MISC_PER_HOUR"] = "/hr"          -- ENGLISH ONLY
L["MISC_ESTIMATED"] = "Est:"         -- ENGLISH ONLY
L["MISC_EXPANSION"] = "Expansion"
L["MISC_IN_BAGS_BANK"] = "In Bags/Bank"
L["MISC_TOTAL_NEEDED"] = "Total Needed"
L["MISC_NEED_MORE"] = "Need %s more"
L["MISC_HAVE_ENOUGH"] = "Have enough"
L["MISC_LUMBER_MUST_BE_FARMED"] = "Lumber must be farmed"
L["MISC_NOT_NEEDED_FOR_QUEUE"] = "Not needed for crafting queue"
L["MISC_ALL_RECIPES_COLLECTED"] = "All recipes using this collected"

-- ============================================================================
-- Acquisition Tab
-- ============================================================================
L["ACQ_TITLE"] = "Acquisition Guide"
L["ACQ_HOW_TO_USE"] = " How to Use"
L["ACQ_HIDE_UNRELEASED"] = "Hide Unreleased"
L["ACQ_EXPORT_NOTES"] = "Export Notes"
L["ACQ_BY_VENDOR"] = "By Vendor"
L["ACQ_BY_ITEM"] = "By Item"
L["ACQ_CLEAR_PINS"] = "Clear Pins"       -- ENGLISH ONLY
L["ACQ_MAP_ALL"] = "Map All"             -- ENGLISH ONLY
L["ACQ_RESET"] = "Reset"                 -- ENGLISH ONLY
L["ACQ_NAVIGATE"] = "Navigate"           -- ENGLISH ONLY
L["ACQ_SHOW_ON_MAP"] = "Show on Map"
L["ACQ_ADD_TO_QUEUE"] = "Add to Crafting Queue"
L["ACQ_EXPORT_TITLE"] = "Export User Notes"
L["ACQ_PINS_CLEARED"] = "All waypoints and map pins cleared."
L["ACQ_NO_VENDORS_TO_MAP"] = "No valid vendor locations to map."
L["ACQ_NO_COORDS"] = "No valid coordinates for this vendor."
L["ACQ_COMBAT_MAP_ERROR"] = "Cannot open map during combat."
L["ACQ_MAP_PIN_ERROR"] = "Could not set map pin for this zone."
L["ACQ_STATUS_VENDORS"] = "Showing %d vendors (%d items)"
L["ACQ_STATUS_ITEMS"] = "Showing %d items (%d uncollected)"

-- ============================================================================
-- Styles Tab
-- ============================================================================
L["STYLE_BROWSE_HEADER"] = "Browse by Style"
L["STYLE_BETA"] = "(Beta - in development)"
L["STYLE_CREATOR"] = "+ Style Creator"
L["STYLE_NEW"] = "+ New Style"
L["STYLE_NEW_DESC"] = "Click to create a custom style with your own facet tags"
L["STYLE_BACK"] = "< Back"               -- ENGLISH ONLY
L["STYLE_CREATOR_TITLE"] = "Style Creator"
L["STYLE_NAME_LABEL"] = "Name:"          -- ENGLISH ONLY
L["STYLE_DESC_LABEL"] = "Desc:"          -- ENGLISH ONLY
L["STYLE_CLEAR_ALL"] = "Clear All"       -- ENGLISH ONLY
L["STYLE_SAVE"] = "Save"                 -- ENGLISH ONLY
L["STYLE_CANCEL"] = "Cancel"             -- ENGLISH ONLY
L["STYLE_DELETE"] = "Delete"             -- ENGLISH ONLY
L["STYLE_IMPORT"] = "Import"             -- ENGLISH ONLY
L["STYLE_EXPORT_TITLE"] = "Export Style"
L["STYLE_IMPORT_PROMPT"] = "Paste an HDG style string to import:"
L["STYLE_CONFIRM_DELETE"] = "Delete custom style \"%s\"?"
L["STYLE_TIER_SIGNATURE"] = "Signature"
L["STYLE_TIER_ACCENT"] = "Accent"
L["STYLE_TIER_VERSATILE"] = "Versatile"
L["STYLE_TIER_CLASHING"] = "Clashing"
L["STYLE_BASKET"] = "BASKET (%d)"
L["STYLE_UNDO"] = "Undo"                 -- ENGLISH ONLY
L["STYLE_MSG_IMPORT_FAILED"] = "Import failed: %s"
L["STYLE_MSG_IMPORTED"] = "Imported style: %s"
L["STYLE_MSG_SAVED"] = "Saved custom style: %s"
L["STYLE_ERR_NAME_EMPTY"] = "Style name cannot be empty."
L["STYLE_ERR_NO_TAGS"] = "Need at least one tag selected."
L["STYLE_ERR_MAX_REACHED"] = "Maximum %d custom styles reached."

-- ============================================================================
-- Recipes Tab
-- ============================================================================
L["RECIPE_PROFESSIONS"] = "Professions"
L["RECIPE_EST_COST"] = "Est. Cost:"
L["RECIPE_CRAFT_CONFIRM"] = "Craft Confirmation"
L["RECIPE_CRAFT_ONE"] = "Craft 1"        -- ENGLISH ONLY
L["RECIPE_CRAFT_N"] = "Craft %d"
L["RECIPE_CRAFT_QUESTION"] = "Craft this item?"
L["RECIPE_KEEP_PROF_OPEN"] = "Keep profession window open after craft"
L["RECIPE_SEARCH"] = "Search recipes..."
L["RECIPE_TIER_READY"] = "Ready to Craft"
L["RECIPE_TIER_ALMOST"] = "Have Most Materials (75-99%%)"
L["RECIPE_TIER_HALFWAY"] = "Halfway There (50-74%%)"
L["RECIPE_TIER_NEED_MATS"] = "Need Materials (<50%%)"
L["RECIPE_MSG_CRAFTING"] = "[HDG] Crafting %dx %s..."
L["RECIPE_MSG_CRAFT_FAILED"] = "[HDG] CraftRecipe failed: %s"
L["RECIPE_MSG_INVALID"] = "[HDG] Invalid recipe data."
L["RECIPE_MSG_NO_API"] = "[HDG] C_TradeSkillUI not available."
L["RECIPE_MSG_PROF_NOT_READY"] = "[HDG] Profession window not ready. Please try again."

-- ============================================================================
-- Config Tab
-- ============================================================================
L["CONFIG_TITLE"] = "Configuration"
L["CONFIG_APPEARANCE"] = "Appearance"
L["CONFIG_INTERFACE"] = "Interface"
L["CONFIG_LUMBER_RADAR"] = "Lumber Radar"
L["CONFIG_QUOTES"] = "Farming & Crafting Quotes"
L["CONFIG_COMMUNITY"] = "Community"
L["CONFIG_HOW_TO_USE"] = "How to Use"
L["CONFIG_ADVANCED"] = "Advanced"
L["CONFIG_SPECIAL_THANKS"] = "Special Thanks"
L["CONFIG_LANGUAGE"] = "Language"

-- Config: Interface card
L["CFG_SHOW_MINIMAP"] = "Show Minimap Button"
L["CFG_HINT_MINIMAP"] = "(Draggable icon around the minimap)"
L["CFG_SHOW_COMPARTMENT"] = "Show in Addon Compartment"
L["CFG_HINT_COMPARTMENT"] = "(Minimap drawer menu - requires /reload)"
L["CFG_SHOW_PROF_BUTTONS"] = "Show Profession Window Buttons"
L["CFG_HINT_PROF_BUTTONS"] = "(Decor Guide & Filter Decor buttons)"
L["CFG_PIN_LUMBER"] = "Pin Lumber Tracker"
L["CFG_HINT_PIN_LUMBER"] = "(Floating widget - also via pin button)"
L["CFG_COMPARTMENT_CHANGED"] = "Addon compartment setting changed. Use /reload to apply."

-- Config: Lumber Radar card
L["CFG_AUTO_LUMBER_TRACKER"] = "Auto-Enable Lumber Tracker"
L["CFG_HINT_AUTO_LUMBER"] = "(Auto-show tracker when collecting lumber)"
L["CFG_AUTO_LUMBER_RADAR"] = "Auto-Show Lumber Radar"
L["CFG_HINT_AUTO_RADAR"] = "(/lumberhud to toggle manually)"
L["CFG_HINT_RADAR_SCALE"] = "(0.5x to 2.5x - resize the radar)"
L["CFG_HINT_RADAR_FPS"] = "(10-30 fps - smoothness vs CPU)"
L["CFG_PIN_RADAR"] = "Pin Radar to Tracker"
L["CFG_HINT_PIN_RADAR"] = "(Radar follows lumber tracker)"

-- Config: Quotes card
L["CFG_ENABLE_QUOTES"] = "Enable Quotes"
L["CFG_HINT_QUOTES"] = "(Talking head popups and chat messages while farming/crafting)"
L["CFG_QUOTES_CHAT_ONLY"] = "Only print quotes to chat"
L["CFG_HINT_CHAT_ONLY"] = "(No talking head display)"
L["CFG_LUMBER_QUOTES"] = "Lumber Quotes"
L["CFG_HINT_LUMBER_QUOTES"] = "(Vamoose, Squirrel, Gazlowe while lumber farming)"
L["CFG_HINT_CHATTINESS"] = "(0=Off, or quote after 1 to N lumber)"
L["CFG_CRAFT_QUOTES"] = "Craft Quotes"
L["CFG_HINT_CRAFT_QUOTES"] = "(When crafting/acquiring decor)"

-- Config: Advanced card
L["CFG_ENABLE_DEBUG"] = "Enable Debug Mode"
L["CFG_HINT_DEBUG"] = "(Enables /hdgdebug slash commands for troubleshooting)"
L["CFG_DEBUG_ENABLED"] = "Debug mode enabled - /hdgdebug commands now available"
L["CFG_DEBUG_DISABLED"] = "Debug mode disabled"

-- Config: Waypoints
L["CFG_WAYPOINT_AUTO"] = "Auto"
L["CFG_WAYPOINT_NATIVE"] = "Blizzard Native"
L["CFG_WAYPOINT_TOMTOM"] = "TomTom Only"

-- ============================================================================
-- Goblin Tab
-- ============================================================================
L["GOBLIN_EXPORT_TITLE"] = "Goblin Export (%d items)"
L["GOBLIN_NO_DATA_EXPORT"] = "No data to export. Adjust filters or scan prices first."
L["GOBLIN_ADDED_TO_QUEUE"] = "Added %s to crafting queue"
L["GOBLIN_OPEN_AH_TO_SEARCH"] = "Open the Auction House to search"
L["GOBLIN_CANNOT_SCAN"] = "Cannot scan: %s"
L["GOBLIN_SCANNING"] = "Scanning..."
L["GOBLIN_UPDATED"] = "Updated!"
L["GOBLIN_NO_AH_DATA"] = "No AH data"
L["GOBLIN_NO_PRICE_ADDON"] = "No price addon"
L["GOBLIN_SEARCH"] = "Search..."
L["GOBLIN_ITEMS_COUNT"] = "%d items"
L["GOBLIN_FILTERED_COUNT"] = "%d / %d items"
L["GOBLIN_KNOWN_BY_ALTS"] = "All Known Recipes"

-- ============================================================================
-- Alts Tab
-- ============================================================================
L["ALTS_PANEL_TITLE"] = "Your Characters"
L["ALTS_VIEW_RECIPES"] = "Recipes"
L["ALTS_VIEW_SKILLS"] = "Skills"
L["ALTS_HEADER_CHAR_DETAILS"] = "Character Details"
L["ALTS_NO_PROFESSIONS"] = "No Professions / Not Scanned"
L["ALTS_CURRENT"] = " (current)"
L["ALTS_LUMBER_KNOWN"] = "Find Lumber known"
L["ALTS_LUMBER_NOT_LEARNED"] = "Find Lumber not learned"
L["ALTS_LOG_IN"] = "Log in to check"
L["ALTS_SCAN_INSTRUCTIONS"] = "Open a profession window on each character to scan their skill levels."

-- ============================================================================
-- Data Tab
-- ============================================================================
L["DATA_CRAFTING_CLEARED"] = "Crafting history cleared."
L["DATA_NO_CRAFTING_EXPORT"] = "No crafting history to export."
L["DATA_FARMING_CLEARED"] = "Farming history cleared."
L["DATA_NO_FARMING_DELETE"] = "No farming sessions to delete."
L["DATA_DELETED_SESSION"] = "Deleted most recent session: "
L["DATA_NO_FARMING_EXPORT"] = "No farming history to export."
L["DATA_NO_COLLECTION_EXPORT"] = "No collection data to export. Click Refresh first."
L["DATA_EXPORTED_CRAFTING"] = "Exported %d crafting entries."
L["DATA_EXPORTED_FARMING"] = "Exported %d farming entries."
L["DATA_EXPORTED_COLLECTION"] = "Exported %d items (%d owned)."
L["DATA_DECOR_COLLECTION"] = "Decor Collection"
L["DATA_COLLECTION_DESC"] = "Overview of your owned decor items from the Housing Catalog."
L["DATA_FARMING_HELP"] = "Sessions start when lumber enters your bags. Zone shows where the last lumber was collected. Reloading UI ends the session."
L["DATA_CRAFTING_SORT_HELP"] = "(click item to preview, headers to sort)"
L["DATA_CLICK_REFRESH"] = "Click Refresh to load data"
L["DATA_CATALOG_UNAVAILABLE"] = "Housing Catalog API not available"
L["DATA_EMPTY_FARMING"] = "No farming sessions recorded yet.\nStart farming lumber to see your history here!"
L["DATA_STAT_UNIQUE"] = "Unique: "
L["DATA_STAT_STORAGE"] = "Storage: "
L["DATA_STAT_PLACED"] = "Placed: "
L["DATA_STAT_TOTAL"] = "Total: "
L["DATA_STAT_OWNED"] = "Owned: "

-- ============================================================================
-- Trainers Tab
-- ============================================================================
L["TRAINER_PANEL_TITLE"] = "Profession Trainers"
L["TRAINER_PANEL_SUBTITLE"] = "Click profession to expand/collapse"
L["TRAINER_DATA_NOT_LOADED"] = "Trainer data not loaded"
L["TRAINER_WAYPOINT_CLEARED"] = "Waypoint cleared."
L["TRAINER_ALL_CLEARED"] = "All waypoints and map pins cleared."
L["TRAINER_UNKNOWN_ZONE"] = "Unknown zone: '%s' - please report this!"
L["TRAINER_NEEDS_TRAINING"] = "Needs training:"
L["TRAINER_TRAINERS_SUFFIX"] = " trainers"

-- ============================================================================
-- Decor Preview Tab
-- ============================================================================
L["PREVIEW_TAB_TITLE"] = "Decor Preview"
L["PREVIEW_FILTER"] = "Filter:"
L["PREVIEW_ITEMS"] = "Items"
L["PREVIEW_HIDE_UNRELEASED"] = "Hide Unreleased"
L["PREVIEW_FIND_VENDOR"] = "Find Vendor"
L["PREVIEW_PLACEHOLDER"] = "Select an item to preview"
L["PREVIEW_LOADING"] = "Loading catalog..."
L["PREVIEW_NO_WINDOW"] = "Main window not available. Open /hdg first."
L["PREVIEW_NOT_INITIALIZED"] = "Module not initialized. Try reopening /hdg."
L["PREVIEW_NO_ITEM_ID"] = "Could not find item ID for this decor"
L["PREVIEW_ADDED_QUEUE"] = "Added %d craftable item(s) to crafting queue"
L["PREVIEW_NO_CRAFTABLE"] = "No craftable items to add (check your filters)"
L["PREVIEW_ADDED_TO_LIST"] = "Added %s to %s"
L["PREVIEW_SHOPPING_LIST"] = "shopping list"
L["PREVIEW_WISH_LIST"] = "wish list"
L["PREVIEW_INFO_PROFESSION"] = "Profession:"
L["PREVIEW_INFO_STORED"] = "(Stored: %d)"
L["PREVIEW_INFO_PLACED"] = "(Placed: %d)"
L["PREVIEW_INFO_ALLOWED"] = "Allowed:"
L["PREVIEW_INFO_INDOORS"] = "Indoors"
L["PREVIEW_INFO_OUTDOORS"] = "Outdoors"
L["PREVIEW_INFO_TAGS"] = "Tags:"
L["PREVIEW_INFO_DYEABLE"] = "Dyeable:"

-- ============================================================================
-- Save baseline for locale switching
-- ============================================================================
_G.HDG_BaseLocale = {}
for k, v in pairs(L) do
    _G.HDG_BaseLocale[k] = v
end

-- ============================================================================
-- LOCALE APPLICATION
-- ============================================================================

local function ApplyLocale(targetLocale)
    -- Reset to English base
    for key, value in pairs(_G.HDG_BaseLocale) do
        L[key] = value
    end

    -- Apply locale-specific overrides
    if _G.HDG_Locales[targetLocale] then
        for key, value in pairs(_G.HDG_Locales[targetLocale]) do
            L[key] = value
        end
    end

    -- Handle fallbacks for regional variants
    local fallbacks = {
        ["esMX"] = "esES",
        ["ptPT"] = "ptBR",
    }
    if fallbacks[targetLocale] and _G.HDG_Locales[fallbacks[targetLocale]] then
        for key, value in pairs(_G.HDG_Locales[fallbacks[targetLocale]]) do
            if not L[key] or L[key] == _G.HDG_BaseLocale[key] then
                L[key] = value
            end
        end
    end
end

-- Initial build with client locale
ApplyLocale(GetLocale())

-- ============================================================================
-- ACCESSOR METHODS
-- ============================================================================

function L:Get(key, fallback)
    return self[key] or fallback or key
end

function L:ApplyOverride()
    local override = HDG_Settings and HDG_Settings.localeOverride
    local targetLocale = (override and override ~= "auto") and override or GetLocale()
    ApplyLocale(targetLocale)
end

function L:GetEffectiveLocale()
    local override = HDG_Settings and HDG_Settings.localeOverride
    return (override and override ~= "auto") and override or GetLocale()
end

function L:GetAvailableLocales()
    return {
        { code = "auto", name = L["LOCALE_AUTO"] or "Auto (Client)" },
        { code = "enUS", name = "English" },
        { code = "esES", name = "Espanol (ES)" },
        { code = "esMX", name = "Espanol (MX)" },
        { code = "ptBR", name = "Portugues (BR)" },
        { code = "deDE", name = "Deutsch" },
        { code = "frFR", name = "Francais" },
        { code = "itIT", name = "Italiano" },
        { code = "ruRU", name = "Russian" },
        { code = "koKR", name = "Korean" },
        { code = "zhCN", name = "Chinese (Simplified)" },
        { code = "zhTW", name = "Chinese (Traditional)" },
    }
end

-- ============================================================================
-- EXPORT
-- ============================================================================

_G.HDG_L = L
_G.HDG_Localization = L
