<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" encoding="UTF-8"/>
  <xsl:template match="/">
    <html>
      <head>
        <title>Library table via XSLT</title>
        <style>
          body {
            margin: 0;
            padding: 18px;
            font-family: system-ui, sans-serif;
            background: linear-gradient(135deg, #111827, #1f2937);
            color: #f9fafb;
          }
          h1 { margin: 0 0 14px; color: #ffc107; font-size: 20px; }
          table {
            width: 100%;
            border-collapse: collapse;
            overflow: hidden;
            border-radius: 10px;
            background: #0f172a;
            box-shadow: 0 10px 24px rgba(0, 0, 0, .25);
          }
          th, td { padding: 10px 12px; text-align: left; }
          th { background: #334155; color: #ffc107; font-size: 12px; text-transform: uppercase; }
          tr:nth-child(even) td { background: #172033; }
          tr:nth-child(odd) td { background: #111827; }
          .available { color: #6abf69; font-weight: 700; }
          .checked { color: #fca5a5; font-weight: 700; }
        </style>
      </head>
      <body>
        <h1>Library table generated by XSLT</h1>
        <table>
          <thead>
            <tr>
              <th>ID</th>
              <th>Title</th>
              <th>Author</th>
              <th>Year</th>
              <th>Status</th>
            </tr>
          </thead>
          <tbody>
            <xsl:for-each select="library/book">
              <tr>
                <td><xsl:value-of select="@id"/></td>
                <td><xsl:value-of select="title"/></td>
                <td><xsl:value-of select="author"/></td>
                <td><xsl:value-of select="year"/></td>
                <td>
                  <xsl:attribute name="class">
                    <xsl:choose>
                      <xsl:when test="status='Available'">available</xsl:when>
                      <xsl:otherwise>checked</xsl:otherwise>
                    </xsl:choose>
                  </xsl:attribute>
                  <xsl:value-of select="status"/>
                </td>
              </tr>
            </xsl:for-each>
          </tbody>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
