"use client"

import { useState } from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
} from "@/components/ui/dialog"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Progress } from "@/components/ui/progress"
import { TrendingUp, TrendingDown, AlertTriangle, Upload, MessageSquare, Plus, BarChart3 } from "lucide-react"

// Mock progress data
const progressData = [
  {
    id: 1,
    kpiTitle: "營收成長率",
    currentValue: 85,
    targetValue: 100,
    progress: 85,
    lastUpdate: "2024-02-10",
    updatedBy: "陳雅雯",
    comment: "本月營收表現良好，預計下月可達成目標",
    blockers: "",
    trend: "up",
    color: "emerald",
    category: "financial",
  },
  {
    id: 2,
    kpiTitle: "團隊滿意度",
    currentValue: 92,
    targetValue: 90,
    progress: 102,
    lastUpdate: "2024-02-08",
    updatedBy: "王志明",
    comment: "團隊士氣高昂，超越預期目標",
    blockers: "",
    trend: "up",
    color: "blue",
    category: "team",
  },
  {
    id: 3,
    kpiTitle: "市場佔有率",
    currentValue: 68,
    targetValue: 75,
    progress: 91,
    lastUpdate: "2024-02-05",
    updatedBy: "李美玲",
    comment: "競爭激烈，需要加強市場推廣",
    blockers: "競爭對手推出新產品",
    trend: "down",
    color: "purple",
    category: "operational",
  },
  {
    id: 4,
    kpiTitle: "創新指數",
    currentValue: 45,
    targetValue: 80,
    progress: 56,
    lastUpdate: "2024-02-03",
    updatedBy: "張建國",
    comment: "研發進度落後，需要額外資源",
    blockers: "人力不足，預算限制",
    trend: "down",
    color: "orange",
    category: "innovation",
  },
]

// 簡單的趨勢數據
const trendData = [
  { month: "1月", 營收成長率: 75, 團隊滿意度: 88, 市場佔有率: 72, 創新指數: 40 },
  { month: "2月", 營收成長率: 85, 團隊滿意度: 92, 市場佔有率: 68, 創新指數: 45 },
]

