<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
    <xsl:template match="/">
        <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
        <head>
            <title>Sitemap - L&#039;Essencce Ayurveda</title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
            <style><![CDATA[
                *, *::before, *::after { box-sizing: border-box; }
                body {
                    margin: 0;
                    padding: 0;
                    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
                    background: #f0f4f8;
                    color: #1a2332;
                    min-height: 100vh;
                }
                .header {
                    background: linear-gradient(135deg, #2d5a27 0%, #4a7c45 50%, #6b9e5e 100%);
                    color: white;
                    padding: 40px 24px;
                    text-align: center;
                }
                .header h1 {
                    margin: 0 0 8px 0;
                    font-size: 32px;
                    font-weight: 700;
                    letter-spacing: -0.5px;
                }
                .header p {
                    margin: 0;
                    font-size: 15px;
                    opacity: 0.85;
                }
                .header .stats {
                    margin-top: 20px;
                    display: inline-flex;
                    gap: 12px;
                    flex-wrap: wrap;
                    justify-content: center;
                }
                .stat-pill {
                    background: rgba(255,255,255,0.2);
                    border: 1px solid rgba(255,255,255,0.3);
                    border-radius: 50px;
                    padding: 6px 18px;
                    font-size: 14px;
                    font-weight: 600;
                }
                .container {
                    max-width: 1300px;
                    margin: 0 auto;
                    padding: 32px 20px;
                }
                .card {
                    background: #ffffff;
                    border-radius: 16px;
                    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
                    overflow: hidden;
                    border: 1px solid #e8edf2;
                }
                .table-wrap {
                    overflow-x: auto;
                }
                table {
                    width: 100%;
                    border-collapse: collapse;
                    font-size: 14px;
                }
                thead tr {
                    background: #f7f9fb;
                }
                th {
                    padding: 14px 18px;
                    text-align: left;
                    font-weight: 600;
                    font-size: 12px;
                    color: #64748b;
                    text-transform: uppercase;
                    letter-spacing: 0.6px;
                    border-bottom: 2px solid #e8edf2;
                    white-space: nowrap;
                }
                td {
                    padding: 14px 18px;
                    border-bottom: 1px solid #f0f4f8;
                    vertical-align: top;
                    line-height: 1.5;
                }
                tr:last-child td { border-bottom: none; }
                tbody tr:hover td { background: #fafcfe; }
                .url-link {
                    color: #2563eb;
                    text-decoration: none;
                    font-weight: 500;
                    word-break: break-all;
                    font-size: 13.5px;
                }
                .url-link:hover { text-decoration: underline; }
                .badge {
                    display: inline-block;
                    font-size: 11px;
                    font-weight: 600;
                    padding: 3px 9px;
                    border-radius: 6px;
                    margin: 2px 3px 2px 0;
                    border: 1px solid transparent;
                    white-space: nowrap;
                }
                .badge-en {
                    background: #dbeafe;
                    color: #1e40af;
                    border-color: #bfdbfe;
                }
                .badge-fr {
                    background: #fce7f3;
                    color: #9d174d;
                    border-color: #fbcfe8;
                }
                .badge-default {
                    background: #ecfdf5;
                    color: #065f46;
                    border-color: #a7f3d0;
                }
                .badge-generic {
                    background: #f1f5f9;
                    color: #475569;
                    border-color: #e2e8f0;
                }
                .freq-badge {
                    display: inline-block;
                    background: #f0fdf4;
                    color: #166534;
                    border: 1px solid #bbf7d0;
                    border-radius: 6px;
                    padding: 3px 10px;
                    font-size: 12px;
                    font-weight: 600;
                }
                .priority-high { color: #15803d; font-weight: 700; }
                .priority-med { color: #b45309; font-weight: 600; }
                .priority-low { color: #6b7280; }
                .footer {
                    text-align: center;
                    padding: 24px;
                    font-size: 13px;
                    color: #94a3b8;
                }
                .footer a { color: #2563eb; text-decoration: none; }
            ]]></style>
        </head>
        <body>
            <div class="header">
                <h1>&#127807; XML Sitemap</h1>
                <p>L&#039;Essencce Ayurveda — Structured site index for search engines</p>
                <div class="stats">
                    <span class="stat-pill">
                        <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/>&#160;Total URLs
                    </span>
                </div>
            </div>
            <div class="container">
                <div class="card">
                    <div class="table-wrap">
                        <table>
                            <thead>
                                <tr>
                                    <th>&#35;</th>
                                    <th>URL</th>
                                    <!-- <th>Alternate Languages (hreflang)</th> -->
                                    <th>Frequency</th>
                                    <th>Priority</th>
                                </tr>
                            </thead>
                            <tbody>
                                <xsl:for-each select="sitemap:urlset/sitemap:url">
                                    <tr>
                                        <td style="color:#94a3b8;font-size:12px;width:40px;">
                                            <xsl:value-of select="position()"/>
                                        </td>
                                        <td>
                                            <a class="url-link">
                                                <xsl:attribute name="href">
                                                    <xsl:value-of select="sitemap:loc"/>
                                                </xsl:attribute>
                                                <xsl:value-of select="sitemap:loc"/>
                                            </a>
                                        </td>
                                        <!-- <td>
                                            <xsl:for-each select="xhtml:link">
                                                <xsl:choose>
                                                    <xsl:when test="contains(@hreflang,'en')">
                                                        <span class="badge badge-en">
                                                            <xsl:value-of select="@hreflang"/>
                                                        </span>
                                                    </xsl:when>
                                                    <xsl:when test="contains(@hreflang,'fr')">
                                                        <span class="badge badge-fr">
                                                            <xsl:value-of select="@hreflang"/>
                                                        </span>
                                                    </xsl:when>
                                                    <xsl:when test="@hreflang='x-default'">
                                                        <span class="badge badge-default">x-default</span>
                                                    </xsl:when>
                                                    <xsl:otherwise>
                                                        <span class="badge badge-generic">
                                                            <xsl:value-of select="@hreflang"/>
                                                        </span>
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:for-each>
                                        </td> -->
                                        <td>
                                            <xsl:if test="sitemap:changefreq">
                                                <span class="freq-badge">
                                                    <xsl:value-of select="sitemap:changefreq"/>
                                                </span>
                                            </xsl:if>
                                        </td>
                                        <td>
                                            <xsl:choose>
                                                <xsl:when test="sitemap:priority &gt;= 0.8">
                                                    <span class="priority-high">
                                                        <xsl:value-of select="sitemap:priority"/>
                                                    </span>
                                                </xsl:when>
                                                <xsl:when test="sitemap:priority &gt;= 0.5">
                                                    <span class="priority-med">
                                                        <xsl:value-of select="sitemap:priority"/>
                                                    </span>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <span class="priority-low">
                                                        <xsl:value-of select="sitemap:priority"/>
                                                    </span>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </td>
                                    </tr>
                                </xsl:for-each>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="footer">
                    Generated dynamically &#183; <a href="https://www.sitemaps.org" target="_blank">Sitemap Protocol</a>
                </div>
            </div>
        </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
