import type { ReactNode } from 'react';
import {
  Badge,
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableFooter,
  TableHead,
  TableHeader,
  TableRow,
} from 'cloudrite';

// Cloudrite is dark-only — foreground-coloured text and `border-border` are
// invisible on the preview harness's white card body. Stories render on the
// brand surface, which is also how a real screen is built.
const Surface = ({ children }: { children: ReactNode }) => (
  <div className="bg-background text-foreground rounded-lg p-6">{children}</div>
);

const invoices = [
  ['CR-1042', 'Managed WordPress', 'Paid', '$149.00'],
  ['CR-1041', 'Cloud Hosting — Business', 'Paid', '$89.00'],
  ['CR-1040', 'On-site callout (2 hrs)', 'Overdue', '$240.00'],
  ['CR-1039', 'Domain renewal', 'Paid', '$38.00'],
];

export const Default = () => (
  <Surface>
    <Table>
      <TableCaption>Recent invoices</TableCaption>
      <TableHeader>
        <TableRow>
          <TableHead>Invoice</TableHead>
          <TableHead>Service</TableHead>
          <TableHead>Status</TableHead>
          <TableHead className="text-right">Amount</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {invoices.map(([id, service, status, amount]) => (
          <TableRow key={id}>
            <TableCell className="font-medium">{id}</TableCell>
            <TableCell>{service}</TableCell>
            <TableCell>
              <Badge variant={status === 'Paid' ? 'secondary' : 'destructive'}>{status}</Badge>
            </TableCell>
            <TableCell className="text-right">{amount}</TableCell>
          </TableRow>
        ))}
      </TableBody>
      <TableFooter>
        <TableRow>
          <TableCell colSpan={3}>Total</TableCell>
          <TableCell className="text-right">$516.00</TableCell>
        </TableRow>
      </TableFooter>
    </Table>
  </Surface>
);
