<?php

namespace App\Filament\Resources\Banners\Schemas;

use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;
use Illuminate\Support\HtmlString;

class BannerForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->schema([
                // 1. Input Judul
                TextInput::make('title')
                    ->label('Judul Banner')
                    // ->required()
                   
                    ->hidden()
                    ->maxLength(255),

                // 2. Input Deskripsi
                RichEditor::make('description')
                    ->label('Deskripsi')
                    // ->maxLength(500)
                    ->hidden()
                    ->columnSpanFull(),

                // 3. Upload Gambar
                FileUpload::make('image')
                    ->label('Gambar Banner')
                    ->image() 
                    ->directory('banners')
                    ->disk('public')
                    ->maxSize(2048) 
                    ->required()
                    ->columnSpanFull()
                    ->helperText(new HtmlString('Ukuran optimal: <strong>1920 x 810 px</strong>. Format: JPG/PNG, Max 2MB.')),

                // 4. Status Aktif
                Toggle::make('is_active')
                    ->label('Status Aktif')
                    ->default(true)
                    ->required(),

                // 5. Hidden Fields
                Hidden::make('created_by')
                    ->default(fn () => auth()->id()),
                Hidden::make('updated_by')
                    ->default(fn () => auth()->id()),
            ]);
    }
}