src/Services/ThemeService.ps1

# ThemeService — Wrapper sobre $global:RNThemes.
# Mantiene cuál es el tema activo y expone accessors helper.

class ThemeService {
    [string] $ActiveKey = 'midnight'

    ThemeService() { }
    ThemeService([string]$activeKey) { $this.ActiveKey = $activeKey }

    [hashtable] GetActive() {
        $t = $global:RNThemes[$this.ActiveKey]
        if (-not $t) { throw "ThemeService: theme desconocido: $($this.ActiveKey)" }
        return $t
    }

    [void] SetActive([string]$key) {
        if (-not $global:RNThemes.ContainsKey($key)) {
            throw "ThemeService: theme inexistente: $key"
        }
        $this.ActiveKey = $key
    }

    [string[]] ListAvailable() {
        return @($global:RNThemes.Keys | Where-Object { $null -ne $global:RNThemes[$_] })
    }

    # Helper: hex de una key del tema activo → ANSI escape FG.
    [string] Fg([string]$themeKey) {
        $t = $this.GetActive()
        if (-not $t.ContainsKey($themeKey)) { throw "ThemeService.Fg: key '$themeKey' no existe en theme" }
        return [AnsiService]::FgHex($t[$themeKey])
    }

    [string] Bg([string]$themeKey) {
        $t = $this.GetActive()
        if (-not $t.ContainsKey($themeKey)) { throw "ThemeService.Bg: key '$themeKey' no existe en theme" }
        return [AnsiService]::BgHex($t[$themeKey])
    }

    # Color del status pill por estado de repo.
    [string] StatusFg([string]$status) {
        $key = switch ($status) {
            'clean'    { 'gitClean' }
            'dirty'    { 'gitDirty' }
            'unpushed' { 'gitUnpushed' }
            'behind'   { 'gitBehind' }
            'conflict' { 'gitConflict' }
            'nogit'    { 'gitNoGit' }
            default    { 'fg2' }
        }
        return $this.Fg($key)
    }
}