<?php
include 'includes/db.php';

echo "<h1>Quick City Check</h1>";

// Check if cities exist
$cityCount = $pdo->query("SELECT COUNT(*) as count FROM cities")->fetch()['count'];
echo "<p><strong>Cities in database:</strong> $cityCount</p>";

if ($cityCount == 0) {
    echo "<p style='color: red; font-size: 18px;'>❌ NO CITIES FOUND!</p>";
    echo "<p>This is why the city links aren't working.</p>";
    echo "<p><strong>Solution:</strong> <a href='admin/sync-city-services.php' style='background: blue; color: white; padding: 10px; text-decoration: none; border-radius: 5px;'>Run Sync Script</a></p>";
} else {
    echo "<p style='color: green;'>✅ Cities found</p>";
    
    // Show first few cities
    $cities = $pdo->query("SELECT * FROM cities ORDER BY name LIMIT 5")->fetchAll();
    echo "<h3>Sample Cities:</h3>";
    echo "<ul>";
    foreach ($cities as $city) {
        echo "<li>{$city['name']} (slug: {$city['slug']})</li>";
    }
    echo "</ul>";
}

// Check services
$serviceCount = $pdo->query("SELECT COUNT(*) as count FROM services")->fetch()['count'];
echo "<p><strong>Services in database:</strong> $serviceCount</p>";

// Check combinations
$comboCount = $pdo->query("SELECT COUNT(*) as count FROM city_service")->fetch()['count'];
echo "<p><strong>City-service combinations:</strong> $comboCount</p>";

if ($cityCount > 0 && $serviceCount > 0 && $comboCount == 0) {
    echo "<p style='color: orange;'>⚠️ Cities and services exist but no combinations!</p>";
    echo "<p><a href='admin/sync-city-services.php' style='background: orange; color: white; padding: 10px; text-decoration: none; border-radius: 5px;'>Run Sync Script</a></p>";
}
?>