<?php

namespace App\Filament\Resources\Posts\Schemas;

use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class PostForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            Section::make('Beitrag')->schema([
                TextInput::make('title')->label('Titel')->required()->maxLength(180),
                TextInput::make('slug')->label('URL-Kürzel')->required()->unique(ignoreRecord: true)->alphaDash(),
                TextInput::make('category')->label('Kategorie')->maxLength(100),
                Textarea::make('excerpt')->label('Kurzbeschreibung')->rows(3)->maxLength(600)->columnSpanFull(),
                RichEditor::make('body')->label('Beitragstext')->columnSpanFull(),
                SpatieMediaLibraryFileUpload::make('hero_media')->label('Beitragsbild')->collection('hero')->image()->imageEditor()->columnSpanFull(),
            ])->columns(2),
            Section::make('Veröffentlichung & SEO')->schema([
                Toggle::make('is_published')->label('Veröffentlicht')->required(),
                Toggle::make('is_featured')->label('Auf Startseite hervorheben')->required(),
                DateTimePicker::make('published_at')->label('Veröffentlichen am')->seconds(false),
                TextInput::make('meta_title')->label('SEO-Titel')->maxLength(70)->columnSpanFull(),
                Textarea::make('meta_description')->label('SEO-Beschreibung')->maxLength(320)->rows(3)->columnSpanFull(),
            ])->columns(3),
        ]);
    }
}
