$htmlPath = "site\tools.html"
$html = Get-Content $htmlPath -Raw

$uniqueLogos = @{
    # 1. Broken link tool needs to be a highly recognizable broken link chain
    "broken-link-checker.html" = '<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="#EA4335" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"/><path d="m5.17 11.67-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"/><line x1="8" y1="8" x2="16" y2="16" stroke="#EA4335" stroke-width="4"/></svg>'
    
    # 2. Google Merchant Feed Logo (Google-colored shopping bag)
    "merchant-feed-generator.html" = '<svg viewBox="0 0 24 24" width="24" height="24"><path fill="#4285F4" d="M19 6h-2c0-2.76-2.24-5-5-5S7 3.24 7 6H5c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7-3c1.66 0 3 1.34 3 3H9c0-1.66 1.34-3 3-3zm7 17H5V8h14v12z"/><path fill="#34A853" d="M12 15c-3.87 0-7-3.13-7-7H3c0 4.97 4.03 9 9 9s9-4.03 9-9h-2c0 3.87-3.13 7-7 7z"/><circle cx="12" cy="11" r="3" fill="#EA4335"/></svg>'
    
    # 3. Google Product Category Finder (Purple distinct tag so it doesn't share colors)
    "google-product-category-finder.html" = '<svg viewBox="0 0 24 24" width="24" height="24"><path fill="#7C2FF5" d="M21.41 11.58l-9-9C12.05 2.22 11.55 2 11 2H4c-1.1 0-2 .9-2 2v7c0 .55.22 1.05.59 1.42l9 9c.36.36.86.58 1.41.58.55 0 1.05-.22 1.41-.59l7-7c.37-.36.59-.86.59-1.41 0-.55-.23-1.06-.59-1.42zM5.5 7C4.67 7 4 6.33 4 5.5S4.67 4 5.5 4 7 4.67 7 5.5 6.33 7 5.5 7z"/></svg>'
    
    # 4. Merchant Feed Validator (Cyan shield-check)
    "merchant-feed-validator.html" = '<svg viewBox="0 0 24 24" width="24" height="24"><path fill="#00BCD4" d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm-2 16l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z"/></svg>'
    
    # 5. GTIN/EAN/UPC Validator (Indigo Barcode)
    "gtin-ean-upc-validator.html" = '<svg viewBox="0 0 24 24" width="24" height="24" fill="#4F46E5"><rect x="3" y="5" width="2" height="14"/><rect x="7" y="5" width="4" height="14"/><rect x="13" y="5" width="2" height="14"/><rect x="17" y="5" width="4" height="14"/></svg>'
}

$regex = '(?s)<a class="tool-card" href="[^"]*?([^/"]+\.html)">\s*<div class="tool-icon"[^>]*>.*?</div>'
$matches = [regex]::Matches($html, $regex)

foreach ($m in $matches) {
    $filename = $m.Groups[1].Value
    $fullMatch = $m.Value
    
    if ($uniqueLogos.ContainsKey($filename)) {
        $newIcon = $uniqueLogos[$filename]
        $newFullMatch = $fullMatch -replace '(?s)<svg.*?</svg>', $newIcon
        $html = $html.Replace($fullMatch, $newFullMatch)
    }
}

Set-Content -Path $htmlPath -Value $html -Encoding UTF8
Write-Host "Replaced ecommerce logos and broken link icon."
