'use client'

import { GCIResult } from '@/lib/sdk/gci/types'

export function AuditTab({ gci }: { gci: GCIResult }) {
  return (
    <div className="space-y-6">
      <div className="bg-white rounded-xl border border-gray-200 p-6">
        <h3 className="text-base font-semibold text-gray-900 mb-4">
          Audit Trail - Berechnung GCI {gci.gci_score.toFixed(1)}
        </h3>
        <p className="text-sm text-gray-500 mb-4">
          Jeder Schritt der GCI-Berechnung ist nachvollziehbar und prueffaehig dokumentiert.
        </p>
        <div className="space-y-2">
          {gci.audit_trail.map((entry, i) => (
            <div key={i} className="flex items-start gap-3 p-3 border border-gray-100 rounded-lg">
              <div className={`flex-shrink-0 w-2 h-2 rounded-full mt-1.5 ${
                entry.impact === 'positive' ? 'bg-green-500' :
                entry.impact === 'negative' ? 'bg-red-500' :
                'bg-gray-400'
              }`} />
              <div className="flex-1 min-w-0">
                <div className="flex items-center justify-between">
                  <span className="text-sm font-medium text-gray-900">{entry.factor}</span>
                  <span className={`text-sm font-mono ${
                    entry.impact === 'positive' ? 'text-green-600' :
                    entry.impact === 'negative' ? 'text-red-600' :
                    'text-gray-600'
                  }`}>
                    {entry.value > 0 ? '+' : ''}{entry.value.toFixed(2)}
                  </span>
                </div>
                <p className="text-xs text-gray-500 mt-0.5">{entry.description}</p>
              </div>
            </div>
          ))}
        </div>
      </div>
    </div>
  )
}
