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>
  );
}

export default function MissionLoading() {
  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="text-center sm:text-left mb-6">
            <Skeleton className="w-48 h-10 mb-2 mx-auto sm:mx-0" />
            <Skeleton className="w-96 h-4 mx-auto sm:mx-0" />
          </div>

          {/* Mission Statement Card */}
          <Card className="mb-8">
            <CardContent className="p-4 sm:p-6 md:p-8">
              <div className="flex flex-col sm:flex-row items-center gap-4 sm:gap-6">
                <Skeleton className="w-16 h-16 sm:w-20 sm:h-20 rounded-2xl" />
                <div className="flex-1 w-full">
                  <Skeleton className="w-48 h-6 mb-2" />
                  <Skeleton className="w-full h-16" />
                </div>
              </div>
            </CardContent>
          </Card>

          {/* Progress Dashboard */}
          <div className="mb-8">
            <div className="flex items-center gap-3 mb-4">
              <Skeleton className="w-10 h-10 rounded-lg" />
              <div>
                <Skeleton className="w-40 h-6 mb-1" />
                <Skeleton className="w-32 h-3" />
              </div>
            </div>
            <div className="grid grid-cols-1 lg:grid-cols-2 gap-3 sm:gap-4">
              {Array.from({ length: 4 }).map((_, i) => (
                <Card key={i}>
                  <CardContent className="p-4 sm:p-6">
                    <div className="flex items-start justify-between gap-3 mb-4">
                      <div className="flex items-center gap-2 sm:gap-3">
                        <Skeleton className="w-10 h-10 sm:w-12 sm:h-12 rounded-xl" />
                        <div>
                          <Skeleton className="w-32 h-5 mb-1" />
                          <Skeleton className="w-24 h-3" />
                        </div>
                      </div>
                      <Skeleton className="w-16 h-8" />
                    </div>
                    <Skeleton className="w-full h-3 sm:h-4" />
                  </CardContent>
                </Card>
              ))}
            </div>
          </div>

          {/* Two Column Layout */}
          <div className="grid grid-cols-1 xl:grid-cols-2 gap-6 sm:gap-8">
            {/* Milestones */}
            <div>
              <div className="flex items-center gap-3 mb-4">
                <Skeleton className="w-10 h-10 rounded-lg" />
                <Skeleton className="w-48 h-6" />
              </div>
              <div className="space-y-3 sm:space-y-4">
                {Array.from({ length: 4 }).map((_, i) => (
                  <div key={i} className="flex gap-3 sm:gap-4">
                    <Skeleton className="w-8 h-8 sm:w-10 sm:h-10 rounded-full shrink-0" />
                    <Card className="flex-1">
                      <CardContent className="p-3 sm:p-4">
                        <Skeleton className="w-full h-12" />
                      </CardContent>
                    </Card>
                  </div>
                ))}
              </div>
            </div>

            {/* Next Steps */}
            <div>
              <div className="flex items-center gap-3 mb-4">
                <Skeleton className="w-10 h-10 rounded-lg" />
                <div className="flex-1">
                  <Skeleton className="w-32 h-6 mb-1" />
                  <Skeleton className="w-24 h-3" />
                </div>
                <Skeleton className="w-24 h-9" />
              </div>
              <div className="space-y-2 sm:space-y-3">
                {Array.from({ length: 4 }).map((_, i) => (
                  <Card key={i}>
                    <CardContent className="p-3 sm:p-4">
                      <Skeleton className="w-full h-16" />
                    </CardContent>
                  </Card>
                ))}
              </div>
            </div>
          </div>

          {/* Core Values */}
          <div className="mt-8">
            <Skeleton className="w-32 h-6 mb-4" />
            <div className="grid grid-cols-2 sm:grid-cols-4 gap-3 sm:gap-4">
              {Array.from({ length: 4 }).map((_, i) => (
                <Card key={i}>
                  <CardContent className="p-3 sm:p-4 text-center">
                    <Skeleton className="w-10 h-10 sm:w-12 sm:h-12 rounded-full mx-auto mb-2 sm:mb-3" />
                    <Skeleton className="w-16 h-5 mx-auto mb-1" />
                    <Skeleton className="w-20 h-3 mx-auto" />
                  </CardContent>
                </Card>
              ))}
            </div>
          </div>
        </div>
      </main>
    </div>
  );
}
