<?php

namespace App\Filament\Auth;

use Filament\Actions\Action;
use Filament\Auth\Pages\Login;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Component;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\HtmlString;

class AdminLogin extends Login
{
    public function getTitle(): string|Htmlable
    {
        return 'Admin login';
    }

    public function getHeading(): string|Htmlable|null
    {
        return 'Admin Control Center';
    }

    public function getSubheading(): string|Htmlable|null
    {
        return new HtmlString('Secure access for managing users, links, ads, CMS, reports, and platform operations.');
    }

    protected function getEmailFormComponent(): Component
    {
        return TextInput::make('email')
            ->label('Admin email')
            ->email()
            ->placeholder('admin@urless.test')
            ->prefixIcon('heroicon-m-envelope')
            ->required()
            ->autocomplete()
            ->autofocus();
    }

    protected function getPasswordFormComponent(): Component
    {
        return TextInput::make('password')
            ->label('Password')
            ->password()
            ->placeholder('Enter your secure password')
            ->prefixIcon('heroicon-m-lock-closed')
            ->revealable(filament()->arePasswordsRevealable())
            ->autocomplete('current-password')
            ->required();
    }

    protected function getRememberFormComponent(): Component
    {
        return Checkbox::make('remember')
            ->label('Keep me signed in on this device');
    }

    protected function getAuthenticateFormAction(): Action
    {
        return parent::getAuthenticateFormAction()
            ->label('Enter admin panel')
            ->icon('heroicon-m-arrow-right-end-on-rectangle');
    }
}
