--[[
============================================================================
ETB - Modules/TooltipStyle.lua
============================================================================
Single source of truth for tooltip styling across the whole suite (core
ETB, ERB, EMT, EPT, ZoneScan). The canonical look is the flagship boss-loot
hover (BossLootTooltip): a cyan section header, ReadyCheck textures for the
collected / not-collected marks (texture marks render reliably; unicode
check glyphs show as tofu on some clients), and the flagship green/red.

Consumers read these at runtime, so load order isn't critical, but this
file is listed early in the TOC so ETB.Style is present before any tooltip
fires. Adding a value here and pointing modules at it keeps the palette
from drifting apart again.
============================================================================
]]--

local ADDON_NAME, NS = ...
NS.ETB = NS.ETB or {}
local ETB = NS.ETB

local Style = {
    -- Core palette (mirrors BossLootTooltip's exposed constants exactly)
    HEADER      = "|cff00ccff",   -- cyan section header
    COLLECTED   = "|cff00ff00",   -- green (have it)
    UNCOLLECTED = "|cffff6666",   -- red  (missing)
    SEPARATOR   = "|cff444444",   -- faint divider
    TOKEN       = "|cffff8000",   -- orange (tier tokens)
    DIFFICULTY  = "|cffffcc00",   -- gold-ish difficulty label
    RATE        = "|cffaaaaaa",   -- grey drop-rate / secondary text
    SUBHEADER   = "|cffaaaaff",   -- light-blue boss / encounter sub-header
    WHITE       = "|cffffffff",

    -- Marks — ReadyCheck textures, the flagship's tofu-safe choice.
    MARK_OWNED   = "|TInterface\\RaidFrame\\ReadyCheck-Ready:14:14:0:0|t",
    MARK_MISSING = "|TInterface\\RaidFrame\\ReadyCheck-NotReady:14:14:0:0|t",
    STAR         = "|TInterface\\Common\\ReputationStar:14:14:0:0|t",  -- gold star texture (Unicode renders as tofu on some clients)

    -- Source-type tag colors (standardised from EMT SourceInfo).
    SOURCE_TAG = {
        B = "|cffff7777Boss|r",   R = "|cffffbb55Rare|r",  V = "|cff77dd77Vendor|r",
        P = "|cff7799ffPvP|r",    C = "|cffffaa44Craft|r",  F = "|cff55ccffRep|r",
        H = "|cffff88ccEvent|r",  K = "|cffbb88ffBMAH|r",   W = "|cffaabbaaWorld|r",
        L = "|cffcccc66Class|r",  M = "|cff66ccffStore|r",  ["?"] = "|cff999999Other|r",
    },
}

-- Mark for a boolean owned-state. nil owned -> no mark (unknown).
function Style:Mark(owned)
    if owned == true then return self.MARK_OWNED end
    if owned == false then return self.MARK_MISSING end
    return ""
end

-- Canonical "N / M" count string. Coloured green when complete, red while
-- incomplete — matching the flagship's header count. Pass withPct=true to
-- append the percentage the boss hover shows.
function Style:Count(collected, total, withPct)
    collected = collected or 0
    total = total or 0
    local color = (total > 0 and collected >= total) and self.COLLECTED or self.UNCOLLECTED
    if withPct then
        local pct = total > 0 and (100 * collected / total) or 0
        return string.format("%s%d / %d (%.0f%%)|r", color, collected, total, pct)
    end
    return string.format("%s%d|r%s/%d|r", color, collected, self.RATE, total)
end

-- Inline collection-status string: the canonical ReadyCheck mark followed by a
-- colored label, e.g. "<check> Collected" / "<x> Not Collected". Keeps every
-- "✓ Collected / ✗ Not Collected" line in the suite identical.
function Style:StatusText(owned, ownedLabel, missingLabel)
    if owned then
        return self.MARK_OWNED .. " " .. self.COLLECTED .. (ownedLabel or "Collected") .. "|r"
    end
    return self.MARK_MISSING .. " " .. self.UNCOLLECTED .. (missingLabel or "Not Collected") .. "|r"
end

ETB.Style = Style

if ETB.Debug then ETB:Debug("TooltipStyle", "loaded (canonical tooltip palette)") end
