import type { JSX } from "react"

import { Card, CardContent, CardHeader } from "@/shared/components/ui/card"
import { Skeleton } from "@/shared/components/ui/skeleton"

/**
 * P2-9: 消息列表骨架屏。
 *
 * 作为 Suspense fallback，在 MessageListSection 流式加载期间展示。
 */
export function MessageListSkeleton(): JSX.Element {
  return (
    <div className="space-y-4" role="status" aria-label="Loading messages">
      <div className="flex items-center justify-between">
        <Skeleton className="h-10 w-48" />
        <Skeleton className="h-10 w-28" />
      </div>
      <Skeleton className="h-10 w-full" />
      {Array.from({ length: 5 }).map((_, i) => (
        <Card key={i} aria-hidden="true">
          <CardHeader className="flex flex-row items-start justify-between gap-2 space-y-0 pb-3">
            <div className="space-y-2">
              <Skeleton className="h-4 w-48" />
              <Skeleton className="h-3 w-32" />
            </div>
            <Skeleton className="h-3 w-20" />
          </CardHeader>
          <CardContent className="pt-0">
            <Skeleton className="h-4 w-full" />
            <Skeleton className="mt-1 h-4 w-3/4" />
          </CardContent>
        </Card>
      ))}
    </div>
  )
}
