/** 多主体画像 — 根据角色展示不同视角的企业画像。 */

"use client";

import { Users, Building2, TrendingUp, AlertTriangle, Target, Lightbulb } from "lucide-react";
import { useAuth } from "@/lib/auth-context";

/** 角色视角配置。 */
const ROLE_PERSPECTIVES: Record<string, { title: string; focus: string[]; icon: typeof Users }> = {
  gp: {
    title: "GP 视角 — 组合层面",
    focus: ["组合健康度分布", "基金 IRR 追踪", "退出时机", "LP 汇报"],
    icon: TrendingUp,
  },
  post_invest_lead: {
    title: "投后负责人视角 — 运营层面",
    focus: ["企业健康度趋势", "风险队列", "任务推进", "月报审阅"],
    icon: Target,
  },
  investor: {
    title: "投资经理视角 — 执行层面",
    focus: ["今日行动", "企业跟进", "协同匹配", "数据校验"],
    icon: Lightbulb,
  },
  founder: {
    title: "创始人视角 — 经营层面",
    focus: ["经营 KPI", "融资准备", "投资人沟通", "团队建设"],
    icon: Building2,
  },
  admin: {
    title: "管理员视角 — 系统层面",
    focus: ["租户管理", "用户权限", "审计日志", "数据源监控"],
    icon: Users,
  },
};

/** 多主体画像页面。 */
export default function ProfilePage() {
  const { user } = useAuth();
  const role = user?.role ?? "investor";
  const perspective = ROLE_PERSPECTIVES[role] ?? ROLE_PERSPECTIVES.investor;

  return (
    <div className="space-y-6">
      <div className="flex items-center gap-2">
        <perspective.icon className="text-[var(--investor-primary)]" size={24} />
        <h1 className="text-2xl font-bold">多主体画像</h1>
      </div>

      <div className="rounded-lg border bg-white p-4 shadow-sm">
        <h2 className="mb-3 font-medium">{perspective.title}</h2>
        <div className="grid grid-cols-2 gap-3">
          {perspective.focus.map((item, i) => (
            <div key={i} className="rounded-md border p-3 text-sm">
              <div className="flex items-center gap-2">
                <div className="h-2 w-2 rounded-full bg-indigo-500" />
                <span className="font-medium">{item}</span>
              </div>
              <p className="mt-1 text-xs text-muted-foreground">
                基于当前角色权限展示的数据维度
              </p>
            </div>
          ))}
        </div>
      </div>

      {/* 角色切换提示 */}
      <div className="rounded-lg border border-indigo-200 bg-indigo-50 p-4 text-sm text-indigo-700">
        当前角色：<span className="font-medium">{role}</span>
        — 不同角色看到的数据维度和关注重点不同，系统自动适配。
      </div>
    </div>
  );
}
