"use client" import { StudyTimeOptimizationCard } from "@/components/AI/StudyTimeOptimizationCard" import { Clock, Zap, Moon, Sun, AlertCircle, ArrowRight, BarChart2 } from "lucide-react" import { Card, CardContent } from "@/components/ui/card" import Link from "next/link" import { useActiveUser, isDemoUser } from "@/hooks/useActiveUser" const DEMO_INSIGHTS = [ { icon: , title: "Peak Cognitive Window", desc: "2 PM – 5 PM is your highest-efficiency block. Reserve this for new concepts, hard problems, and mock tests.", color: "border-yellow-400/20 bg-yellow-400/5", }, { icon: , title: "Evening Consolidation", desc: "9–10 PM is ideal for light revision and flashcard review — this window solidifies short-term to long-term memory.", color: "border-indigo-400/20 bg-indigo-400/5", }, { icon: , title: "Avoid After 11 PM", desc: "Cognitive fatigue significantly increases error rate. Solving new concepts late at night is counterproductive.", color: "border-red-400/20 bg-red-400/5", }, ] const DEMO_HOURLY_EFFICIENCY = [ { slot: "6–9 AM", pct: 60, label: "Morning" }, { slot: "9–12 PM", pct: 72, label: "Mid-Morning" }, { slot: "12–2 PM", pct: 55, label: "Post-Lunch dip" }, { slot: "2–5 PM", pct: 95, label: "Peak ★", highlight: true }, { slot: "5–7 PM", pct: 82, label: "Afternoon" }, { slot: "7–9 PM", pct: 74, label: "Evening" }, { slot: "9–11 PM", pct: 60, label: "Night Revision" }, { slot: "11 PM+", pct: 32, label: "Avoid" }, ] const ZERO_HOURLY_EFFICIENCY = [ { slot: "6–9 AM", pct: 0, label: "Pending" }, { slot: "9–12 PM", pct: 0, label: "Pending" }, { slot: "12–2 PM", pct: 0, label: "Pending" }, { slot: "2–5 PM", pct: 0, label: "Calibrating", highlight: false }, { slot: "5–7 PM", pct: 0, label: "Pending" }, { slot: "7–9 PM", pct: 0, label: "Pending" }, { slot: "9–11 PM", pct: 0, label: "Pending" }, { slot: "11 PM+", pct: 0, label: "Pending" }, ] export default function TimeOptimizationPage() { const { userId } = useActiveUser() const isDemo = isDemoUser(userId) const hourlySlots = isDemo ? DEMO_HOURLY_EFFICIENCY : ZERO_HOURLY_EFFICIENCY const insights = isDemo ? DEMO_INSIGHTS : [ { icon: , title: "Peak Window Calibrating", desc: "Complete 3 test sessions at different times of day to establish your circadian peak focus hours.", color: "border-yellow-400/20 bg-yellow-400/5", }, { icon: , title: "Consistency Booster", desc: "Start with a 30-minute daily review routine to jumpstart your spaced repetition learning schedule.", color: "border-indigo-400/20 bg-indigo-400/5", }, ] return (
{/* Page Header */}

Study Time Optimization

Understand your peak productive hours and schedule your hardest topics in your highest-efficiency windows.

Chronobiology Analytics
{/* KPI Strip */}
{[ { label: "Peak Efficiency", value: isDemo ? "95%" : "--", sub: isDemo ? "2–5 PM window" : "Calibrating", color: "border-yellow-400/20 bg-yellow-400/5", icon: }, { label: "Study Hrs Today", value: isDemo ? "3.8 h" : "0.0 h", sub: "Target: 6 h", color: "border-[var(--cyan-ai-20)] bg-[var(--cyan-ai-10)]", icon: }, { label: "Morning Block", value: isDemo ? "60%" : "0%", sub: "6–9 AM", color: "border-indigo-400/20 bg-indigo-400/5", icon: }, { label: "Evening Block", value: isDemo ? "74%" : "0%", sub: "7–9 PM", color: "border-green-400/20 bg-green-400/5", icon: }, ].map(kpi => ( {kpi.icon}
{kpi.value}
{kpi.label}
{kpi.sub}
))}
{/* Chart — 2/3 */}
Hourly Efficiency Profile
{/* Right Panel */}
{/* Slot breakdown table */}

Time Slot Breakdown

{hourlySlots.map(slot => (
{slot.slot}
= 80 ? (slot.highlight ? "bg-yellow-400" : "bg-green-400") : slot.pct >= 60 ? "bg-[var(--cyan-ai)]" : isDemo ? "bg-red-400" : "bg-white/10"}`} style={{ width: `${slot.pct}%` }} />
{slot.pct}%
{slot.highlight && PEAK}
))}
{/* AI Insights */}
{insights.map(insight => (
{insight.icon}

{insight.title}

{insight.desc}

))}

Apply Insights

{[ { label: "Schedule Today's Study Plan", href: "/dashboard/ai-coach/study-plan" }, { label: "Check Exam Readiness", href: "/dashboard/ai-coach/readiness" }, { label: "Launch a Practice Test Now", href: "/dashboard/ai-coach/cbt-dpp" }, ].map(link => ( {link.label} ))}
) }