<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
                xmlns:html="http://www.w3.org/TR/REC-html40"
                xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
                xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
                xmlns:xhtml="http://www.w3.org/1999/xhtml"
                xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>XML Sitemap — Solid Medya (v5.0 birleşik)</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style type="text/css">
          body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            font-size: 14px;
            color: #e0e0e0;
            background-color: #050505;
            margin: 0;
            padding: 40px;
          }
          a { color: #FFD700; text-decoration: none; transition: color 0.3s; }
          a:hover { color: #fff; text-decoration: underline; }
          h1 { font-size: 24px; font-weight: 700; margin: 0 0 12px 0; color: #fff; }
          .description { margin-bottom: 24px; color: #888; line-height: 1.6; max-width: 820px; }
          .badges { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
          .count-badge, .stat-badge {
            display: inline-block;
            padding: 6px 14px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
          }
          .count-badge { background: rgba(255,215,0,0.12); color: #FFD700; }
          .stat-badge { background: rgba(255,255,255,0.06); color: #aaa; border: 1px solid rgba(255,255,255,0.08); }
          .stat-badge strong { color: #fff; }
          table {
            border: none;
            border-collapse: collapse;
            width: 100%;
            background: rgba(255,255,255,0.03);
            border-radius: 8px;
            overflow: hidden;
          }
          th {
            text-align: left;
            padding: 14px 12px;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            color: #888;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 600;
          }
          td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: top; }
          tr:hover td { background-color: rgba(255,255,255,0.05); }
          .url-col { color: #fff; word-break: break-all; }
          .date-col { color: #aaa; white-space: nowrap; font-size: 12px; }
          .freq-col { color: #888; font-size: 12px; }
          .priority-col { color: #FFD700; font-weight: 600; }
          .tag {
            display: inline-block;
            padding: 2px 8px;
            margin: 2px 4px 2px 0;
            border-radius: 4px;
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
          }
          .tag-ai { background: rgba(126,200,227,0.15); color: #7ec8e3; }
          .tag-news { background: rgba(255,100,100,0.15); color: #ff8a8a; }
          .tag-img { background: rgba(255,215,0,0.12); color: #FFD700; }
          .extras-col { min-width: 100px; }
        </style>
      </head>
      <body>
        <h1>Solid Medya — Birleşik XML Site Haritası</h1>
        <div class="description">
          Tek dosyada HTML sayfalar, keşif meta URL'leri, AI <code>content_url</code> alternatifleri (<code>xhtml:link</code>)
          ve Google News (<code>news:news</code>) kayıtları.
          <a href="https://sitemaps.org" target="_blank" rel="noopener">sitemaps.org</a>
        </div>
        <div class="badges">
          <span class="count-badge">
            Toplam URL: <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/>
          </span>
          <span class="stat-badge">
            AI alternatif: <strong><xsl:value-of select="count(sitemap:urlset/sitemap:url[xhtml:link])"/></strong>
          </span>
          <span class="stat-badge">
            Google News: <strong><xsl:value-of select="count(sitemap:urlset/sitemap:url[news:news])"/></strong>
          </span>
          <span class="stat-badge">
            Görsel: <strong><xsl:value-of select="count(sitemap:urlset/sitemap:url[image:image])"/></strong>
          </span>
        </div>
        <table cellspacing="0">
          <thead>
            <tr>
              <th width="42%">URL</th>
              <th width="14%">Ekler</th>
              <th width="10%">Öncelik</th>
              <th width="12%">Sıklık</th>
              <th width="22%">Son güncelleme</th>
            </tr>
          </thead>
          <tbody>
            <xsl:for-each select="sitemap:urlset/sitemap:url">
              <tr>
                <td class="url-col">
                  <xsl:variable name="itemURL"><xsl:value-of select="sitemap:loc"/></xsl:variable>
                  <a href="{$itemURL}" target="_blank" rel="noopener"><xsl:value-of select="sitemap:loc"/></a>
                  <xsl:if test="news:news/news:title">
                    <div style="margin-top:6px;font-size:12px;color:#888;">
                      <xsl:value-of select="news:news/news:title"/>
                    </div>
                  </xsl:if>
                </td>
                <td class="extras-col">
                  <xsl:if test="xhtml:link"><span class="tag tag-ai">AI</span></xsl:if>
                  <xsl:if test="news:news"><span class="tag tag-news">News</span></xsl:if>
                  <xsl:if test="image:image"><span class="tag tag-img">IMG</span></xsl:if>
                </td>
                <td class="priority-col">
                  <xsl:value-of select="concat(format-number(sitemap:priority * 100, '0'), '%')"/>
                </td>
                <td class="freq-col"><xsl:value-of select="sitemap:changefreq"/></td>
                <td class="date-col">
                  <xsl:value-of select="concat(substring(sitemap:lastmod,1,10),' ',substring(sitemap:lastmod,12,5))"/>
                </td>
              </tr>
            </xsl:for-each>
          </tbody>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
