import { define } from '../../src'
import { Layout } from './helpers'
import { ButtonExamplesContent } from '../button'
import { ProfileExamplesContent } from '../profile'
import { NavigationExamplesContent } from '../navigation'
import { FormExamplesContent } from '../form'

const P = define('SSR_P', {
  color: '#6b7280',
  fontSize: 18,
  marginBottom: 48,
})

const ExamplesGrid = define('SSR_ExamplesGrid', {
  display: 'grid',
  gap: 20,
  gridTemplateColumns: 'repeat(auto-fill, minmax(300px, 1fr))'
})

const ExampleCard = define('SSR_ExampleCard', {
  base: 'a',

  background: 'white',
  padding: 24,
  borderRadius: 12,
  boxShadow: '0 1px 3px rgba(0,0,0,0.1)',
  textDecoration: 'none',
  transition: 'all 0.2s ease',
  display: 'block',

  states: {
    hover: {
      transform: 'translateY(-2px)',
      boxShadow: '0 4px 12px rgba(0,0,0,0.15)'
    }
  },

  parts: {
    H2: {
      color: '#111827',
      margin: '0 0 8px 0',
      fontSize: 20,
    },
    P: {
      color: '#6b7280',
      margin: 0,
      fontSize: 14,
    }
  },

  render({ props: { title, desc, ...rest }, parts: { Root, H2, P } }) {
    return (
      <Root {...rest}>
        <H2>{title}</H2>
        <P>{desc}</P>
      </Root>
    )
  }
})

export const IndexPage = ({ path }: any) => (
  <Layout title="Forge Examples" path={path}>
    <P>Explore component examples built with Forge</P>

    <ExamplesGrid>
      <ExampleCard href="/ssr/profile"
        title="Profile Card"
        desc="User profile component with variants for size, theme, and verified status"
      />

      <ExampleCard href="/ssr/buttons"
        title="Buttons"
        desc="Button component with intent, size, and disabled variants"
      />

      <ExampleCard href="/ssr/navigation"
        title="Navigation"
        desc="Navigation patterns including tabs, pills, vertical nav, and breadcrumbs"
      />

      <ExampleCard href="/ssr/form"
        title="Forms"
        desc="Form inputs with validation states, checkboxes, textareas, and buttons"
      />
    </ExamplesGrid>
  </Layout>
)

export const ButtonExamplesPage = ({ path }: any) => (
  <Layout title="Forge Button Component Examples" path={path}>
    <ButtonExamplesContent />
  </Layout>
)

export const ProfileExamplesPage = ({ path }: any) => (
  <Layout title="Forge Profile Examples" path={path}>
    <ProfileExamplesContent />
  </Layout>
)

export const NavigationExamplesPage = ({ path }: any) => (
  <Layout title="Forge Navigation Examples" path={path}>
    <NavigationExamplesContent />
  </Layout>
)

export const FormExamplesPage = ({ path }: any) => (
  <Layout title="Forge Form Examples" path={path}>
    <FormExamplesContent />
  </Layout>
)
