<?php

namespace App\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
            ->id('admin')
            ->path('admin')
            ->login(\App\Filament\Auth\Pages\CustomLogin::class)
            ->colors([
                'primary' => Color::Amber,
                'gray' => Color::Gray,
                'info' => Color::Blue,
                'success' => Color::Emerald,
                'warning' => Color::Orange,
                'danger' => Color::Rose,
            ])
            ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
            ->resources([
                \App\Filament\Resources\TextbookSeriesResource::class,
                \App\Filament\Resources\TextbookResource::class,
                \App\Filament\Resources\TextbookCatalogResource::class,
                \App\Filament\Resources\SourcePaperResource::class,
            ])
            ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
            ->pages([
                \App\Filament\Pages\UploadExamPaper::class,
                \App\Filament\Pages\QuestionDetail::class,
            ])
            ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
            ->widgets([
                \Filament\Widgets\AccountWidget::class,
            ])
            ->navigationGroups([
                '教材管理',
                '卷子导入流程',
                '知识图谱管理',
                '题库管理',
                '卷子生成管理',
                '学生管理',
                'API 管理',
                '其他',
            ])
            ->middleware([
                \Illuminate\Cookie\Middleware\EncryptCookies::class,
                \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
                \Illuminate\Session\Middleware\StartSession::class,
                \Illuminate\Session\Middleware\AuthenticateSession::class,
                \Illuminate\View\Middleware\ShareErrorsFromSession::class,
                \Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
                \Illuminate\Routing\Middleware\SubstituteBindings::class,
                \App\Http\Middleware\FilamentAdminLocale::class,
            ])
            ->authMiddleware([
                \Filament\Http\Middleware\Authenticate::class,
                \App\Http\Middleware\FilamentAdminLocale::class,
            ])
            ->brandName('数学知识图谱管理系统')
            ->brandLogoHeight('2.5rem')
            ->maxContentWidth('full')
            ->sidebarCollapsibleOnDesktop()
            ->topNavigation(false);
    }
}
