<?php

namespace App\Filament\Resources\CollateralAssets\Schemas;

use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;

class CollateralAssetForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make('Asset')
                    ->schema([
                        TextInput::make('symbol')
                            ->required()
                            ->maxLength(20),
                        TextInput::make('name')
                            ->required()
                            ->maxLength(60),
                        TextInput::make('gecko_id')
                            ->helperText('CoinGecko id (e.g. bitcoin, ethereum). Used for live prices.')
                            ->maxLength(60),
                        TextInput::make('network')
                            ->helperText('Single supported network for MVP (e.g. bitcoin, erc20, solana).')
                            ->maxLength(30),
                        TextInput::make('wallet_provider_name')
                            ->maxLength(60),
                        Toggle::make('is_active')
                            ->required(),
                    ])
                    ->columns(2),

                Section::make('Deposit Addresses')
                    ->schema([
                        TextInput::make('collateral_deposit_address')
                            ->helperText('Company address to receive collateral deposits.')
                            ->maxLength(255),
                        TextInput::make('earn_deposit_address')
                            ->helperText('Company address to receive staking deposits.')
                            ->maxLength(255),
                    ])
                    ->columns(2),

                Section::make('Loan & Earn Terms')
                    ->schema([
                        TextInput::make('loan_ltv_ratio')
                            ->required()
                            ->numeric()
                            ->helperText('Fraction, e.g. 0.60 for 60% LTV.')
                            ->default(0),
                        TextInput::make('min_collateral_coin')
                            ->required()
                            ->numeric()
                            ->helperText('Minimum collateral in COIN units.')
                            ->default(0),
                        TextInput::make('staking_apr')
                            ->required()
                            ->numeric()
                            ->helperText('APR fraction, e.g. 0.12 for 12% APR.')
                            ->default(0),
                    ])
                    ->columns(3),
            ]);
    }
}