export default function ProgressPage() {
  const [activeTab, setActiveTab] = useState("overview")
  const [isUpdateDialogOpen, setIsUpdateDialogOpen] = useState(false)
  const [selectedKPI, setSelectedKPI] = useState<any>(null)

  const handleUpdateProgress = (kpi: any) => {
    setSelectedKPI(kpi)
    setIsUpdateDialogOpen(true)
  }

  return (
    <div className="min-h-screen bg-gradient-to-br from-slate-50 via-purple-50 to-pink-50 p-3 sm:p-6">
      <div className="max-w-7xl mx-auto space-y-4 sm:space-y-6">
        {/* Header */}
        <div className="flex flex-col space-y-4 sm:flex-row sm:items-center sm:justify-between sm:space-y-0">
          <div className="flex flex-col sm:flex-row sm:items-center space-y-2 sm:space-y-0 sm:space-x-4">
            <img
              src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAakAAABPCAMAAABmmMpCAAAAMFBMVEX///9PT08AZLLq6uxaWlr19fXX2NmNjY16enrFxsikpKRoaGi3t7eOqtg4eL9jjssqyzjzAAAPHklEQVR4nO1cB3bbSAyldnqxdf/bLvCBaRSpxI6jOLuE/WyKZQr+oA+1bRdddNFFF1100UUXXfRbyd+J3uT4jY/Nnx3PRWfk/yFSpO587P/seC46oxmptwupb0xA6i7Hl0x9Z/LvRE2m+PhC6puS80TqRRg+dH92PBf9CXoZ6I7oVX29hvzbl9CJgvSJfvgPc82HEPLKvppzHZ9czlkacr4mJZLrdphGL77WxM0r7eMI7irU9Zybbh5NTk/XMFOufag0ykPadfCbCc7dr9PbcevhZoWYreV2uyUo18YbR6fiwM7TDRlHJt6Uotny7Wbl1wa92dCDgZuXK7Y0prG2pva5q1v1M23GapPFb/U2U26DXal1tsXbMdmDGbtDOrjn8Lnj9l6BVJ9j2nxUnjiCj5lQY4zM5ziI2RhjMA9IdVJEqhwOFvJSwAVZGHJupug6UrQ4jpGa75/OfwipHA8o5FnnuMDn0vKYCXLjA4Ch33qA1Ptbekt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8c5b5lfu6jR+cKp48C/hFDoSOF65hQpJK9gV0nd8G2v8VuXAP4rFPQtdHDbFe9DiI5lKuIbSEnLyU2SQsILanWTq4xiyMakcvTWw0VfTILUJsk8+uuD4T8kU6hANKTc+OJURqriTWL6m/mrUq4UxStolSkCiSWK4IHUkGzlRaZQ9ZmRInciX2bqJVTFPgkiqTiuCnLVrdkpXGeDhHorTla2U6jmZXwIz76v9aKvIlOyJz+v/+e8uOddjCWRr8f7KrPHrpZS6XrzH1wm6WNhCtg5fNmpVxBvCM7yP/IO0yy+oG/vWFUyRPyfX8rCC5r4CkuXecsxfWDs8t+yueqiiy666KKLLrrooosu+r/Qv5Veut0DM30cAAAAAElFTkSuQmCC"
              alt="公司 Logo"
              className="h-10 w-auto sm:h-12 md:hidden"
            />
            <div>
              <h1 className="text-xl sm:text-2xl lg:text-3xl font-bold bg-gradient-to-r from-purple-600 to-pink-600 bg-clip-text text-transparent">
                進度追蹤中心
              </h1>
              <p className="text-sm sm:text-base text-gray-600 mt-1">KPI 進度更新與監控</p>
            </div>
          </div>
          <Button className="bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white shadow-lg">
            <Plus className="h-4 w-4 mr-2" />
            批量更新
          </Button>
        </div>

        {/* Progress Overview Cards */}
        <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-6">
          {progressData.map((item) => (
            <Card
              key={item.id}
              className={`shadow-lg hover:shadow-xl transition-all duration-300 border-0 ${
                item.color === "emerald"
                  ? "bg-gradient-to-br from-emerald-50 to-green-100"
                  : item.color === "blue"
                    ? "bg-gradient-to-br from-blue-50 to-cyan-100"
                    : item.color === "purple"
                      ? "bg-gradient-to-br from-purple-50 to-violet-100"
                      : "bg-gradient-to-br from-orange-50 to-amber-100"
              }`}
            >
              <CardHeader className="pb-3">
                <div className="flex items-center justify-between">
                  <CardTitle className="text-sm font-semibold text-gray-800">{item.kpiTitle}</CardTitle>
                  {item.trend === "up" ? (
                    <TrendingUp className="h-4 w-4 text-green-500" />
                  ) : (
                    <TrendingDown className="h-4 w-4 text-red-500" />
                  )}
                </div>
              </CardHeader>
              <CardContent className="space-y-4">
                <div className="space-y-2">
                  <div className="flex justify-between text-sm">
                    <span className="text-gray-600">進度</span>
                    <span className="font-semibold">{item.progress}%</span>
                  </div>
                  <Progress value={item.progress} className="h-2" />
                  <div className="flex justify-between text-xs text-gray-500">
                    <span>
                      {item.currentValue} / {item.targetValue}
                    </span>
                    <span>{item.lastUpdate}</span>
                  </div>
                </div>
                <div className="flex items-center justify-between">
                  <Avatar className="h-6 w-6">
                    <AvatarFallback className="text-xs bg-gradient-to-br from-blue-400 to-purple-500 text-white">
                      {item.updatedBy.charAt(0)}
                    </AvatarFallback>
                  </Avatar>
                  <Button
                    variant="outline"
                    size="sm"
                    className="h-7 text-xs bg-transparent"
                    onClick={() => handleUpdateProgress(item)}
                  >
                    更新
                  </Button>
                </div>
                {item.blockers && (
                  <div className="flex items-start space-x-2 p-2 bg-red-50 rounded-lg border border-red-200">
                    <AlertTriangle className="h-3 w-3 text-red-500 mt-0.5 flex-shrink-0" />
                    <p className="text-xs text-red-700">{item.blockers}</p>
                  </div>
                )}
              </CardContent>
            </Card>
          ))}
        </div>

        {/* Main Content */}
        <Card className="shadow-lg bg-white/80 backdrop-blur-sm">
          <CardHeader>
            <CardTitle className="text-lg font-bold bg-gradient-to-r from-gray-800 to-gray-600 bg-clip-text text-transparent">
              進度分析
            </CardTitle>
            <CardDescription>KPI 進度趨勢與詳細追蹤</CardDescription>
          </CardHeader>
          <CardContent>
            <Tabs value={activeTab} onValueChange={setActiveTab}>
              <TabsList className="grid w-full grid-cols-3">
                <TabsTrigger value="overview">趨勢概覽</TabsTrigger>
                <TabsTrigger value="details">詳細記錄</TabsTrigger>
                <TabsTrigger value="timeline">時間軸</TabsTrigger>
              </TabsList>

              <TabsContent value="overview" className="space-y-6">
                <Card className="shadow-md">
                  <CardHeader>
                    <CardTitle className="text-base flex items-center">
                      <BarChart3 className="h-5 w-5 mr-2" />
                      KPI 進度趨勢
                    </CardTitle>
                  </CardHeader>
                  <CardContent>
                    <div className="space-y-6">
                      {trendData.map((data, index) => (
                        <div key={index} className="space-y-4">
                          <h4 className="font-semibold text-gray-700">{data.month}</h4>
                          <div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
                            <div className="space-y-2">
                              <div className="flex justify-between text-sm">
                                <span className="text-gray-600">營收成長率</span>
                                <span className="font-medium">{data.營收成長率}%</span>
                              </div>
                              <Progress value={data.營收成長率} className="h-2" />
                            </div>
                            <div className="space-y-2">
                              <div className="flex justify-between text-sm">
                                <span className="text-gray-600">團隊滿意度</span>
                                <span className="font-medium">{data.團隊滿意度}%</span>
                              </div>
                              <Progress value={data.團隊滿意度} className="h-2" />
                            </div>
                            <div className="space-y-2">
                              <div className="flex justify-between text-sm">
                                <span className="text-gray-600">市場佔有率</span>
                                <span className="font-medium">{data.市場佔有率}%</span>
                              </div>
                              <Progress value={data.市場佔有率} className="h-2" />
                            </div>
                            <div className="space-y-2">
                              <div className="flex justify-between text-sm">
                                <span className="text-gray-600">創新指數</span>
                                <span className="font-medium">{data.創新指數}%</span>
                              </div>
                              <Progress value={data.創新指數} className="h-2" />
                            </div>
                          </div>
                        </div>
                      ))}
                    </div>
                  </CardContent>
                </Card>
              </TabsContent>

              <TabsContent value="details" className="space-y-4">
                {progressData.map((item) => (
                  <Card key={item.id} className="shadow-md hover:shadow-lg transition-shadow">
                    <CardContent className="p-6">
                      <div className="flex flex-col sm:flex-row sm:items-start sm:justify-between space-y-4 sm:space-y-0">
                        <div className="flex-1 space-y-3">
                          <div className="flex items-center space-x-3">
                            <h3 className="font-semibold text-gray-900">{item.kpiTitle}</h3>
                            <Badge
                              variant={
                                item.progress >= 80 ? "default" : item.progress >= 60 ? "secondary" : "destructive"
                              }
                            >
                              {item.progress}%
                            </Badge>
                          </div>
                          <div className="space-y-2">
                            <Progress value={item.progress} className="h-2" />
                            <div className="flex items-center justify-between text-sm text-gray-600">
                              <span>
                                目前: {item.currentValue} / 目標: {item.targetValue}
                              </span>
                              <span>更新: {item.lastUpdate}</span>
                            </div>
                          </div>
                          {item.comment && (
                            <div className="flex items-start space-x-2 p-3 bg-blue-50 rounded-lg">
                              <MessageSquare className="h-4 w-4 text-blue-500 mt-0.5 flex-shrink-0" />
                              <p className="text-sm text-blue-700">{item.comment}</p>
                            </div>
                          )}
                          {item.blockers && (
                            <div className="flex items-start space-x-2 p-3 bg-red-50 rounded-lg">
                              <AlertTriangle className="h-4 w-4 text-red-500 mt-0.5 flex-shrink-0" />
                              <p className="text-sm text-red-700">
                                <span className="font-medium">阻礙因素:</span> {item.blockers}
                              </p>
                            </div>
                          )}
                        </div>
                        <div className="flex items-center space-x-2">
                          <Avatar className="h-8 w-8">
                            <AvatarFallback className="bg-gradient-to-br from-blue-400 to-purple-500 text-white">
                              {item.updatedBy.charAt(0)}
                            </AvatarFallback>
                          </Avatar>
                          <div className="text-sm">
                            <p className="font-medium text-gray-900">{item.updatedBy}</p>
                            <p className="text-gray-500">{item.lastUpdate}</p>
                          </div>
                        </div>
                      </div>
                    </CardContent>
                  </Card>
                ))}
              </TabsContent>

              <TabsContent value="timeline" className="space-y-4">
                <div className="relative">
                  <div className="absolute left-4 top-0 bottom-0 w-0.5 bg-gradient-to-b from-blue-500 to-purple-500"></div>
                  {progressData.map((item, index) => (
                    <div key={item.id} className="relative flex items-start space-x-4 pb-8">
                      <div className="flex-shrink-0 w-8 h-8 bg-gradient-to-br from-blue-500 to-purple-500 rounded-full flex items-center justify-center">
                        <span className="text-white text-xs font-bold">{index + 1}</span>
                      </div>
                      <Card className="flex-1 shadow-md">
                        <CardContent className="p-4">
                          <div className="flex items-center justify-between mb-2">
                            <h4 className="font-semibold text-gray-900">{item.kpiTitle}</h4>
                            <Badge variant={item.progress >= 80 ? "default" : "secondary"}>{item.progress}%</Badge>
                          </div>
                          <p className="text-sm text-gray-600 mb-2">{item.comment}</p>
                          <div className="flex items-center justify-between text-xs text-gray-500">
                            <span>更新者: {item.updatedBy}</span>
                            <span>{item.lastUpdate}</span>
                          </div>
                        </CardContent>
                      </Card>
                    </div>
                  ))}
                </div>
              </TabsContent>
            </Tabs>
          </CardContent>
        </Card>

        {/* Update Progress Dialog */}
        <Dialog open={isUpdateDialogOpen} onOpenChange={setIsUpdateDialogOpen}>
          <DialogContent className="max-w-md">
            <DialogHeader>
              <DialogTitle className="bg-gradient-to-r from-purple-600 to-pink-600 bg-clip-text text-transparent">
                更新進度
              </DialogTitle>
              <DialogDescription>更新 {selectedKPI?.kpiTitle} 的最新進度</DialogDescription>
            </DialogHeader>
            <div className="space-y-4">
              <div>
                <Label htmlFor="currentValue">目前數值</Label>
                <Input id="currentValue" type="number" placeholder="輸入目前數值" />
              </div>
              <div>
                <Label htmlFor="comment">進度說明</Label>
                <Textarea id="comment" placeholder="描述目前進度狀況..." />
              </div>
              <div>
                <Label htmlFor="blockers">阻礙因素 (選填)</Label>
                <Textarea id="blockers" placeholder="描述遇到的困難或阻礙..." />
              </div>
              <div>
                <Label htmlFor="attachment">附件 (選填)</Label>
                <div className="flex items-center space-x-2">
                  <Input id="attachment" type="file" className="flex-1" />
                  <Button variant="outline" size="sm">
                    <Upload className="h-4 w-4" />
                  </Button>
                </div>
              </div>
            </div>
            <DialogFooter>
              <Button
                type="submit"
                className="bg-gradient-to-r from-green-500 to-emerald-500 hover:from-green-600 hover:to-emerald-600 text-white"
              >
                更新進度
              </Button>
            </DialogFooter>
          </DialogContent>
        </Dialog>
      </div>
    </div>
  )
}
