<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9">

  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

  <xsl:template match="/">
    <html lang="de">
      <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <meta name="robots" content="noindex, nofollow"/>
        <title>Sitemap – sharkz.eu</title>
        <style>
          * { box-sizing: border-box; margin: 0; padding: 0; }
          body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
            background: #f5f5f5;
            color: #222;
            padding: 40px 20px;
          }
          .wrapper {
            max-width: 900px;
            margin: 0 auto;
          }
          header {
            margin-bottom: 32px;
          }
          header h1 {
            font-size: 1.6rem;
            font-weight: 700;
            color: #111;
          }
          header p {
            margin-top: 8px;
            color: #666;
            font-size: 0.9rem;
          }
          header a {
            color: #0057d9;
            text-decoration: none;
          }
          header a:hover { text-decoration: underline; }
          table {
            width: 100%;
            border-collapse: collapse;
            background: #fff;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 2px 12px rgba(0,0,0,0.08);
          }
          thead tr {
            background: #111;
            color: #fff;
          }
          th {
            padding: 14px 18px;
            text-align: left;
            font-size: 0.78rem;
            font-weight: 600;
            letter-spacing: 0.08em;
            text-transform: uppercase;
          }
          td {
            padding: 13px 18px;
            font-size: 0.9rem;
            border-bottom: 1px solid #eee;
            vertical-align: middle;
          }
          tr:last-child td { border-bottom: none; }
          tr:hover td { background: #f9f9f9; }
          td a {
            color: #0057d9;
            text-decoration: none;
            word-break: break-all;
          }
          td a:hover { text-decoration: underline; }
          .badge {
            display: inline-block;
            padding: 3px 9px;
            border-radius: 999px;
            font-size: 0.72rem;
            font-weight: 600;
          }
          .prio-high { background: #e8f5e9; color: #2e7d32; }
          .prio-mid  { background: #fff8e1; color: #f57f17; }
          .prio-low  { background: #f3f3f3; color: #555; }
          footer {
            margin-top: 24px;
            color: #aaa;
            font-size: 0.78rem;
            text-align: center;
          }
        </style>
      </head>
      <body>
        <div class="wrapper">
          <header>
            <h1>Sitemap – sharkz.eu</h1>
            <p>
              Diese Datei ist für Suchmaschinen bestimmt. Weitere Informationen unter
              <a href="https://www.sitemaps.org" target="_blank" rel="noopener">sitemaps.org</a>.
            </p>
          </header>

          <table>
            <thead>
              <tr>
                <th>#</th>
                <th>URL</th>
                <th>Zuletzt geändert</th>
                <th>Änderungshäufigkeit</th>
                <th>Priorität</th>
              </tr>
            </thead>
            <tbody>
              <xsl:for-each select="sitemap:urlset/sitemap:url">
                <xsl:sort select="sitemap:priority" order="descending" data-type="number"/>
                <tr>
                  <td><xsl:value-of select="position()"/></td>
                  <td>
                    <a href="{sitemap:loc}" target="_blank" rel="noopener">
                      <xsl:value-of select="sitemap:loc"/>
                    </a>
                  </td>
                  <td><xsl:value-of select="sitemap:lastmod"/></td>
                  <td><xsl:value-of select="sitemap:changefreq"/></td>
                  <td>
                    <xsl:choose>
                      <xsl:when test="sitemap:priority >= 0.9">
                        <span class="badge prio-high"><xsl:value-of select="sitemap:priority"/></span>
                      </xsl:when>
                      <xsl:when test="sitemap:priority >= 0.7">
                        <span class="badge prio-mid"><xsl:value-of select="sitemap:priority"/></span>
                      </xsl:when>
                      <xsl:otherwise>
                        <span class="badge prio-low"><xsl:value-of select="sitemap:priority"/></span>
                      </xsl:otherwise>
                    </xsl:choose>
                  </td>
                </tr>
              </xsl:for-each>
            </tbody>
          </table>

          <footer>
            <p>
              <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> URLs indexiert ·
              Generiert für Google Search Console
            </p>
          </footer>
        </div>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>
