local addonName, ns = ...

-- Addon namespace
ns.addonName = addonName
ns.version = "1.0.0"

-- Localization table (will be filled by locale files)
ns.L = ns.L or {}

-- Create saved variables table if it doesn't exist
nCastbarDB = nCastbarDB or {}

-- Helper functions
ns.Print = function(msg)
    print("|cff1784d1nCastbar:|r " .. tostring(msg))
end

ns.Debug = function(fmt, ...)
    if not nCastbarDB or not nCastbarDB.profile then return end
    if not nCastbarDB.profile.debug and not nCastbarDB.profile.debugChat then return end
    local ok, msg = pcall(string.format, tostring(fmt), ...)
    if not ok then msg = tostring(fmt) end
    local ts = date("%H:%M:%S")
    print("|cff1784d1nCastbar |cffff9900[" .. ts .. "]|r " .. msg)
end

ns.Error = function(msg)
    print("|cff1784d1nCastbar:|r " .. ns.L["ERROR_PREFIX"] .. " " .. tostring(msg))
end

-- Helper to check if we're in combat
ns.InCombat = function()
    if InCombatLockdown() then
        ns.Error(ns.L["COMBAT_LOCKDOWN"])
        return true
    end
    return false
end

-- Helper for multiple unit checks
ns.MultiCheck = function(unit, ...)
    for i = 1, select("#", ...) do
        if unit == select(i, ...) then
            return true
        end
    end
    return false
end

-- Color conversion helper
ns.RGBToHex = function(r, g, b)
    return string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
end


