'use client'

import React from 'react'
import type { StepProps } from '../_types'
import { RETENTION_TILES } from '../_tiles'

export function Step7Retention({ form, updateForm }: StepProps) {
  return (
    <div className="space-y-6">
      <h2 className="text-lg font-semibold text-gray-900">Datenhaltung & Aufbewahrung</h2>
      <p className="text-sm text-gray-500">Wie lange sollen die Daten gespeichert werden?</p>

      <div className="grid grid-cols-2 md:grid-cols-4 gap-3">
        {RETENTION_TILES.map(item => (
          <button
            key={item.value}
            type="button"
            onClick={() => updateForm({ retention_period: item.value })}
            className={`p-3 rounded-xl border-2 text-left transition-all ${
              form.retention_period === item.value
                ? 'border-purple-500 bg-purple-50 ring-1 ring-purple-300'
                : 'border-gray-200 hover:border-purple-300 hover:bg-gray-50'
            }`}
          >
            <div className="flex items-center gap-2 mb-1">
              <span className="text-lg">{item.icon}</span>
              <span className="text-sm font-medium text-gray-900">{item.label}</span>
            </div>
            <p className="text-xs text-gray-500 leading-tight">{item.desc}</p>
          </button>
        ))}
      </div>

      <div>
        <label className="block text-sm font-medium text-gray-700 mb-1">
          Zweck der Aufbewahrung (optional)
        </label>
        <textarea
          value={form.retention_purpose}
          onChange={e => updateForm({ retention_purpose: e.target.value })}
          rows={2}
          placeholder="z.B. Vertragliche Pflichten, gesetzliche Aufbewahrungsfristen..."
          className="w-full px-4 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent"
        />
      </div>

      {form.retention_period === 'indefinite' && (
        <div className="bg-amber-50 border border-amber-200 rounded-lg p-4 text-sm text-amber-800">
          <div className="font-medium mb-1">Hinweis: Unbefristete Speicherung</div>
          <p>Die DSGVO fordert Datenminimierung und Speicherbegrenzung (Art. 5 Abs. 1e). Unbefristete Speicherung muss besonders gut begruendet sein.</p>
        </div>
      )}
    </div>
  )
}
