<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>AASD — Consultant Dashboard</title>
  <script src="https://cdn.tailwindcss.com/"></script>
  <style>
    * { -webkit-tap-highlight-color: transparent; }
    body { overscroll-behavior: none; }
  </style>
</head>
<body class="bg-slate-900 text-slate-100 p-4 md:p-8">
  <div class="max-w-6xl mx-auto">
    <header class="text-center mb-8">
      <h1 class="text-3xl md:text-4xl font-extrabold bg-gradient-to-r from-blue-400 to-purple-400 bg-clip-text text-transparent">AASD Dashboard</h1>
      <p class="text-sm text-slate-400 mt-1">API Attack Surface Discovery — Consultant View</p>
      <p class="text-xs text-slate-500 mt-1">Version 2026-04.1 | GITEX 2026</p>
    </header>

    <!-- Stats -->
    <div class="grid grid-cols-3 gap-3 md:gap-4 mb-6">
      <div class="bg-slate-800 rounded-xl p-4 text-center border-l-4 border-blue-500">
        <div class="text-2xl md:text-3xl font-bold text-blue-400">{{ .Total }}</div>
        <div class="text-xs text-slate-400 uppercase tracking-wider mt-1">Total Scans</div>
      </div>
      <div class="bg-slate-800 rounded-xl p-4 text-center border-l-4 border-green-500">
        <div class="text-2xl md:text-3xl font-bold text-green-400">{{ .Completed }}</div>
        <div class="text-xs text-slate-400 uppercase tracking-wider mt-1">Completed</div>
      </div>
      <div class="bg-slate-800 rounded-xl p-4 text-center border-l-4 border-purple-500">
        <div class="text-2xl md:text-3xl font-bold text-purple-400">{{ .Running }}</div>
        <div class="text-xs text-slate-400 uppercase tracking-wider mt-1">In Progress</div>
      </div>
    </div>

    <!-- Results Table -->
    {{ if .Results }}
    <div class="bg-slate-800 rounded-2xl overflow-hidden border border-slate-700">
      <div class="overflow-x-auto">
        <table class="w-full text-sm">
          <thead class="bg-slate-700/50">
            <tr>
              <th class="p-3 text-left font-semibold text-slate-300">Domain</th>
              <th class="p-3 text-left font-semibold text-slate-300 hidden md:table-cell">Token</th>
              <th class="p-3 text-left font-semibold text-slate-300">Status</th>
              <th class="p-3 text-left font-semibold text-slate-300 hidden sm:table-cell">Subdomains</th>
              <th class="p-3 text-left font-semibold text-slate-300">Actions</th>
            </tr>
          </thead>
          <tbody class="divide-y divide-slate-700">
            {{ range .Results }}
            <tr class="hover:bg-slate-700/30 transition-colors">
              <td class="p-3 font-medium text-slate-200">{{ .Domain }}</td>
              <td class="p-3 text-xs font-mono text-slate-400 hidden md:table-cell">{{ .ReportToken }}</td>
              <td class="p-3">
                {{ if eq .Status "completed" }}
                <span class="inline-block px-2.5 py-0.5 rounded-full text-xs font-semibold bg-green-900/50 text-green-400 border border-green-700">Completed</span>
                {{ else if eq .Status "failed" }}
                <span class="inline-block px-2.5 py-0.5 rounded-full text-xs font-semibold bg-red-900/50 text-red-400 border border-red-700">Failed</span>
                {{ else if eq .Status "discovering" }}
                <span class="inline-block px-2.5 py-0.5 rounded-full text-xs font-semibold bg-blue-900/50 text-blue-400 border border-blue-700">Discovering</span>
                {{ else if eq .Status "scanning" }}
                <span class="inline-block px-2.5 py-0.5 rounded-full text-xs font-semibold bg-purple-900/50 text-purple-400 border border-purple-700">Scanning</span>
                {{ else if eq .Status "generating" }}
                <span class="inline-block px-2.5 py-0.5 rounded-full text-xs font-semibold bg-yellow-900/50 text-yellow-400 border border-yellow-700">Generating</span>
                {{ else }}
                <span class="inline-block px-2.5 py-0.5 rounded-full text-xs font-semibold bg-slate-700 text-slate-400">{{ .Status }}</span>
                {{ end }}
              </td>
              <td class="p-3 text-slate-400 hidden sm:table-cell">{{ len .Subdomains }}</td>
              <td class="p-3">
                {{ if .HasConsultantReport }}
                <a href="/reports/consultant_{{ .ReportToken }}.html" target="_blank" class="text-blue-400 hover:text-blue-300 text-xs font-medium underline underline-offset-2">Consultant Report</a>
                {{ else if eq .Status "completed" }}
                <span class="text-slate-500 text-xs">No WAF report (target unreachable)</span>
                {{ else }}
                <span class="text-slate-600 text-xs">Pending</span>
                {{ end }}
              </td>
            </tr>
            {{ end }}
          </tbody>
        </table>
      </div>
    </div>
    {{ else }}
    <div class="bg-slate-800 rounded-2xl p-8 text-center border border-slate-700">
      <p class="text-slate-400 text-lg mb-2">No scans yet</p>
      <p class="text-slate-500 text-sm">Scans appear here after booth visitors submit their domain.</p>
    </div>
    {{ end }}

    <footer class="mt-8 text-center text-xs text-slate-600">
      <p>AASD v2026-04.1 — Internal use only | <a href="/admin-dashboard" class="text-blue-500 hover:underline">Refresh</a></p>
      <p class="mt-1">GITEX 2026 — sechpoint.app</p>
    </footer>
  </div>
</body>
</html>
