<?php
/**
 * Template Name: Find a Trainer - Minimal Test
 * Minimal version for Safari debugging
 *
 * @package HVAC_Plugin
 * @since 1.0.0
 */

// Define constant to identify we're in a page template
define('HVAC_IN_PAGE_TEMPLATE', true);

// Get header
get_header();

?>

<div class="hvac-find-trainer-minimal">
    <div class="ast-container">
        <h1>Find a Trainer - Minimal Test</h1>
        <p>If you can see this text, the basic page loading works.</p>
        
        <p><strong>Browser Info:</strong></p>
        <ul>
            <li>User Agent: <code id="user-agent"></code></li>
            <li>Browser: <span id="browser-detection"></span></li>
            <li>JavaScript: <span id="js-status">❌ Not loaded</span></li>
        </ul>
        
        <div id="test-results">
            <h3>JavaScript Tests:</h3>
            <div id="test-output"></div>
        </div>
    </div>
</div>

<!-- Minimal JavaScript test -->
<script type="text/javascript">
// ES5 only - basic compatibility test
(function() {
    'use strict';
    
    // Test 1: Basic JavaScript works
    document.getElementById('js-status').innerHTML = '✅ Basic JS working';
    document.getElementById('user-agent').innerHTML = navigator.userAgent;
    
    // Test 2: Browser detection
    var userAgent = navigator.userAgent;
    var isSafari = userAgent.indexOf('Safari') !== -1 && userAgent.indexOf('Chrome') === -1;
    var isOldSafari = false;
    
    if (isSafari) {
        var versionMatch = userAgent.match(/Version\/([0-9]+)/);
        if (versionMatch && parseInt(versionMatch[1]) < 10) {
            isOldSafari = true;
        }
    }
    
    var browserText = isSafari ? (isOldSafari ? '🚨 Old Safari (needs ES5)' : '✅ Modern Safari') : '✅ Other browser';
    document.getElementById('browser-detection').innerHTML = browserText;
    
    // Test 3: Add test results
    var testOutput = document.getElementById('test-output');
    var tests = [
        'Basic JavaScript: ✅ Working',
        'DOM manipulation: ✅ Working',
        'User agent detection: ✅ Working'
    ];
    
    for (var i = 0; i < tests.length; i++) {
        var p = document.createElement('p');
        p.innerHTML = tests[i];
        testOutput.appendChild(p);
    }
    
    // Test 4: Try some potentially problematic syntax
    try {
        var testVar = 'test';
        testOutput.appendChild(createTestResult('var declaration: ✅ Working'));
    } catch (e) {
        testOutput.appendChild(createTestResult('var declaration: ❌ Error - ' + e.message));
    }
    
    function createTestResult(text) {
        var p = document.createElement('p');
        p.innerHTML = text;
        return p;
    }
    
})();
</script>

<?php
// Get footer
get_footer();
?>