import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Store, ExternalLink, Info, CheckCircle2 } from "lucide-react";

interface ShopRenterConnectProps {
  onClose?: () => void;
}

export function ShopRenterConnect({ onClose }: ShopRenterConnectProps) {
  return (
    <Card className="bg-slate-800 border-slate-700 max-w-2xl mx-auto shadow-none border-0">
      <CardHeader>
        <div className="flex items-center gap-3">
          <Store className="w-8 h-8 text-cyan-500" />
          <div>
            <CardTitle className="text-white text-2xl">Connect ShopRenter Store</CardTitle>
            <CardDescription className="text-slate-400">
              Link your ShopRenter shop to start managing AI-powered customer calls
            </CardDescription>
          </div>
        </div>
      </CardHeader>
      <CardContent className="space-y-6">
        {/* Information about connecting via ShopRenter Admin */}
        <div className="bg-cyan-500/10 border border-cyan-500/30 rounded-lg p-4 space-y-3">
          <div className="flex items-start gap-3">
            <Info className="w-5 h-5 text-cyan-500 mt-0.5 flex-shrink-0" />
            <div className="space-y-2">
              <h4 className="text-white font-medium">Install from ShopRenter App Store</h4>
              <p className="text-sm text-slate-300">
                ShopRenter stores can only be connected through the ShopRenter admin panel.
                Please install our application from the ShopRenter App Store to connect your store.
              </p>
            </div>
          </div>
        </div>

        {/* How to Connect Steps */}
        <div className="bg-slate-700/50 rounded-lg p-4 space-y-3">
          <h4 className="text-white font-medium flex items-center gap-2">
            <ExternalLink className="w-4 h-4 text-cyan-500" />
            How to connect your store
          </h4>
          <ul className="space-y-2 text-sm text-slate-300">
            <li className="flex items-start gap-2">
              <span className="text-cyan-500 mt-0.5">1.</span>
              <span>Log in to your ShopRenter admin panel</span>
            </li>
            <li className="flex items-start gap-2">
              <span className="text-cyan-500 mt-0.5">2.</span>
              <span>Navigate to the App Store section</span>
            </li>
            <li className="flex items-start gap-2">
              <span className="text-cyan-500 mt-0.5">3.</span>
              <span>Search for "ShopCall.ai" and click Install</span>
            </li>
            <li className="flex items-start gap-2">
              <span className="text-cyan-500 mt-0.5">4.</span>
              <span>Grant the necessary permissions for AI caller integration</span>
            </li>
            <li className="flex items-start gap-2">
              <span className="text-cyan-500 mt-0.5">5.</span>
              <span>You'll be redirected back to ShopCall.ai to complete the setup</span>
            </li>
          </ul>
        </div>

        {/* Required Permissions */}
        <div className="bg-slate-700/50 rounded-lg p-4 space-y-3">
          <h4 className="text-white font-medium">Required Permissions</h4>
          <div className="grid grid-cols-2 gap-2 text-sm text-slate-300">
            <div className="flex items-center gap-2">
              <CheckCircle2 className="w-4 h-4 text-green-500" />
              <span>Read Products</span>
            </div>
            <div className="flex items-center gap-2">
              <CheckCircle2 className="w-4 h-4 text-green-500" />
              <span>Write Products</span>
            </div>
            <div className="flex items-center gap-2">
              <CheckCircle2 className="w-4 h-4 text-green-500" />
              <span>Read Orders</span>
            </div>
            <div className="flex items-center gap-2">
              <CheckCircle2 className="w-4 h-4 text-green-500" />
              <span>Write Orders</span>
            </div>
            <div className="flex items-center gap-2">
              <CheckCircle2 className="w-4 h-4 text-green-500" />
              <span>Read Customers</span>
            </div>
            <div className="flex items-center gap-2">
              <CheckCircle2 className="w-4 h-4 text-green-500" />
              <span>Write Customers</span>
            </div>
          </div>
          <p className="text-xs text-slate-400">
            These permissions allow our AI assistant to access your store data and provide accurate customer support.
          </p>
        </div>

        {/* App Store Link Placeholder - to be updated with actual link */}
        {/* TODO: Add link to ShopRenter App Store when available */}
        {/* <Button
          className="w-full bg-cyan-500 hover:bg-cyan-600 text-white"
          onClick={() => window.open('https://app-store-link', '_blank')}
        >
          <ExternalLink className="w-4 h-4 mr-2" />
          Go to ShopRenter App Store
        </Button> */}

        {/* Close Button */}
        {onClose && (
          <Button
            variant="outline"
            onClick={onClose}
            className="w-full border-slate-600 text-slate-300 hover:bg-slate-700"
          >
            Close
          </Button>
        )}
      </CardContent>
    </Card>
  );
}
