<?php

namespace App\Filament\Admin\Resources\Vocabularies\Schemas;

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

class VocabularyForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make('Core Info')
                    ->schema([
                        TextInput::make('word')
                            ->label('Word (Kanji/Kana)')
                            ->required()
                            ->maxLength(255),
                        TextInput::make('reading')
                            ->label('Reading (Kana)')
                            ->required()
                            ->maxLength(255),
                        TextInput::make('romaji')
                            ->maxLength(255),
                        TextInput::make('meaning_id')
                            ->label('Meaning (Bahasa Indonesia)')
                            ->required()
                            ->maxLength(255),
                        TextInput::make('meaning_en')
                            ->label('Meaning (English)')
                            ->required()
                            ->maxLength(255),
                    ])->columns(2),

                Section::make('Metadata & Media')
                    ->schema([
                        Select::make('level_id')
                            ->label('JLPT Level')
                            ->relationship('level', 'code')
                            ->searchable()
                            ->preload()
                            ->required(),
                        Select::make('type')
                            ->options([
                                'noun' => 'Noun',
                                'verb' => 'Verb',
                                'adjective' => 'Adjective',
                                'adverb' => 'Adverb',
                                'particle' => 'Particle',
                                'expression' => 'Expression',
                            ])
                            ->required(),
                        FileUpload::make('audio_url')
                            ->label('Pronunciation Audio')
                            ->disk('r2')
                            ->directory('audio/vocab')
                            ->visibility('public')
                            ->acceptedFileTypes(['audio/mpeg', 'audio/wav', 'audio/ogg']),
                    ])->columns(2),
                
                Section::make('Advanced')
                    ->schema([
                        Textarea::make('stroke_order_svg')
                            ->label('Stroke Order SVG (JSON)')
                            ->columnSpanFull(),
                        Textarea::make('example_sentences')
                            ->label('Example Sentences (JSON)')
                            ->columnSpanFull(),
                    ])->collapsed(),
            ]);
    }
}
