import type { Meta, StoryObj } from '@storybook/react';
import Box from '@mui/material/Box';
import { LineItem } from './LineItem';
import { Typography } from '../../atoms/Typography';
import { Divider } from '../../atoms/Divider';

const meta: Meta<typeof LineItem> = {
  title: 'Molecules/LineItem',
  component: LineItem,
  tags: ['autodocs'],
  parameters: {
    layout: 'centered',
  },
  decorators: [
    (Story) => (
      <Box sx={{ maxWidth: 500, width: '100%' }}>
        <Story />
      </Box>
    ),
  ],
};

export default meta;
type Story = StoryObj<typeof LineItem>;

// --- Default -----------------------------------------------------------------

/** Basic line item with name and price */
export const Default: Story = {
  args: {
    name: 'Professional Service Fee',
    price: 1500,
    info: 'Covers coordination of the entire funeral service, liaising with clergy, cemetery, and crematorium.',
  },
};

// --- Allowance ---------------------------------------------------------------

/** Price marked with asterisk — indicates an allowance that can be customised */
export const Allowance: Story = {
  args: {
    name: 'Allowance for Coffin',
    price: 1500,
    isAllowance: true,
    info: 'This is an allowance amount. You may upgrade or change the coffin selection during your arrangement.',
  },
};

// --- No Price ----------------------------------------------------------------

/** Complimentary/included item — no price shown */
export const Complimentary: Story = {
  args: {
    name: 'Dressing Fee',
    info: 'Included at no additional charge with this package.',
  },
};

// --- Custom Price Label ------------------------------------------------------

/** Custom text instead of dollar amount */
export const CustomPriceLabel: Story = {
  args: {
    name: 'Transfer of Deceased',
    priceLabel: 'Included',
    info: 'Transfer within 50km of the funeral home.',
  },
};

// --- Total Row ---------------------------------------------------------------

/** Summary total — bold with top border */
export const Total: Story = {
  args: {
    name: 'Total',
    price: 2700,
    variant: 'total',
  },
};

// --- Package Contents --------------------------------------------------------

/** Realistic package breakdown — Essentials, Complimentary, Total, then Extras */
export const PackageContents: Story = {
  render: () => (
    <Box>
      <Typography variant="label" sx={{ mb: 2, display: 'block' }}>
        Essentials
      </Typography>
      <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
        <LineItem
          name="Accommodation"
          price={1500}
          info="Refrigerated holding of the deceased prior to the funeral service."
        />
        <LineItem
          name="Death Registration Certificate"
          price={1500}
          info="Lodgement of death registration with NSW Registry of Births, Deaths & Marriages."
        />
        <LineItem
          name="Doctor Fee for Cremation"
          price={1500}
          info="Statutory medical referee fee required for all cremations in NSW."
        />
        <LineItem
          name="NSW Government Levy — Cremation"
          price={1500}
          info="NSW Government cremation levy as set by the Department of Health."
        />
        <LineItem
          name="Professional Mortuary Care"
          price={1500}
          info="Preparation and care of the deceased."
        />
        <LineItem
          name="Professional Service Fee"
          price={1500}
          info="Coordination of all funeral arrangements and services."
        />
        <LineItem
          name="Allowance for Coffin"
          price={1500}
          isAllowance
          info="Allowance amount — upgrade options available during arrangement."
        />
        <LineItem
          name="Allowance for Crematorium"
          price={1500}
          isAllowance
          info="Allowance for crematorium fees — varies by location."
        />
        <LineItem
          name="Allowance for Hearse"
          price={1500}
          isAllowance
          info="Allowance for hearse transfer — distance surcharges may apply."
        />
      </Box>

      <Divider sx={{ my: 3 }} />

      <Typography variant="label" sx={{ mb: 2, display: 'block' }}>
        Complimentary Items
      </Typography>
      <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
        <LineItem
          name="Dressing Fee"
          info="Dressing and preparation of the deceased — included at no charge."
        />
        <LineItem name="Viewing Fee" info="One private family viewing — included at no charge." />
      </Box>

      <LineItem name="Total" price={13500} variant="total" />

      <Divider sx={{ my: 3 }} />

      <Typography variant="label" sx={{ mb: 2, display: 'block' }}>
        Extras
      </Typography>
      <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
        <LineItem
          name="Allowance for Flowers"
          price={1500}
          isAllowance
          info="Seasonal floral arrangements for the service."
        />
        <LineItem
          name="Allowance for Master of Ceremonies"
          price={1500}
          isAllowance
          info="Professional celebrant or MC for the funeral service."
        />
        <LineItem
          name="After Business Hours Service Surcharge"
          price={1500}
          info="Additional fee for services held outside standard business hours."
        />
        <LineItem
          name="After Hours Prayers"
          price={1500}
          info="Evening prayer service at the funeral home."
        />
        <LineItem
          name="Coffin Bearing by Funeral Directors"
          price={1500}
          info="Professional pallbearing by funeral directors."
        />
        <LineItem
          name="Digital Recording"
          price={1500}
          info="Professional video recording of the funeral service."
        />
      </Box>
    </Box>
  ),
};
