
import { SMTPSettingsCard } from "@/components/admin/SMTPSettingsCard";
import { AiSettingsCard } from "@/components/admin/AiSettingsCard";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { ArrowLeft, Shield, Bot, FileText, Settings, Sparkles } from "lucide-react";
import { useLocation } from "wouter";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { AuditLogsTable } from "@/components/admin/AuditLogsTable";
import { McpSettingsCard } from "@/components/admin/McpSettingsCard";
import { RoutineSettingsCard } from "@/components/admin/RoutineSettingsCard";
import { Clock } from "lucide-react";

export default function AdminSettings() {
    const { t } = useTranslation();
    const [, setLocation] = useLocation();

    return (
        <div className="space-y-6 container mx-auto p-4 max-w-5xl">
            <div className="flex items-center gap-4">
                <Button variant="ghost" size="icon" onClick={() => setLocation("/settings")}>
                    <ArrowLeft className="w-5 h-5" />
                </Button>
                <div>
                    <div className="flex items-center gap-3">
                        <h1 className="text-3xl font-bold tracking-tight">{t('settings.admin.title')}</h1>
                        <span className="text-sm font-mono text-muted-foreground border px-2 py-0.5 rounded-md bg-muted/50">
                            v{__APP_VERSION__}
                        </span>
                    </div>
                    <p className="text-muted-foreground">{t('settings.admin.description')}</p>
                </div>
            </div>

            <div className="grid gap-6">
                <Tabs defaultValue="settings" className="space-y-4">
                    <TabsList>
                        <TabsTrigger value="settings" className="flex items-center gap-2">
                            <Settings className="h-4 w-4" />
                            {t('settings.admin.tabs.general')}
                        </TabsTrigger>
                        <TabsTrigger value="ai" className="flex items-center gap-2">
                            <Sparkles className="h-4 w-4" />
                            {t('settings.admin.tabs.ai')}
                        </TabsTrigger>
                        <TabsTrigger value="routines" className="flex items-center gap-2">
                            <Clock className="h-4 w-4" />
                            {t('settings.admin.tabs.routines', 'Routines')}
                        </TabsTrigger>
                        <TabsTrigger value="mcp" className="flex items-center gap-2">
                            <Bot className="h-4 w-4" />
                            {t('settings.admin.tabs.mcp')}
                        </TabsTrigger>
                        <TabsTrigger value="audit" className="flex items-center gap-2">
                            <FileText className="h-4 w-4" />
                            {t('settings.admin.tabs.audit')}
                        </TabsTrigger>
                    </TabsList>

                    <TabsContent value="settings" className="space-y-6">
                        <SMTPSettingsCard />
                    </TabsContent>

                    <TabsContent value="ai">
                        <AiSettingsCard />
                    </TabsContent>

                    <TabsContent value="routines">
                        <RoutineSettingsCard />
                    </TabsContent>

                    <TabsContent value="mcp">
                        <McpSettingsCard />
                    </TabsContent>

                    <TabsContent value="audit">
                        <AuditLogsTable />
                    </TabsContent>
                </Tabs>
            </div>
        </div>
    );
}
