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

  <xsl:template match="/">
    <html>
      <head>
        <title>Keekan SEO Sitemap</title>
        <style type="text/css">
          body { font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; background: #0b1020; color: #e6ebff; margin: 0; }
          .wrap { max-width: 1000px; margin: 32px auto; padding: 24px; }
          h1 { font-size: 24px; margin: 0 0 8px; }
          p { color: #a7b0d8; margin: 0 0 20px; }
          table { width: 100%; border-collapse: collapse; background: #111835; border-radius: 12px; overflow: hidden; }
          th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #1e2650; }
          th { background: #141c3f; color: #c9d4ff; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
          tr:last-child td { border-bottom: 0; }
          a { color: #7fd1ff; text-decoration: none; }
          a:hover { text-decoration: underline; }
          .meta { font-size: 12px; color: #8b95c7; }
        </style>
      </head>
      <body>
        <div class="wrap">
          <h1>Keekan SEO Sitemap</h1>
          <xsl:choose>
            <xsl:when test="sitemap:sitemapindex">
              <p class="meta">This sitemap index lists all sitemap sections. Total sections: <xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"/>.</p>
            </xsl:when>
            <xsl:otherwise>
              <p class="meta">This sitemap lists the latest content URLs. Total URLs: <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/>.</p>
            </xsl:otherwise>
          </xsl:choose>
          <xsl:choose>
            <xsl:when test="sitemap:sitemapindex">
              <table>
                <thead>
                  <tr>
                    <th>Section</th>
                    <th>Last Modified</th>
                  </tr>
                </thead>
                <tbody>
                  <xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
                    <tr>
                      <td><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc"/></a></td>
                      <td><xsl:value-of select="sitemap:lastmod"/></td>
                    </tr>
                  </xsl:for-each>
                </tbody>
              </table>
            </xsl:when>
            <xsl:otherwise>
              <table>
                <thead>
                  <tr>
                    <th>URL</th>
                    <th>Last Modified</th>
                  </tr>
                </thead>
                <tbody>
                  <xsl:for-each select="sitemap:urlset/sitemap:url">
                    <tr>
                      <td><a href="{sitemap:loc}"><xsl:value-of select="sitemap:loc"/></a></td>
                      <td><xsl:value-of select="sitemap:lastmod"/></td>
                    </tr>
                  </xsl:for-each>
                </tbody>
              </table>
            </xsl:otherwise>
          </xsl:choose>
        </div>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
