<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>PeerCortex Report - AS{{asn}}</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      color: #333;
      line-height: 1.6;
      background: white;
    }
    .page {
      page-break-after: always;
      padding: 40px;
      min-height: 100vh;
    }
    .page:last-child {
      page-break-after: avoid;
    }
    h1 {
      font-size: 2.5em;
      margin-bottom: 0.5em;
      color: #1e40af;
    }
    h2 {
      font-size: 1.8em;
      margin-top: 1em;
      margin-bottom: 0.5em;
      color: #1e40af;
      border-bottom: 2px solid #e5e7eb;
      padding-bottom: 0.3em;
    }
    h3 {
      font-size: 1.3em;
      margin-top: 0.8em;
      margin-bottom: 0.4em;
      color: #374151;
    }
    .title-page {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      text-align: center;
      min-height: 100vh;
    }
    .title-page h1 {
      font-size: 3.5em;
      margin-bottom: 0.2em;
    }
    .title-page .subtitle {
      font-size: 1.5em;
      color: #6b7280;
      margin-bottom: 2em;
    }
    .title-page .date {
      color: #9ca3af;
      font-size: 1em;
    }
    .score-card {
      background: #f3f4f6;
      border-left: 4px solid #3b82f6;
      padding: 20px;
      margin: 20px 0;
      border-radius: 4px;
    }
    .score-card .label {
      font-size: 0.9em;
      color: #6b7280;
      margin-bottom: 5px;
    }
    .score-card .value {
      font-size: 2em;
      font-weight: bold;
      color: #1e40af;
    }
    .score-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 15px;
      margin: 20px 0;
    }
    .metric {
      background: #f9fafb;
      padding: 15px;
      border-radius: 4px;
      border: 1px solid #e5e7eb;
    }
    .metric .name {
      font-weight: bold;
      color: #374151;
      margin-bottom: 5px;
    }
    .metric .value {
      font-size: 1.5em;
      color: #1e40af;
    }
    .section {
      margin-bottom: 30px;
    }
    .recommendation {
      background: #fffbeb;
      border-left: 4px solid #f59e0b;
      padding: 15px;
      margin: 10px 0;
      border-radius: 4px;
    }
    .recommendation .title {
      font-weight: bold;
      color: #d97706;
    }
    .footer {
      margin-top: 40px;
      padding-top: 20px;
      border-top: 1px solid #e5e7eb;
      font-size: 0.85em;
      color: #9ca3af;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin: 20px 0;
    }
    th, td {
      border-bottom: 1px solid #e5e7eb;
      padding: 12px;
      text-align: left;
    }
    th {
      background: #f3f4f6;
      font-weight: bold;
      color: #1e40af;
    }
    tr:nth-child(even) {
      background: #f9fafb;
    }
  </style>
</head>
<body>
  <div class="page title-page">
    <h1>PeerCortex Analysis Report</h1>
    <div class="subtitle">Autonomous System AS{{asn}}</div>
    <div class="subtitle">{{networkName}}</div>
    <div class="date">Generated: {{generatedAt}}</div>
  </div>

  <div class="page">
    <h2>Executive Summary</h2>
    <div class="score-card">
      <div class="label">Overall Health Score</div>
      <div class="value">{{healthScore.overall}}/100</div>
    </div>
    <p style="margin: 20px 0;">This comprehensive report evaluates the network health and security posture of AS{{asn}} ({{networkName}}). The analysis covers ASPA adoption, RPKI compliance, BGP stability, peering relationships, and identified security threats.</p>
  </div>

  <div class="page">
    <h2>Health Metrics</h2>
    <div class="score-grid">
      <div class="metric">
        <div class="name">ASPA Adoption</div>
        <div class="value">{{healthScore.aspa}}/100</div>
      </div>
      <div class="metric">
        <div class="name">RPKI Compliance</div>
        <div class="value">{{healthScore.rpki}}/100</div>
      </div>
      <div class="metric">
        <div class="name">BGP Stability</div>
        <div class="value">{{healthScore.bgp_stability}}/100</div>
      </div>
      <div class="metric">
        <div class="name">Peering Health</div>
        <div class="value">{{healthScore.peering_health}}/100</div>
      </div>
    </div>
  </div>

  <div class="page">
    <h2>ASPA Status</h2>
    <h3>Adoption</h3>
    <p>Current Status: <strong>{{aspa.adoption_status}}</strong></p>
    <h3>Provider Verification</h3>
    <p>Provider verification readiness: {{aspa.provider_verification}}%</p>
    <h3>Readiness Score</h3>
    <p>Overall ASPA implementation readiness: {{aspa.readiness_score}}/100</p>
  </div>

  <div class="page">
    <h2>Peering Analysis</h2>
    <h3>Network Connections</h3>
    <table>
      <tr>
        <th>Metric</th>
        <th>Value</th>
      </tr>
      <tr>
        <td>IXP Connections</td>
        <td>{{peering.ixp_connections}}</td>
      </tr>
      <tr>
        <td>Peer Count</td>
        <td>{{peering.peer_count}}</td>
      </tr>
      <tr>
        <td>Open Peers</td>
        <td>{{peering.open_peers}}</td>
      </tr>
      <tr>
        <td>Route Exports</td>
        <td>{{peering.route_exports}}</td>
      </tr>
    </table>
  </div>

  <div class="page">
    <h2>Security Threats</h2>
    <div class="score-grid">
      <div class="metric">
        <div class="name">Recent Hijacks</div>
        <div class="value">{{threats.recent_hijacks}}</div>
      </div>
      <div class="metric">
        <div class="name">Anomalies Detected</div>
        <div class="value">{{threats.anomalies_detected}}</div>
      </div>
      <div class="metric">
        <div class="name">RPKI Invalids</div>
        <div class="value">{{threats.rpki_invalids}}</div>
      </div>
      <div class="metric">
        <div class="name">MOAS Events</div>
        <div class="value">{{threats.moas_events}}</div>
      </div>
    </div>
  </div>

  <div class="page">
    <h2>Recommendations</h2>
    {{#each recommendations}}
    <div class="recommendation">
      <div class="title">{{this}}</div>
    </div>
    {{/each}}
  </div>

  <div class="page">
    <h2>Data Provenance</h2>
    <p>This report was generated using the following data sources:</p>
    <ul style="margin-left: 20px; margin-top: 15px;">
      {{#each dataSources}}
      <li>{{this}}</li>
      {{/each}}
    </ul>
    <div class="footer">
      <p>Report generated by PeerCortex on {{generatedAt}}</p>
      <p>All data is sourced from publicly available BGP routing information, RPKI repositories, and network databases.</p>
    </div>
  </div>
</body>
</html>
