import type { CollectionConfig } from 'payload'
import {
  HeroBlock,
  HeroSliderBlock,
  ImageSliderBlock,
  TextBlock,
  ImageTextBlock,
  CardGridBlock,
  QuoteBlock,
  CTABlock,
  ContactFormBlock,
  TimelineBlock,
  DividerBlock,
  VideoBlock,
  // Neue Blocks
  PostsListBlock,
  TestimonialsBlock,
  NewsletterBlock,
  ProcessStepsBlock,
  FAQBlock,
  TeamBlock,
  ServicesBlock,
  // Blogging Blocks
  AuthorBioBlock,
  RelatedPostsBlock,
  ShareButtonsBlock,
  TableOfContentsBlock,
  // Team Blocks
  TeamFilterBlock,
  OrgChartBlock,
  // New Feature Blocks
  LocationsBlock,
  LogoGridBlock,
  StatsBlock,
  JobsBlock,
  DownloadsBlock,
  MapBlock,
  // Events & Interactive Blocks
  EventsBlock,
  PricingBlock,
  TabsBlock,
  AccordionBlock,
  ComparisonBlock,
  // Tenant-specific Blocks
  BeforeAfterBlock,
  // BlogWoman Blocks
  FavoritesBlock,
  SeriesBlock,
  SeriesDetailBlock,
  VideoEmbedBlock,
  FeaturedContentBlock,
} from '../blocks'
import { pagesAccess } from '../lib/access'

export const Pages: CollectionConfig = {
  slug: 'pages',
  admin: {
    useAsTitle: 'title',
    defaultColumns: ['title', 'slug', 'status', 'updatedAt'],
  },
  access: pagesAccess,
  fields: [
    {
      name: 'title',
      type: 'text',
      required: true,
      localized: true,
    },
    {
      name: 'slug',
      type: 'text',
      required: true,
      localized: true,
      unique: false, // Uniqueness per locale handled by index
      admin: {
        description: 'URL-Pfad (z.B. "ueber-uns" / "about-us")',
      },
    },
    {
      name: 'layout',
      type: 'blocks',
      label: 'Seiteninhalt',
      blocks: [
        // Bestehende Blocks
        HeroBlock,
        HeroSliderBlock,
        ImageSliderBlock,
        TextBlock,
        ImageTextBlock,
        CardGridBlock,
        QuoteBlock,
        CTABlock,
        ContactFormBlock,
        TimelineBlock,
        DividerBlock,
        VideoBlock,
        // Neue Blocks
        PostsListBlock,
        TestimonialsBlock,
        NewsletterBlock,
        ProcessStepsBlock,
        FAQBlock,
        TeamBlock,
        ServicesBlock,
        // Blogging Blocks
        AuthorBioBlock,
        RelatedPostsBlock,
        ShareButtonsBlock,
        TableOfContentsBlock,
        // Team Blocks
        TeamFilterBlock,
        OrgChartBlock,
        // New Feature Blocks
        LocationsBlock,
        LogoGridBlock,
        StatsBlock,
        JobsBlock,
        DownloadsBlock,
        MapBlock,
        // Events & Interactive Blocks
        EventsBlock,
        PricingBlock,
        TabsBlock,
        AccordionBlock,
        ComparisonBlock,
        // Tenant-specific Blocks
        BeforeAfterBlock,
        // BlogWoman Blocks
        FavoritesBlock,
        SeriesBlock,
        SeriesDetailBlock,
        VideoEmbedBlock,
        FeaturedContentBlock,
      ],
    },
    {
      name: 'seo',
      type: 'group',
      label: 'SEO',
      fields: [
        {
          name: 'metaTitle',
          type: 'text',
          label: 'Meta-Titel',
          localized: true,
        },
        {
          name: 'metaDescription',
          type: 'textarea',
          label: 'Meta-Beschreibung',
          localized: true,
        },
        {
          name: 'ogImage',
          type: 'upload',
          relationTo: 'media',
          label: 'Social Media Bild',
        },
      ],
    },
    {
      name: 'status',
      type: 'select',
      defaultValue: 'draft',
      options: [
        { label: 'Entwurf', value: 'draft' },
        { label: 'Veröffentlicht', value: 'published' },
      ],
    },
    {
      name: 'publishedAt',
      type: 'date',
    },
  ],
}
