import { Download, Filter, Search } from 'lucide-react';

import { Barcode, MockAvatar, MockBadge, MockRateRow, MockStatus, MockTimeline, mockRates } from '@/components/marketing/mock-ui';
import { cn } from '@/lib/utils';

/** Larger code-built mocks for the features page. Static illustration values only. */
export function FeatureMock({ kind }: { kind: string }) {
  if (kind === 'Compare rates') {
    return (
      <div>
        <div className="mb-3 flex items-center justify-between">
          <p className="text-small font-semibold">Berlin → Toronto · 2.4 kg</p>
          <MockBadge tone="primary">3 services</MockBadge>
        </div>
        <div className="grid gap-2">
          {mockRates.map((rate) => (
            <MockRateRow key={rate.name} rate={rate} badge={rate.selected ? <MockBadge tone="success">Cheapest</MockBadge> : undefined} />
          ))}
        </div>
      </div>
    );
  }

  if (kind === 'Labels in one click') {
    return (
      <div className="mx-auto max-w-sm rounded-lg border border-border bg-surface p-5 shadow-sm">
        <div className="flex items-center justify-between border-b border-dashed border-border-strong pb-3">
          <span className="font-display text-small font-extrabold">PRIORITY INTL.</span>
          <span className="rounded-sm border-2 border-foreground px-1.5 text-caption font-extrabold">P</span>
        </div>
        <div className="grid grid-cols-2 gap-4 border-b border-dashed border-border-strong py-3 text-caption">
          <div>
            <p className="text-[10px] font-semibold uppercase tracking-[0.12em] text-subtle-foreground">From</p>
            <p className="mt-0.5 font-medium">Berlin, DE</p>
          </div>
          <div>
            <p className="text-[10px] font-semibold uppercase tracking-[0.12em] text-subtle-foreground">To</p>
            <p className="mt-0.5 font-medium">Toronto, CA</p>
          </div>
        </div>
        <Barcode className="mt-4 h-16" bars={42} />
        <p className="mt-2 text-center font-mono text-caption tracking-[0.24em] text-muted-foreground">SHP 1042 7781 DE</p>
        <span className="mt-4 flex items-center justify-center gap-1.5 rounded-md bg-brand-gradient px-3 py-2 text-caption font-semibold text-primary-foreground shadow-sm">
          <Download className="h-3.5 w-3.5" aria-hidden="true" />
          Download label
        </span>
      </div>
    );
  }

  if (kind === 'Live tracking') {
    return (
      <div className="rounded-lg border border-border bg-surface p-5">
        <div className="flex items-center justify-between">
          <span className="font-mono text-small font-semibold">SHP10427781DE</span>
          <MockStatus status="Out for delivery" />
        </div>
        <div className="mt-4 h-1.5 overflow-hidden rounded-pill bg-surface-muted">
          <div className="h-full w-[85%] rounded-pill bg-brand-gradient" />
        </div>
        <MockTimeline
          className="mt-5"
          currentIndex={3}
          events={[
            { title: 'Label created', meta: 'Berlin, DE · Mon 09:12' },
            { title: 'Picked up', meta: 'Berlin Hub, DE · Mon 16:40' },
            { title: 'Arrived at destination', meta: 'Toronto, CA · Wed 22:10' },
            { title: 'Out for delivery', meta: 'Toronto, CA · Thu 08:02' },
          ]}
        />
      </div>
    );
  }

  if (kind === 'Prepaid wallet') {
    return (
      <div className="overflow-hidden rounded-lg border border-border bg-surface">
        <div className="flex items-end justify-between bg-surface-muted px-4 py-4">
          <div>
            <p className="text-caption text-muted-foreground">Available balance</p>
            <p className="font-display text-h1 font-extrabold tabular-nums">250.00</p>
          </div>
          <span className="rounded-md bg-brand-gradient px-3 py-1.5 text-caption font-semibold text-primary-foreground shadow-sm">Top up</span>
        </div>
        <div className="grid grid-cols-[minmax(0,1fr)_auto_auto] gap-x-4 px-4 py-2 text-[10px] font-semibold uppercase tracking-[0.12em] text-subtle-foreground">
          <span>Entry</span>
          <span>Date</span>
          <span className="text-right">Amount</span>
        </div>
        {[
          { label: 'Top up', date: '12 Nov', amount: '+100.00', positive: true },
          { label: 'Label SH-1042', date: '12 Nov', amount: '−36.90', positive: false },
          { label: 'Refund SH-1038', date: '11 Nov', amount: '+15.60', positive: true },
          { label: 'Label SH-1037', date: '10 Nov', amount: '−18.40', positive: false },
        ].map((row) => (
          <div key={row.label} className="grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-x-4 border-t border-border px-4 py-2.5 text-small">
            <span className="truncate font-medium">{row.label}</span>
            <span className="text-caption text-muted-foreground">{row.date}</span>
            <span className={cn('text-right font-semibold tabular-nums', row.positive ? 'text-success' : 'text-foreground')}>{row.amount}</span>
          </div>
        ))}
      </div>
    );
  }

  if (kind === 'Team access') {
    return (
      <div className="grid gap-2">
        {[
          { name: 'Ava Chen', email: 'ava@example.com', role: 'Owner', tone: 'primary' as const },
          { name: 'Noah Berg', email: 'noah@example.com', role: 'Admin', tone: 'info' as const },
          { name: 'Mia Ortiz', email: 'mia@example.com', role: 'Member', tone: 'success' as const },
          { name: 'Leo Park', email: 'leo@example.com', role: 'Viewer', tone: 'neutral' as const },
        ].map((member) => (
          <div key={member.name} className="flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2.5">
            <MockAvatar initials={member.name.split(' ').map((part) => part[0]).join('')} className="rounded-full" />
            <div className="min-w-0 flex-1">
              <p className="truncate text-small font-semibold">{member.name}</p>
              <p className="truncate text-caption text-muted-foreground">{member.email}</p>
            </div>
            <MockBadge tone={member.tone}>{member.role}</MockBadge>
          </div>
        ))}
      </div>
    );
  }

  return (
    <div className="overflow-hidden rounded-lg border border-border bg-surface">
      <div className="flex flex-wrap items-center gap-2 border-b border-border px-3 py-2.5">
        <span className="inline-flex h-8 flex-1 items-center gap-2 rounded-md border border-border px-2.5 text-caption text-subtle-foreground">
          <Search className="h-3.5 w-3.5" aria-hidden="true" />
          Search
        </span>
        <span className="inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-caption text-muted-foreground">
          <Filter className="h-3.5 w-3.5" aria-hidden="true" />
          Filters
        </span>
      </div>
      <div className="flex flex-wrap gap-1.5 border-b border-border bg-surface-muted px-3 py-2">
        {['Status: In transit', 'Courier: Any', 'Last 30 days'].map((chip, index) => (
          <span
            key={chip}
            className={cn('rounded-pill px-2.5 py-0.5 text-caption font-semibold', index === 0 ? 'bg-primary-soft text-primary' : 'bg-surface text-muted-foreground')}
          >
            {chip}
          </span>
        ))}
      </div>
      {[
        { id: 'SH-1042', city: 'Toronto, CA', status: 'Label ready' },
        { id: 'SH-1041', city: 'Oslo, NO', status: 'In transit' },
        { id: 'SH-1040', city: 'Lyon, FR', status: 'Delivered' },
        { id: 'SH-1039', city: 'Austin, US', status: 'Exception' },
      ].map((row) => (
        <div key={row.id} className="flex items-center gap-3 border-t border-border px-3 py-2.5 text-small first-of-type:border-t-0">
          <span className="font-mono font-semibold">{row.id}</span>
          <span className="flex-1 truncate text-muted-foreground">{row.city}</span>
          <MockStatus status={row.status} />
        </div>
      ))}
    </div>
  );
}
