'use client';

import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
import { Switch } from '@/components/ui/switch';
import { toast } from 'sonner';
import { Server } from 'lucide-react';

interface ServiceConfigDialogProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
}

export function ServiceConfigDialog({ open, onOpenChange }: ServiceConfigDialogProps) {
  const handleSaveConfig = () => {
    toast.success('配置已保存');
    onOpenChange(false);
  };

  return (
    <Dialog open={open} onOpenChange={onOpenChange}>
      <DialogContent className="max-w-3xl">
        <DialogHeader>
          <DialogTitle>服务配置</DialogTitle>
          <DialogDescription>
            配置模型服务的运行参数和性能优化选项
          </DialogDescription>
        </DialogHeader>

        <div className="space-y-4">
          <div className="grid grid-cols-2 gap-4">
            <div>
              <Label>最大并发数</Label>
              <Input type="number" placeholder="10" />
            </div>
            <div>
              <Label>超时时间（秒）</Label>
              <Input type="number" placeholder="30" />
            </div>
          </div>

          <div className="grid grid-cols-2 gap-4">
            <div>
              <Label>重试次数</Label>
              <Input type="number" placeholder="3" />
            </div>
            <div>
              <Label>最小实例数</Label>
              <Input type="number" placeholder="1" />
            </div>
          </div>

          <div className="flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-950 rounded-lg">
            <div>
              <div className="font-medium">启用负载均衡</div>
              <div className="text-xs text-muted-foreground">自动分配请求到多个实例</div>
            </div>
            <Switch defaultChecked />
          </div>

          <div className="flex items-center justify-between p-4 bg-green-50 dark:bg-green-950 rounded-lg">
            <div>
              <div className="font-medium">自动伸缩</div>
              <div className="text-xs text-muted-foreground">根据负载自动调整实例数量</div>
            </div>
            <Switch defaultChecked />
          </div>

          <div>
            <Label>环境变量</Label>
            <Textarea placeholder="KEY=VALUE，每行一个" rows={3} />
          </div>
        </div>

        <DialogFooter>
          <Button variant="outline" onClick={() => onOpenChange(false)}>
            取消
          </Button>
          <Button className="bg-green-600 hover:bg-green-700 dark:bg-green-700 dark:hover:bg-green-600" onClick={handleSaveConfig}>
            保存配置
          </Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}