local MonkeyGames = LibStub("AceAddon-3.0"):GetAddon("MonkeyGames")

local Theme = {}
MonkeyGames.Theme = Theme

-- Base font (same as XPTracker)
Theme.BASE_FONT = _G.GameFontNormal:GetFont()
Theme.FONT_SIZE_TITLE = 12
Theme.FONT_SIZE_BODY = 10
Theme.FONT_SIZE_SMALL = 9
Theme.FONT_SIZE_BUTTON = 10
Theme.FONT_SIZE_PIECE = 24

-- Primary colors (XPTracker palette)
Theme.BG_COLOR = { 0.047, 0.047, 0.106 }
Theme.BORDER_COLOR = { 0.4, 0.4, 0.45, 1 }
Theme.HEADER_GRADIENT_LEFT = { 0.12, 0.10, 0.25, 0.9 }
Theme.HEADER_GRADIENT_RIGHT = { 0.03, 0.03, 0.08, 0.7 }

-- Text colors
Theme.TEXT_DEFAULT = { 0.9, 0.9, 0.9, 1 }
Theme.TEXT_ACCENT = { 0.9, 0.85, 1, 1 }
Theme.TEXT_GREEN = { 0.5, 0.9, 0.6, 1 }
Theme.TEXT_LABEL = { 0.7, 0.5, 0.8, 1 }
Theme.TEXT_GOLD = { 1, 0.843, 0, 1 }
Theme.TEXT_DIM = { 0.6, 0.6, 0.6, 1 }
Theme.TEXT_ERROR = { 0.9, 0.4, 0.4, 1 }

-- Button colors
Theme.BUTTON_TEXT = { 0.7, 0.9, 0.7, 1 }
Theme.BUTTON_TEXT_HOVER = { 1, 1, 1, 1 }
Theme.BUTTON_BG = { 0.08, 0.08, 0.18, 0.8 }
Theme.BUTTON_BG_HOVER = { 0.15, 0.12, 0.30, 0.9 }

-- Chess board colors
Theme.BOARD_LIGHT = { 0.22, 0.18, 0.35, 1 }
Theme.BOARD_DARK = { 0.10, 0.08, 0.20, 1 }

-- Highlight colors
Theme.HIGHLIGHT_SELECTED = { 0.4, 0.3, 0.7, 0.6 }
Theme.HIGHLIGHT_LEGAL = { 0.3, 0.7, 0.3, 0.4 }
Theme.HIGHLIGHT_CAPTURE = { 0.8, 0.3, 0.3, 0.4 }
Theme.HIGHLIGHT_LAST_MOVE = { 0.5, 0.5, 0.2, 0.3 }
Theme.HIGHLIGHT_CHECK = { 0.9, 0.2, 0.2, 0.5 }

-- Piece colors
Theme.PIECE_WHITE = { 1.0, 0.95, 0.85, 1 }
Theme.PIECE_BLACK = { 0.15, 0.12, 0.10, 1 }
Theme.PIECE_WHITE_OUTLINE = { 0.3, 0.25, 0.2, 1 }
Theme.PIECE_BLACK_OUTLINE = { 0.7, 0.65, 0.6, 1 }

-- Textures (WoW built-in)
Theme.TEX_BG = "Interface\\Tooltips\\UI-Tooltip-Background"
Theme.TEX_BORDER = "Interface\\DialogFrame\\UI-DialogBox-Border"
Theme.TEX_BORDER_TOOLTIP = "Interface\\Tooltips\\UI-Tooltip-Border"
Theme.TEX_WHITE8X8 = "Interface\\BUTTONS\\WHITE8X8"

-- Custom art textures
local ART_PATH = "Interface\\AddOns\\MonkeyGames\\images\\"
Theme.TEX_FELT = ART_PATH .. "felt"

-- Card textures (individual PNG files)
local CARDS_PATH = ART_PATH .. "cards\\"
Theme.CARD_BACK_TEXTURE = CARDS_PATH .. "back_red.png"

function Theme:GetCardTexture(rank, suit)
    if rank and suit then
        return CARDS_PATH .. rank .. "_of_" .. suit .. ".png"
    end
    return nil
end

-- Chess piece textures (individual PNG files)
local CHESS_PATH = ART_PATH .. "chess\\"
Theme.CHESS_PIECE_TEXTURES = {
    wK = CHESS_PATH .. "white_king.png",
    wQ = CHESS_PATH .. "white_queen.png",
    wR = CHESS_PATH .. "white_rook.png",
    wB = CHESS_PATH .. "white_bishop.png",
    wN = CHESS_PATH .. "white_knight.png",
    wP = CHESS_PATH .. "white_pawn.png",
    bK = CHESS_PATH .. "black_king.png",
    bQ = CHESS_PATH .. "black_queen.png",
    bR = CHESS_PATH .. "black_rook.png",
    bB = CHESS_PATH .. "black_bishop.png",
    bN = CHESS_PATH .. "black_knight.png",
    bP = CHESS_PATH .. "black_pawn.png",
}

-- Backdrop template (compatible across WoW versions)
Theme.BACKDROP = {
    bgFile = Theme.TEX_BG,
    edgeFile = Theme.TEX_BORDER_TOOLTIP,
    tile = true,
    tileSize = 16,
    edgeSize = 16,
    insets = { left = 4, right = 4, top = 4, bottom = 4 },
}

Theme.BACKDROP_SECTION = {
    bgFile = Theme.TEX_BG,
    edgeFile = Theme.TEX_BORDER,
    tile = true,
    tileSize = 32,
    edgeSize = 16,
    insets = { left = 4, right = 4, top = 4, bottom = 4 },
}
