<?php
// ============================================================
// SITEMAP XML DYNAMIQUE - OpulentEdge
// Génère automatiquement toutes les URLs du site
// ============================================================

header('Content-Type: application/xml; charset=UTF-8');
header('X-Robots-Tag: noindex');

$base = 'https://opulentedgeltd.com';
$today = date('Y-m-d');

// Charger les districts
$districts = json_decode(file_get_contents(__DIR__ . '/data/districts_germany.json'), true) ?? [];

// Pierres
$stonePrefixes = [
    'tanzanite' => 'tanzanite-investment',
    'spinell'   => 'spinell-investment',
    'tsavorit'  => 'tsavorit-investment',
    'aquamarin' => 'aquamarin-investment',
    'turmalin'  => 'turmalin-investment',
    'amethyst'  => 'amethyst-investment',
];

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">

  <!-- ============ PAGES PRINCIPALES ============ -->
  <url>
    <loc><?= $base ?>/</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>1.0</priority>
  </url>

  <!-- Pages pierres piliers -->
  <?php foreach ($stonePrefixes as $stone => $prefix): ?>
  <url>
    <loc><?= $base ?>/<?= $prefix ?></loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.9</priority>
  </url>
  <?php endforeach; ?>

  <!-- Pages spéciales -->
  <url>
    <loc><?= $base ?>/investmentgesellschaft-vergleich</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.85</priority>
  </url>
  <url>
    <loc><?= $base ?>/kontakt</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.85</priority>
  </url>
  <url>
    <loc><?= $base ?>/edelstein-preise</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>0.8</priority>
  </url>
  <url>
    <loc><?= $base ?>/edelstein-investment-staedte</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.8</priority>
  </url>
  <url>
    <loc><?= $base ?>/edelstein-investment-landkreise</loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.8</priority>
  </url>

  <!-- ============ PAGES DISTRICTS (400 x 6 = 2400 URLs) ============ -->
  <?php foreach ($stonePrefixes as $stone => $prefix): ?>
    <?php foreach ($districts as $district): ?>
  <url>
    <loc><?= $base ?>/<?= $prefix ?>/district/<?= htmlspecialchars($district['slug']) ?></loc>
    <lastmod><?= $today ?></lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.6</priority>
  </url>
    <?php endforeach; ?>
  <?php endforeach; ?>

</urlset>