<template>
  <section id="content-privacy">
    <Card class="p-6">
      <div class="flex items-start justify-between gap-4">
        <div>
          <p class="text-xs font-semibold uppercase tracking-[0.24em] text-violet-500">Rechtstexte</p>
          <h2 class="mt-1 text-xl font-bold text-slate-900">Datenschutzerklärung</h2>
          <p class="mt-2 text-sm leading-6 text-slate-500">Großes Textfeld für den kompletten Inhalt. Die Landingpage übernimmt denselben Text.</p>
        </div>
        <div class="flex shrink-0 flex-col items-end gap-3">
          <ShieldCheck class="h-6 w-6 text-violet-500" />
          <div class="flex flex-wrap justify-end gap-2">
            <Button variant="ghost" size="sm" class="gap-2 rounded-2xl border border-violet-200 bg-violet-50 px-4 text-violet-700 shadow-none hover:bg-violet-100" @click="$emit('open-preview')">
              <Eye class="h-4 w-4" />
              Preview öffnen
            </Button>
            <Button :disabled="saving" size="sm" class="gap-2 rounded-2xl bg-gradient-to-r from-violet-600 to-fuchsia-500 shadow-violet-500/20" @click="onSave">
              <Save class="h-4 w-4" />
              {{ saving ? 'Speichert ...' : 'Datenschutz speichern' }}
            </Button>
          </div>
        </div>
      </div>
      <div class="mt-5 grid gap-4 sm:grid-cols-2">
        <div class="rounded-[24px] border border-violet-100 bg-gradient-to-br from-violet-50 via-white to-[#f8eefb] p-4">
          <p class="text-[11px] font-semibold uppercase tracking-[0.22em] text-slate-500">Aktualisiert von</p>
          <p class="mt-2 text-lg font-semibold text-violet-900">{{ updatedBy || 'Unbekannt' }}</p>
        </div>
        <div class="rounded-[24px] border border-violet-100 bg-white p-4">
          <p class="text-[11px] font-semibold uppercase tracking-[0.22em] text-slate-500">Zeitpunkt</p>
          <p class="mt-2 text-lg font-semibold text-slate-900">{{ updatedLabel }}</p>
        </div>
      </div>
      <label class="mt-6 block space-y-2">
        <span class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-500">Datenschutz E-Mail</span>
        <input v-model="form.privacyEmail" type="email" placeholder="datenschutz@..." class="h-12 w-full rounded-2xl border border-violet-200 bg-white px-4 text-sm outline-none transition focus:border-violet-400 focus:ring-4 focus:ring-violet-100" />
      </label>
      <AdminRichTextEditor
        v-model="form.privacyPolicyContent"
        class="mt-4"
        label="Datenschutz Inhalt"
        placeholder="Datenschutztext..."
        min-height-class="min-h-[560px]"
      />
    </Card>
  </section>
</template>

<script setup lang="ts">
import { Eye, Save, ShieldCheck } from '@lucide/vue'

import Button from '../ui/Button.vue'
import Card from '../ui/Card.vue'
import AdminRichTextEditor from './AdminRichTextEditor.vue'
import type { AdminContentForm } from './adminContentTypes'

const props = defineProps<{
  form: AdminContentForm
  saving: boolean
  updatedBy: string | null
  updatedLabel: string
  saveSiteSettings: (sectionLabel?: string) => Promise<void>
}>()

defineEmits<{
  'open-preview': []
}>()

function onSave() {
  return props.saveSiteSettings('Datenschutzerklärung')
}
</script>
