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

function SidebarSkeleton() {
  return (
    <div className="hidden lg:flex flex-col fixed inset-y-0 left-0 border-r border-border bg-card w-64 h-screen p-4 space-y-6">
      <div className="flex items-center gap-2">
        <Skeleton className="w-8 h-8 rounded-lg" />
        <Skeleton className="w-32 h-6" />
      </div>
      <Skeleton className="w-full h-12 rounded-lg" />
      <div className="space-y-2 flex-1">
        {Array.from({ length: 8 }).map((_, i) => (
          <Skeleton key={i} className="w-full h-10 rounded-lg" />
        ))}
      </div>
      <div className="flex items-center gap-3 pt-4 border-t">
        <Skeleton className="w-8 h-8 rounded-full" />
        <div className="space-y-1">
          <Skeleton className="w-24 h-4" />
          <Skeleton className="w-16 h-3" />
        </div>
      </div>
    </div>
  );
}

function ActivityItemSkeleton() {
  return (
    <div className="flex items-start gap-3 p-4">
      <Skeleton className="w-8 h-8 rounded-full shrink-0" />
      <div className="flex-1 min-w-0">
        <div className="flex items-center gap-2 mb-1">
          <Skeleton className="w-24 h-4" />
          <Skeleton className="w-16 h-3" />
        </div>
        <Skeleton className="w-full h-4" />
      </div>
    </div>
  );
}

export default function ActivityLoading() {
  return (
    <div className="h-screen bg-background flex overflow-hidden">
      <SidebarSkeleton />

      <main className="flex-1 h-screen overflow-y-auto lg:pl-64">
        <div className="min-h-full p-4 lg:p-8">
          {/* Mobile header */}
          <div className="lg:hidden flex items-center justify-between gap-4 p-4 mb-4 border-b">
            <div className="flex items-center gap-3">
              <Skeleton className="w-8 h-8" />
              <Skeleton className="w-32 h-6" />
            </div>
            <Skeleton className="w-8 h-8" />
          </div>

          {/* Desktop search */}
          <div className="hidden lg:flex items-center justify-end gap-4 mb-6">
            <Skeleton className="w-64 h-10" />
          </div>

          {/* Header */}
          <div className="mb-6">
            <Skeleton className="w-40 h-8 mb-2" />
            <Skeleton className="w-96 h-4" />
          </div>

          {/* Activity Stats */}
          <Card className="mb-6">
            <CardContent className="p-4 sm:p-6">
              <div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
                {Array.from({ length: 4 }).map((_, i) => (
                  <div key={i} className="text-center">
                    <Skeleton className="w-12 h-8 mx-auto mb-1" />
                    <Skeleton className="w-20 h-3 mx-auto" />
                  </div>
                ))}
              </div>
            </CardContent>
          </Card>

          {/* Activity Feed */}
          <Card>
            <CardHeader className="pb-3">
              <Skeleton className="w-32 h-5" />
            </CardHeader>
            <CardContent className="p-0">
              <div className="divide-y">
                {Array.from({ length: 8 }).map((_, i) => (
                  <ActivityItemSkeleton key={i} />
                ))}
              </div>
            </CardContent>
          </Card>
        </div>
      </main>
    </div>
  );
}
