import type { Block } from 'payload'

/**
 * TeamFilterBlock
 *
 * Interaktive Team-Anzeige mit Filter- und Suchfunktion.
 * Ermöglicht Filterung nach Abteilung, Fachgebiet, Sprache.
 */
export const TeamFilterBlock: Block = {
  slug: 'team-filter-block',
  labels: {
    singular: 'Team mit Filter',
    plural: 'Team mit Filter',
  },
  imageURL: '/assets/blocks/team-filter.png',
  fields: [
    {
      name: 'title',
      type: 'text',
      label: 'Überschrift',
      localized: true,
      defaultValue: 'Unser Team',
    },
    {
      name: 'subtitle',
      type: 'textarea',
      label: 'Untertitel',
      localized: true,
    },
    // Filter-Optionen
    {
      name: 'filters',
      type: 'group',
      label: 'Filter-Optionen',
      fields: [
        {
          name: 'showSearch',
          type: 'checkbox',
          defaultValue: true,
          label: 'Suchfeld anzeigen',
        },
        {
          name: 'searchPlaceholder',
          type: 'text',
          label: 'Such-Platzhalter',
          localized: true,
          defaultValue: 'Team durchsuchen...',
          admin: {
            condition: (_, siblingData) => siblingData?.showSearch,
          },
        },
        {
          name: 'showDepartment',
          type: 'checkbox',
          defaultValue: true,
          label: 'Abteilungs-Filter',
        },
        {
          name: 'showSpecialization',
          type: 'checkbox',
          defaultValue: false,
          label: 'Fachgebiets-Filter',
        },
        {
          name: 'showLanguage',
          type: 'checkbox',
          defaultValue: false,
          label: 'Sprach-Filter',
        },
        {
          name: 'showHierarchy',
          type: 'checkbox',
          defaultValue: false,
          label: 'Hierarchie-Filter',
        },
        {
          name: 'filterLayout',
          type: 'select',
          defaultValue: 'horizontal',
          label: 'Filter-Layout',
          options: [
            { label: 'Horizontal (nebeneinander)', value: 'horizontal' },
            { label: 'Vertikal (Sidebar)', value: 'sidebar' },
            { label: 'Dropdown-Menü', value: 'dropdown' },
            { label: 'Tabs', value: 'tabs' },
          ],
        },
        {
          name: 'filterStyle',
          type: 'select',
          defaultValue: 'buttons',
          label: 'Filter-Stil',
          options: [
            { label: 'Buttons/Chips', value: 'buttons' },
            { label: 'Dropdown', value: 'select' },
            { label: 'Checkboxen', value: 'checkbox' },
          ],
          admin: {
            condition: (_, siblingData) =>
              siblingData?.filterLayout !== 'tabs' && siblingData?.filterLayout !== 'dropdown',
          },
        },
        {
          name: 'showResultCount',
          type: 'checkbox',
          defaultValue: true,
          label: 'Ergebnis-Anzahl anzeigen',
        },
        {
          name: 'showResetButton',
          type: 'checkbox',
          defaultValue: true,
          label: 'Filter-Reset-Button',
        },
      ],
    },
    // Anzeige-Optionen
    {
      name: 'display',
      type: 'group',
      label: 'Anzeige',
      fields: [
        {
          name: 'layout',
          type: 'select',
          defaultValue: 'grid',
          label: 'Layout',
          options: [
            { label: 'Grid', value: 'grid' },
            { label: 'Liste', value: 'list' },
            { label: 'Kompakt', value: 'compact' },
          ],
        },
        {
          name: 'columns',
          type: 'select',
          defaultValue: '3',
          label: 'Spalten',
          options: [
            { label: '2 Spalten', value: '2' },
            { label: '3 Spalten', value: '3' },
            { label: '4 Spalten', value: '4' },
          ],
          admin: {
            condition: (_, siblingData) => siblingData?.layout === 'grid',
          },
        },
        {
          name: 'initialLimit',
          type: 'number',
          defaultValue: 12,
          min: 4,
          max: 50,
          label: 'Initiale Anzahl',
        },
        {
          name: 'loadMore',
          type: 'select',
          defaultValue: 'button',
          label: 'Mehr laden',
          options: [
            { label: '"Mehr laden" Button', value: 'button' },
            { label: 'Infinite Scroll', value: 'infinite' },
            { label: 'Pagination', value: 'pagination' },
            { label: 'Alle anzeigen', value: 'all' },
          ],
        },
        {
          name: 'loadMoreText',
          type: 'text',
          label: 'Button-Text',
          localized: true,
          defaultValue: 'Mehr anzeigen',
          admin: {
            condition: (_, siblingData) => siblingData?.loadMore === 'button',
          },
        },
      ],
    },
    // Member-Card Optionen
    {
      name: 'card',
      type: 'group',
      label: 'Mitglieder-Karte',
      fields: [
        {
          name: 'showImage',
          type: 'checkbox',
          defaultValue: true,
          label: 'Foto anzeigen',
        },
        {
          name: 'imageStyle',
          type: 'select',
          defaultValue: 'circle',
          label: 'Foto-Stil',
          options: [
            { label: 'Rund', value: 'circle' },
            { label: 'Abgerundet', value: 'rounded' },
            { label: 'Quadratisch', value: 'square' },
          ],
          admin: {
            condition: (_, siblingData) => siblingData?.showImage,
          },
        },
        {
          name: 'showRole',
          type: 'checkbox',
          defaultValue: true,
          label: 'Position anzeigen',
        },
        {
          name: 'showDepartment',
          type: 'checkbox',
          defaultValue: true,
          label: 'Abteilung anzeigen',
        },
        {
          name: 'showBio',
          type: 'checkbox',
          defaultValue: false,
          label: 'Kurzbiografie anzeigen',
        },
        {
          name: 'showContact',
          type: 'checkbox',
          defaultValue: false,
          label: 'Kontaktdaten anzeigen',
        },
        {
          name: 'showSocial',
          type: 'checkbox',
          defaultValue: true,
          label: 'Social Links anzeigen',
        },
        {
          name: 'showSpecializations',
          type: 'checkbox',
          defaultValue: false,
          label: 'Fachgebiete als Tags',
        },
        {
          name: 'showLanguages',
          type: 'checkbox',
          defaultValue: false,
          label: 'Sprachen anzeigen',
        },
        {
          name: 'showVCard',
          type: 'checkbox',
          defaultValue: false,
          label: 'vCard-Download anzeigen',
        },
        {
          name: 'linkToProfile',
          type: 'checkbox',
          defaultValue: true,
          label: 'Zur Profilseite verlinken',
        },
        {
          name: 'profileBasePath',
          type: 'text',
          label: 'Profil-Basis-Pfad',
          defaultValue: '/team',
          admin: {
            condition: (_, siblingData) => siblingData?.linkToProfile,
            description: 'z.B. "/team" ergibt "/team/max-mustermann"',
          },
        },
        {
          name: 'enableModal',
          type: 'checkbox',
          defaultValue: false,
          label: 'Detail-Modal aktivieren',
          admin: {
            description: 'Klick öffnet Modal statt Profilseite',
          },
        },
      ],
    },
    // Styling
    {
      name: 'style',
      type: 'group',
      label: 'Darstellung',
      fields: [
        {
          name: 'bg',
          type: 'select',
          defaultValue: 'none',
          label: 'Hintergrund',
          options: [
            { label: 'Keiner', value: 'none' },
            { label: 'Hell', value: 'light' },
            { label: 'Dunkel', value: 'dark' },
          ],
        },
        {
          name: 'cardBg',
          type: 'select',
          defaultValue: 'white',
          label: 'Karten-Hintergrund',
          options: [
            { label: 'Weiß', value: 'white' },
            { label: 'Transparent', value: 'transparent' },
            { label: 'Hell', value: 'light' },
          ],
        },
        {
          name: 'cardShadow',
          type: 'checkbox',
          defaultValue: true,
          label: 'Karten-Schatten',
        },
        {
          name: 'cardHover',
          type: 'select',
          defaultValue: 'lift',
          label: 'Hover-Effekt',
          options: [
            { label: 'Keiner', value: 'none' },
            { label: 'Anheben', value: 'lift' },
            { label: 'Schatten verstärken', value: 'shadow' },
            { label: 'Rand hervorheben', value: 'border' },
          ],
        },
        {
          name: 'gap',
          type: 'select',
          defaultValue: '24',
          label: 'Abstand',
          options: [
            { label: 'Klein (16px)', value: '16' },
            { label: 'Normal (24px)', value: '24' },
            { label: 'Groß (32px)', value: '32' },
          ],
        },
        {
          name: 'animation',
          type: 'select',
          defaultValue: 'fade',
          label: 'Filter-Animation',
          options: [
            { label: 'Keine', value: 'none' },
            { label: 'Fade', value: 'fade' },
            { label: 'Slide', value: 'slide' },
            { label: 'Scale', value: 'scale' },
          ],
        },
      ],
    },
    // Empty State
    {
      name: 'emptyState',
      type: 'group',
      label: 'Keine Ergebnisse',
      fields: [
        {
          name: 'title',
          type: 'text',
          label: 'Überschrift',
          localized: true,
          defaultValue: 'Keine Mitarbeiter gefunden',
        },
        {
          name: 'message',
          type: 'textarea',
          label: 'Nachricht',
          localized: true,
          defaultValue: 'Versuchen Sie andere Filterkriterien.',
        },
        {
          name: 'showResetButton',
          type: 'checkbox',
          defaultValue: true,
          label: 'Filter-Reset anzeigen',
        },
      ],
    },
  ],
}
