"use client";

import Link from "next/link";
import { AppShell } from "@/components/app/AppShell";
import { PerformanceReportPanel } from "@/components/reports/PerformanceReportPanel";
import { DashboardSummary } from "@/components/teacher/DashboardSummary";
import { TeacherShell } from "@/components/teacher/TeacherShell";
import { isTeacherRole } from "@/lib/permissions";

export default function PerformanceReportPage() {
  const teacherView = isTeacherRole();
  const today = new Date().toISOString().slice(0, 10);

  const content = (
    <div className="space-y-6">
      {teacherView ? (
        <section className="space-y-3">
          <div>
            <h2 className="text-base font-bold text-slate-900">خلاصه امروز</h2>
            <p className="text-sm text-[var(--muted)]">حضور، تکالیف معطل و آزمون‌های پیش‌رو</p>
          </div>
          <DashboardSummary date={today} />
        </section>
      ) : null}

      <PerformanceReportPanel />

      <div className="text-sm text-[var(--muted)]">
        <Link href="/dashboard" className="text-teal-700 hover:underline">
          ← بازگشت به داشبورد
        </Link>
      </div>
    </div>
  );

  if (teacherView) {
    return (
      <TeacherShell title="گزارش عملکرد" subtitle="حضور، تکالیف و فعالیت تدریس" showBack>
        {content}
      </TeacherShell>
    );
  }

  return (
    <AppShell title="گزارش عملکرد" subtitle="گزارش مدیریتی فعالیت آموزشی" showBack>
      {content}
    </AppShell>
  );
}
