<?php
$files = [
    "resources/views/livewire/accounts.blade.php",
    "resources/views/livewire/projects.blade.php",
    "resources/views/livewire/ledgers.blade.php",
    "resources/views/livewire/parties.blade.php",
    "resources/views/livewire/branches.blade.php",
    "resources/views/livewire/centers.blade.php",
    "resources/views/livewire/entities.blade.php"
];

foreach ($files as $file) {
    if (file_exists($file)) {
        $content = file_get_contents($file);
        
        // Remove BOM if present
        if (substr($content, 0, 3) === "\xEF\xBB\xBF") {
            $content = substr($content, 3);
        }

        // Fix encoding: string is currently UTF-8 containing CP1252 interpreted characters
        $fixed = mb_convert_encoding($content, 'Windows-1252', 'UTF-8');
        
        file_put_contents($file, $fixed);
        echo "Fixed $file\n";
    }
}
