'use client'

/**
 * Audit Export Wizard
 *
 * Features:
 * - Export type selection
 * - Scope filtering (regulations, domains)
 * - Export generation
 * - Download
 * - Export history
 */

import Link from 'next/link'
import AdminLayout from '@/components/admin/AdminLayout'
import { useExport } from './_components/useExport'
import ExportWizard from './_components/ExportWizard'
import ExportHistory from './_components/ExportHistory'

export default function ExportPage() {
  const exp = useExport()

  return (
    <AdminLayout title="Audit Export" description="Export fuer externe Pruefer">
      {/* Header */}
      <div className="flex flex-wrap items-center gap-4 mb-6">
        <Link
          href="/admin/compliance"
          className="text-sm text-slate-500 hover:text-slate-700 flex items-center gap-1"
        >
          <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 19l-7-7m0 0l7-7m-7 7h18" />
          </svg>
          Zurueck
        </Link>
      </div>

      {exp.loading ? (
        <div className="flex items-center justify-center h-64">
          <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600" />
        </div>
      ) : (
        <div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
          <ExportWizard
            wizardStep={exp.wizardStep}
            setWizardStep={exp.setWizardStep}
            exportType={exp.exportType}
            setExportType={exp.setExportType}
            regulations={exp.regulations}
            selectedRegulations={exp.selectedRegulations}
            toggleRegulation={exp.toggleRegulation}
            selectedDomains={exp.selectedDomains}
            toggleDomain={exp.toggleDomain}
            generating={exp.generating}
            startExport={exp.startExport}
            currentExport={exp.currentExport}
            resetWizard={exp.resetWizard}
            downloadExport={exp.downloadExport}
          />
          <ExportHistory
            exports={exp.exports}
            downloadExport={exp.downloadExport}
          />
        </div>
      )}
    </AdminLayout>
  )
}
