<?php
$files = [
    'project-management/pmp-certification-training.php',
    'cloud-computing/aws-cloud-architect-masters-program-certification.php',
    'cloud-computing/microsoft-azure-fundamentals-training.php',
    'agile-management/csm-certification-training.php',
    'agile-management/leading-safe-6-0-certification-training.php',
    'project-management/capm-certification-training.php',
    'data-science/data-science-with-python-certification-training.php',
    'data-science/generative-ai-and-prompt-engineering-course.php',
    'data-science/applied-agentic-ai-certification-course.php',
    'data-science/ai-product-management-course.php',
    'cyber-security/cissp-certification-training.php'
];

foreach ($files as $file) {
    if (!file_exists($file)) {
        echo "File not found: $file\n";
        continue;
    }

    $content = file_get_contents($file);

    // 1. Add course-page-fixes script if missing
    if (strpos($content, 'course-page-fixes.js') === false) {
        $content = preg_replace(
            '/(<script>document\.body\.classList\.add\([\'"][^\'"]*[\'"]\);<\/script>)/', 
            "$1\n<script src=\"/aaa/assets/js/course-page-fixes.js?v=" . time() . "\"></script>", 
            $content
        );
    }

    // 2. Fix the Hero Section Grid Structure for mobile
    // Look for the "col-md-7" vs "col-md-5" pattern which is standard cross-site
    $content = preg_replace(
        '/<div class="([^"]*)row([^"]*)">\s*<div class="([^"]*)col-md-7([^"]*)">/',
        '<div class="row flex flex-col md:flex-row"><div class="col-12 col-md-7 order-1">',
        $content
    );
    $content = preg_replace(
        '/<div class="([^"]*)col-md-5([^"]*)">/',
        '<div class="col-12 col-md-5 order-2 mt-8 md:mt-0">',
        $content
    );

    // 3. Fix the Hero Highlight Box styling to be high-contrast
    $content = preg_replace(
        '/<div class="hero-highlight-box[^"]*">/',
        '<div class="hero-highlight-box p-4 md:p-6 mb-6 mt-10 md:mt-6 bg-yellow-50 border-2 border-yellow-400 rounded-xl shadow-lg">',
        $content
    );

    file_put_contents($file, $content);
    echo "Standardized $file\n";
}
echo "Done.\n";
