import React from 'react';

import { Card, CardContent } from '@/components/ui/card';
import { cn } from '@/lib/utils';

type TenantHeroCardProps = {
  badge?: string;
  title: string;
  description?: string;
  supporting?: string[];
  primaryAction?: React.ReactNode;
  secondaryAction?: React.ReactNode;
  aside?: React.ReactNode;
  children?: React.ReactNode;
  className?: string;
};

export function TenantHeroCard({
  badge,
  title,
  description,
  supporting,
  primaryAction,
  secondaryAction,
  aside,
  children,
  className,
}: TenantHeroCardProps) {
  return (
    <Card
      className={cn(
        'relative overflow-hidden border border-slate-200/80 bg-white text-slate-900 shadow-xl shadow-rose-200/30 backdrop-blur',
        'dark:border-white/10 dark:bg-slate-950/90 dark:text-slate-100',
        className
      )}
    >
      <div
        aria-hidden
        className="pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_top,_rgba(255,137,170,0.18),_transparent_55%),radial-gradient(ellipse_at_bottom,_rgba(99,102,241,0.16),_transparent_65%)] motion-safe:animate-[aurora_18s_ease-in-out_infinite] dark:hidden"
      />
      <div aria-hidden className="absolute inset-0 bg-gradient-to-br from-rose-50/70 via-white to-sky-50/70 dark:hidden" />
      <div aria-hidden className="absolute inset-0 hidden bg-gradient-to-br from-slate-950/80 via-slate-900/20 to-transparent mix-blend-overlay dark:block" />

      <CardContent className="relative z-10 flex flex-col gap-8 px-6 py-8 lg:flex-row lg:items-start lg:justify-between lg:px-10 lg:py-12">
        <div className="max-w-2xl space-y-6">
          {badge ? (
            <span className="inline-flex items-center gap-2 rounded-full border border-rose-100 bg-rose-50/80 px-4 py-1 text-xs font-semibold uppercase tracking-[0.35em] text-rose-600 dark:border-white/30 dark:bg-white/15 dark:text-white">
              {badge}
            </span>
          ) : null}

          <div className="space-y-3 text-slate-700 dark:text-slate-100">
            <h1 className="font-display text-3xl font-semibold tracking-tight text-slate-900 dark:text-white sm:text-4xl">{title}</h1>
            {description ? <p className="text-sm text-slate-600 dark:text-white/75 sm:text-base">{description}</p> : null}
            {supporting?.map((paragraph) => (
              <p key={paragraph} className="text-sm text-slate-600 dark:text-white/75 sm:text-base">
                {paragraph}
              </p>
            ))}
            {children}
          </div>

          {(primaryAction || secondaryAction) && (
            <div className="flex flex-wrap gap-3">
              {primaryAction}
              {secondaryAction}
            </div>
          )}
        </div>

        {aside ? <div className="w-full max-w-sm">{aside}</div> : null}
      </CardContent>
    </Card>
  );
}

export const tenantHeroPrimaryButtonClass = cn(
  'rounded-full bg-rose-600 px-6 text-sm font-semibold text-white shadow-md shadow-rose-400/30 transition-colors',
  'hover:bg-rose-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-300 focus-visible:ring-offset-2 focus-visible:ring-offset-white',
  'dark:focus-visible:ring-offset-slate-950'
);

export const tenantHeroSecondaryButtonClass = cn(
  'rounded-full border border-slate-200/80 bg-white/95 px-6 text-sm font-semibold text-slate-700 shadow-sm transition-colors',
  'hover:bg-rose-50 hover:text-rose-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-200 focus-visible:ring-offset-2 focus-visible:ring-offset-white',
  'dark:border-white/20 dark:bg-white/10 dark:text-white dark:hover:bg-white/20 dark:focus-visible:ring-offset-slate-950'
);
