<?php
$dir = new RecursiveDirectoryIterator('c:/xampp/htdocs/inveetaire/app/views');
$ite = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($ite, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);

$inconsistencies = [
    'card_padding' => [],
    'form_spacing' => [],
    'button_gap' => []
];

foreach ($files as $file) {
    $path = $file[0];
    if (strpos($path, 'layouts') !== false || strpos($path, 'public') !== false) continue; // Focus on couple panel mostly
    $content = file_get_contents($path);

    // Find card padding
    if (preg_match_all('/class="[^"]*bg-white[^"]*rounded-[^"]*shadow-[^"]*p-([0-9]+)[^"]*"/i', $content, $matches)) {
        foreach ($matches[1] as $p) {
            $inconsistencies['card_padding'][$p][] = basename($path);
        }
    }

    // Find form missing space-y
    if (preg_match_all('/<form[^>]*class="([^"]*)"/i', $content, $matches)) {
        foreach ($matches[1] as $cls) {
            if (strpos($cls, 'space-y-') === false && strpos($cls, 'flex') === false && strpos($cls, 'grid') === false) {
                $inconsistencies['form_spacing'][] = basename($path);
            }
        }
    }

    // Find adjacent buttons without gaps in flex containers
    // A bit harder, let's just look for multiple btns in a single line
    $lines = explode("\n", $content);
    foreach ($lines as $i => $line) {
        if (substr_count($line, 'class="btn') > 1 || substr_count($line, 'class=\'btn') > 1) {
            if (strpos($line, 'gap-') === false && strpos($line, 'space-x-') === false && strpos($line, 'justify-between') === false) {
                $inconsistencies['button_gap'][] = basename($path) . ':' . ($i+1);
            }
        }
    }
}

foreach ($inconsistencies['card_padding'] as $k => $v) {
    $inconsistencies['card_padding'][$k] = array_unique($v);
}
$inconsistencies['form_spacing'] = array_unique($inconsistencies['form_spacing']);

print_r($inconsistencies);
