import type { Block } from 'payload'

/**
 * ShareButtonsBlock
 *
 * Social Sharing Buttons für Blog-Posts und andere Inhalte.
 * Unterstützt verschiedene Plattformen und Layouts.
 */
export const ShareButtonsBlock: Block = {
  slug: 'share-buttons-block',
  labels: {
    singular: 'Teilen-Buttons',
    plural: 'Teilen-Buttons',
  },
  imageURL: '/assets/blocks/share-buttons.png',
  fields: [
    {
      name: 'label',
      type: 'text',
      label: 'Label',
      localized: true,
      admin: {
        description: 'z.B. "Teilen:", "Artikel teilen" (optional)',
      },
    },
    // Plattformen
    {
      name: 'platforms',
      type: 'group',
      label: 'Plattformen',
      fields: [
        {
          name: 'facebook',
          type: 'checkbox',
          defaultValue: true,
          label: 'Facebook',
        },
        {
          name: 'twitter',
          type: 'checkbox',
          defaultValue: true,
          label: 'Twitter/X',
        },
        {
          name: 'linkedin',
          type: 'checkbox',
          defaultValue: true,
          label: 'LinkedIn',
        },
        {
          name: 'xing',
          type: 'checkbox',
          defaultValue: false,
          label: 'Xing',
        },
        {
          name: 'whatsapp',
          type: 'checkbox',
          defaultValue: true,
          label: 'WhatsApp',
        },
        {
          name: 'telegram',
          type: 'checkbox',
          defaultValue: false,
          label: 'Telegram',
        },
        {
          name: 'email',
          type: 'checkbox',
          defaultValue: true,
          label: 'E-Mail',
        },
        {
          name: 'copy',
          type: 'checkbox',
          defaultValue: true,
          label: 'Link kopieren',
        },
        {
          name: 'print',
          type: 'checkbox',
          defaultValue: false,
          label: 'Drucken',
        },
        {
          name: 'pinterest',
          type: 'checkbox',
          defaultValue: false,
          label: 'Pinterest',
        },
        {
          name: 'reddit',
          type: 'checkbox',
          defaultValue: false,
          label: 'Reddit',
        },
      ],
    },
    // Layout
    {
      name: 'layout',
      type: 'select',
      defaultValue: 'horizontal',
      label: 'Layout',
      options: [
        { label: 'Horizontal', value: 'horizontal' },
        { label: 'Vertikal', value: 'vertical' },
        { label: 'Floating (Seitenrand)', value: 'floating' },
        { label: 'Sticky (unten)', value: 'sticky' },
      ],
    },
    {
      name: 'align',
      type: 'select',
      defaultValue: 'left',
      label: 'Ausrichtung',
      options: [
        { label: 'Links', value: 'left' },
        { label: 'Mitte', value: 'center' },
        { label: 'Rechts', value: 'right' },
      ],
      admin: {
        condition: (_, siblingData) =>
          siblingData?.layout === 'horizontal' || siblingData?.layout === 'vertical',
      },
    },
    {
      name: 'floatSide',
      type: 'select',
      defaultValue: 'left',
      label: 'Seite',
      options: [
        { label: 'Links', value: 'left' },
        { label: 'Rechts', value: 'right' },
      ],
      admin: {
        condition: (_, siblingData) => siblingData?.layout === 'floating',
      },
    },
    // Styling
    {
      name: 'style',
      type: 'group',
      label: 'Darstellung',
      fields: [
        {
          name: 'variant',
          type: 'select',
          defaultValue: 'filled',
          label: 'Button-Stil',
          options: [
            { label: 'Gefüllt', value: 'filled' },
            { label: 'Outline', value: 'outline' },
            { label: 'Nur Icon', value: 'icon' },
            { label: 'Minimal', value: 'minimal' },
          ],
        },
        {
          name: 'size',
          type: 'select',
          defaultValue: 'md',
          label: 'Größe',
          options: [
            { label: 'Klein', value: 'sm' },
            { label: 'Mittel', value: 'md' },
            { label: 'Groß', value: 'lg' },
          ],
        },
        {
          name: 'shape',
          type: 'select',
          defaultValue: 'rounded',
          label: 'Form',
          options: [
            { label: 'Eckig', value: 'square' },
            { label: 'Abgerundet', value: 'rounded' },
            { label: 'Rund', value: 'circle' },
            { label: 'Pill', value: 'pill' },
          ],
        },
        {
          name: 'colorScheme',
          type: 'select',
          defaultValue: 'brand',
          label: 'Farbschema',
          options: [
            { label: 'Plattform-Farben', value: 'brand' },
            { label: 'Einheitlich (Grau)', value: 'gray' },
            { label: 'Einheitlich (Dunkel)', value: 'dark' },
            { label: 'Einheitlich (Hell)', value: 'light' },
            { label: 'Theme-Akzent', value: 'accent' },
          ],
        },
        {
          name: 'gap',
          type: 'select',
          defaultValue: '8',
          label: 'Abstand',
          options: [
            { label: 'Kein Abstand', value: '0' },
            { label: 'Klein (4px)', value: '4' },
            { label: 'Normal (8px)', value: '8' },
            { label: 'Groß (12px)', value: '12' },
          ],
        },
        {
          name: 'showLabel',
          type: 'checkbox',
          defaultValue: false,
          label: 'Plattform-Namen anzeigen',
        },
        {
          name: 'showCount',
          type: 'checkbox',
          defaultValue: false,
          label: 'Share-Zähler anzeigen',
          admin: {
            description: 'Zeigt Anzahl der Shares (sofern verfügbar)',
          },
        },
      ],
    },
    // Verhalten
    {
      name: 'behavior',
      type: 'group',
      label: 'Verhalten',
      fields: [
        {
          name: 'openInPopup',
          type: 'checkbox',
          defaultValue: true,
          label: 'In Popup öffnen',
          admin: {
            description: 'Share-Dialoge in kleinem Popup statt neuem Tab',
          },
        },
        {
          name: 'useNativeShare',
          type: 'checkbox',
          defaultValue: true,
          label: 'Native Share API nutzen',
          admin: {
            description: 'Auf mobilen Geräten den System-Share-Dialog verwenden',
          },
        },
        {
          name: 'copyFeedback',
          type: 'text',
          label: 'Kopiert-Feedback',
          localized: true,
          defaultValue: 'Link kopiert!',
          admin: {
            description: 'Text der angezeigt wird nach dem Kopieren',
          },
        },
      ],
    },
    // Share-Inhalt
    {
      name: 'content',
      type: 'group',
      label: 'Share-Inhalt',
      admin: {
        description: 'Überschreibt automatische Werte (optional)',
      },
      fields: [
        {
          name: 'customTitle',
          type: 'text',
          label: 'Titel',
          localized: true,
          admin: {
            description: 'Leer lassen für automatischen Seitentitel',
          },
        },
        {
          name: 'customDescription',
          type: 'textarea',
          label: 'Beschreibung',
          localized: true,
          admin: {
            description: 'Leer lassen für automatische Meta-Description',
          },
        },
        {
          name: 'hashtags',
          type: 'text',
          label: 'Hashtags',
          admin: {
            description: 'Komma-getrennt, ohne # (z.B. "blog,news,tech")',
          },
        },
        {
          name: 'via',
          type: 'text',
          label: 'Twitter Via',
          admin: {
            description: 'Twitter-Handle ohne @ (z.B. "c2sgmbh")',
          },
        },
      ],
    },
  ],
}
