<?php

declare(strict_types=1);

namespace App\Filament\Resources\Services\Schemas;

use Filament\Forms\Components\FileUpload;
use Filament\Schemas\Components\Group;
use Filament\Schemas\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;

class ServiceForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema->components([
            Group::make()
                ->schema([
                    Section::make('اطلاعات اصلی')
                        ->schema([
                            TextInput::make('name')
                                ->label('نام خدمت')
                                ->required()
                                ->maxLength(255)
                                ->columnSpan(12),
                            
                            \App\Filament\Components\Form\DescTextarea::create()
                                ->label('خلاصه')
                                ->name('excerpt'),
                            
                            \App\Filament\Components\Form\DescTextarea::create()
                                ->label('توضیحات کامل'),
                            
                            \App\Filament\Components\Form\CategorySelect::create()
                                ->label('دسته اصلی'),
                            
                            \App\Filament\Components\Form\SubCategorySelect::create(),
                            
                            \App\Filament\Components\Form\UserSelect::create()
                                ->label('کاربر'),
                            
                            \App\Filament\Components\Form\PriceTextInput::create()
                                ->label('قیمت')
                                ->columnSpan(6),
                            
                            \App\Filament\Components\Form\DurationTextInput::create()
                                ->label('مدت زمان')
                                ->columnSpan(6),
                            
                            TextInput::make('type')
                                ->label('نوع')
                                ->maxLength(255)
                                ->columnSpan(12),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                    
                    Section::make('موقعیت جغرافیایی')
                        ->schema([
                            \App\Filament\Components\Form\ProvinceSelect::create(),
                            \App\Filament\Components\Form\CountySelect::create(),
                            \App\Filament\Components\Form\AddressTextInput::create(),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                    
                    Section::make('رسانه‌ها')
                        ->schema([
                            \App\Filament\Components\Form\ImageFileUpload::create()
                                ->label('تصویر اصلی'),
                            
                            FileUpload::make('gallery')
                                ->label('گالری تصاویر')
                                ->multiple()
                                ->directory('files/services/gallery')
                                ->image()
                                ->columnSpan(12),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                ])
                ->columns(12)
                ->columnSpan(8),
            
            Group::make()
                ->schema([
                    Section::make('وضعیت')
                        ->schema([
                            Select::make('status')
                                ->label('وضعیت')
                                ->options([
                                    'active' => 'فعال',
                                    'inactive' => 'غیرفعال',
                                    'pending' => 'در انتظار',
                                ])
                                ->default('active')
                                ->columnSpan(12),
                            
                            Toggle::make('is_active')
                                ->label('فعال')
                                ->default(true)
                                ->columnSpan(12),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                    
                    Section::make('آمار')
                        ->schema([
                            TextInput::make('view_count')
                                ->label('تعداد بازدید')
                                ->numeric()
                                ->default(0)
                                ->disabled()
                                ->columnSpan(12),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                    
                    Section::make('اطلاعات سیستم')
                        ->schema([
                            \App\Filament\Components\Form\CreatedBySelect::create()->required(),
                            \App\Filament\Components\Form\UpdatedBySelect::create(),
                        ])
                        ->columns(12)
                        ->columnSpan(12),
                ])
                ->columns(12)
                ->columnSpan(4),
        ])
        ->columns(12);
    }
}

