$files = Get-ChildItem -Path "site\*.html", "site\tools\*.html" -Recurse

foreach ($file in $files) {
    $content = Get-Content $file.FullName -Raw
    
    # Check if this file has tool-icon styles to fix
    if ($content -match 'class="tool-icon" style="background:') {
        
        # Color mapping logic
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--violet-100\);?"', 'class="tool-icon" style="background:var(--violet-100);color:var(--violet-700);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--amber-bg\);?"', 'class="tool-icon" style="background:var(--amber-bg);color:var(--amber);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--green-bg\);?"', 'class="tool-icon" style="background:var(--green-bg);color:var(--green);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--pink-bg\);?"', 'class="tool-icon" style="background:var(--pink-bg);color:var(--pink-500);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--cyan-bg\);?"', 'class="tool-icon" style="background:var(--cyan-bg);color:var(--cyan-600);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--brand-facebook-bg\);?"', 'class="tool-icon" style="background:var(--brand-facebook-bg);color:var(--brand-facebook);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--brand-pinterest-bg\);?"', 'class="tool-icon" style="background:var(--brand-pinterest-bg);color:var(--brand-pinterest);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--brand-whatsapp-bg\);?"', 'class="tool-icon" style="background:var(--brand-whatsapp-bg);color:var(--brand-whatsapp);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--brand-google-blue-bg\);?"', 'class="tool-icon" style="background:var(--brand-google-blue-bg);color:var(--brand-google-blue);"')
        
        $content = [regex]::Replace($content, 'class="tool-icon" style="background:var\(--brand-rss-bg\);?"', 'class="tool-icon" style="background:var(--brand-rss-bg);color:var(--brand-rss);"')

        Set-Content -Path $file.FullName -Value $content -Encoding UTF8
    }
}
Write-Host "Tool icons color fixed."
