<?php

namespace App\Filament\Resources\Sliders\Schemas;

use Filament\Forms;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Schema;

class SliderForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Tabs::make('Slider Content')
                    ->tabs([
                        Tabs\Tab::make('Content')
                            ->icon('heroicon-o-photo')
                            ->schema([
                                Section::make('Slide Information')
                                    ->schema([
                                        Forms\Components\TextInput::make('title')
                                            ->label('Title')
                                            ->maxLength(255)
                                            ->prefixIcon('heroicon-o-tag')
                                            ->placeholder('Enter slide title')
                                            ->helperText('Optional small title above the heading')
                                            ->columnSpanFull(),
                                        
                                        Forms\Components\TextInput::make('header')
                                            ->label('Heading')
                                            ->required()
                                            ->maxLength(255)
                                            ->prefixIcon('heroicon-o-document-text')
                                            ->placeholder('Enter slide heading')
                                            ->columnSpanFull(),
                                        
                                        Forms\Components\Textarea::make('description')
                                            ->label('Description')
                                            ->rows(4)
                                            ->maxLength(1000)
                                            ->placeholder('Enter slide description')
                                            ->helperText('Brief description for the slide')
                                            ->columnSpanFull(),
                                        
                                        Forms\Components\TextInput::make('link')
                                            ->label('Button Link')
                                            ->url()
                                            ->maxLength(255)
                                            ->prefixIcon('heroicon-o-link')
                                            ->placeholder('https://example.com')
                                            ->helperText('Optional link for the slide button')
                                            ->columnSpanFull(),
                                    ])
                                    ->columns(1),
                                
                                Section::make('Slide Image')
                                    ->schema([
                                        Forms\Components\FileUpload::make('image')
                                            ->label('Slide Image')
                                            ->image()
                                            ->imageEditor()
                                            ->disk('public')
                                            ->directory('sliders')
                                            ->maxSize(5120)
                                            ->helperText('Recommended size: 1920x800 pixels')
                                            ->imagePreviewHeight('200')
                                            ->columnSpanFull(),
                                    ])
                                    ->columns(1)
                                    ->collapsible(),
                            ]),
                        
                        Tabs\Tab::make('Settings')
                            ->icon('heroicon-o-cog-6-tooth')
                            ->schema([
                                Section::make('Display Settings')
                                    ->schema([
                                        Forms\Components\Toggle::make('is_active')
                                            ->label('Active')
                                            ->helperText('Show this slide in the slider')
                                            ->default(true),
                                        
                                        Forms\Components\TextInput::make('order')
                                            ->label('Display Order')
                                            ->numeric()
                                            ->default(0)
                                            ->helperText('Lower numbers appear first')
                                            ->minValue(0),
                                    ])
                                    ->columns(2),
                            ]),
                    ])
                    ->columnSpanFull(),
            ]);
    }
}
