// Terms & Conditions page — reached only from the footer link (/terms-and-conditions)

const RTO = 'Allens Training Pty Ltd RTO 90909';

const TERMS = [
  { title: '1. Bookings and Payment', list: [
    'All course bookings are subject to availability and confirmation by Pindan Training.',
    'Public course bookings require full payment at the time of booking unless otherwise agreed.',
    'Corporate and group bookings will be invoiced in accordance with the agreed quotation and payment terms.',
    'All applicable training fees and additional charges will be communicated before booking confirmation.'
  ] },
  { title: '2. Minimum Participant Numbers', list: [
    'Public courses may require a minimum number of participants to proceed.',
    'Corporate and onsite training bookings may be subject to minimum participant numbers or a minimum booking fee.',
    'Any minimum requirements will be communicated at the time of quotation or booking.',
    'Where a minimum booking fee has been agreed, this fee remains payable regardless of actual attendance, subject to applicable consumer law.'
  ] },
  { title: '3. Cancellations and Refunds',
    body: ['The following cancellation policy applies to all individual, public, corporate and group training bookings.'],
    table: {
      head: ['Cancellation Notice', 'Cancellation Fee', 'Refund'],
      rows: [
        ['48 hours or more before training', '0%', '100%'],
        ['24 hours to less than 48 hours', '50%', '50%'],
        ['Less than 24 hours', 'Up to 100%', 'Any remaining amount'],
        ['Non-attendance without notice', 'Up to 100%', 'Any remaining amount']
      ]
    },
    after: ['Cancellation fees are subject to applicable law and must be reasonable and proportionate to the circumstances.'],
    subs: [
      { title: 'Corporate, Onsite and Remote Training Bookings', body: [
        'For bookings requiring travel, accommodation, equipment freight or other additional arrangements, Pindan Training reserves the right to recover reasonable, non-refundable expenses already incurred as a result of the booking, including where cancellation occurs more than 48 hours before training.',
        'Any such expenses must have been disclosed and agreed upon before booking and will be charged only to the extent permitted by law. These expenses will be considered separately from standard cancellation fees, with no double recovery of costs.'
      ] },
      { title: 'Cancellation Requests and Transfers', list: [
        'All cancellations must be submitted in writing to info@pindantraining.com.au.',
        'Notice periods are calculated from the scheduled commencement time of training.',
        'Requests to transfer to another course date may be considered subject to availability.',
        'Participant substitutions may be accepted where sufficient notice is provided and the replacement participant meets all course requirements.'
      ] }
    ] },
  { title: '4. Course Cancellation or Rescheduling by Pindan Training',
    body: ['Pindan Training may cancel or reschedule training due to circumstances including:'],
    list: [
      'Insufficient participant numbers.',
      'Trainer illness or unavailability.',
      'Severe weather or unsafe conditions.',
      'Venue, equipment or logistical issues.',
      'Other unforeseen circumstances beyond our reasonable control.'
    ],
    after: [
      'Pindan Training will endeavour to provide as much notice as reasonably possible.',
      'Where Pindan Training cancels a course and cannot provide the agreed service, clients and participants will be offered a full refund or an alternative training date, subject to applicable consumer law.'
    ] },
  { title: '5. Online Learning and Pre-Course Requirements', list: [
    'Some courses include online theory or pre-course learning that must be completed before attending practical training.',
    'Participants must complete all required pre-course components by the communicated deadline.',
    'Failure to complete mandatory pre-course requirements may prevent participation in practical assessment.',
    'Additional training or reassessment fees may apply where further sessions are required. Any applicable fees will be communicated in advance.'
  ] },
  { title: '6. Participant Requirements',
    body: ['Participants must:'],
    list: [
      'Provide a valid Unique Student Identifier (USI) where required.',
      'Attend and participate in all required training and assessment activities.',
      'Follow reasonable safety instructions provided by the trainer.',
      'Meet the practical and assessment requirements of their enrolled course, with reasonable adjustments considered where appropriate and permitted.',
      'Notify Pindan Training before the course of any additional learning or accessibility support they may require, where possible.'
    ] },
  { title: '7. Assessment and Certification', list: [
    'Nationally recognised training is delivered through ' + RTO + '.',
    'Participants must satisfactorily complete all required assessment components to be deemed competent.',
    'Attendance alone does not guarantee competency or certification.',
    'Statements of Attainment are issued by ' + RTO + '.'
  ] }
];

const termsText = { fontFamily: 'var(--font-body)', fontSize: 16, lineHeight: 1.7, color: 'var(--stone)', margin: 0, maxWidth: '72ch' };

const TermsList = ({ items }) => (
  <ul style={{ display: 'grid', gap: 10, margin: 0, padding: 0, listStyle: 'none', maxWidth: '72ch' }}>
    {items.map((li, i) => (
      <li key={i} style={{ display: 'grid', gridTemplateColumns: '18px minmax(0, 1fr)', gap: 12, alignItems: 'start', ...termsText }}>
        <span aria-hidden="true" style={{ width: 7, height: 7, marginTop: 10, background: 'var(--pindan-red)', borderRadius: 1 }}></span>
        <span>{li}</span>
      </li>
    ))}
  </ul>
);

const TermsTable = ({ head, rows }) => (
  <div style={{ overflowX: 'auto', maxWidth: '72ch' }}>
    <table style={{ width: '100%', borderCollapse: 'collapse', fontFamily: 'var(--font-body)', fontSize: 15, minWidth: 460 }}>
      <thead>
        <tr>
          {head.map(h => (
            <th key={h} scope="col" style={{ textAlign: 'left', padding: '12px 14px', background: 'var(--char)', color: 'var(--bone)', fontWeight: 600, fontSize: 13, letterSpacing: '0.04em' }}>{h}</th>
          ))}
        </tr>
      </thead>
      <tbody>
        {rows.map((r, i) => (
          <tr key={i} style={{ background: i % 2 ? 'var(--bone)' : 'var(--bone-deep)' }}>
            {r.map((c, j) => (
              <td key={j} style={{ padding: '12px 14px', color: j === 0 ? 'var(--char)' : 'var(--stone)', borderBottom: '1px solid var(--border-strong)', lineHeight: 1.45 }}>{c}</td>
            ))}
          </tr>
        ))}
      </tbody>
    </table>
  </div>
);

const TermsBlock = ({ body = [], list, table, after = [] }) => (
  <>
    {body.map((p, i) => <p key={'b' + i} style={termsText}>{p}</p>)}
    {list && <TermsList items={list} />}
    {table && <TermsTable {...table} />}
    {after.map((p, i) => <p key={'a' + i} style={termsText}>{p}</p>)}
  </>
);

const TermsPage = () => (
  <>
    <section style={{ background: 'var(--bone-deep)', padding: '64px 0 56px', borderBottom: '1px solid var(--border-strong)' }}>
      <Container narrow>
        <Eyebrow rule style={{ marginBottom: 20 }}>Pindan Training</Eyebrow>
        <h1 style={{ fontFamily: 'var(--font-display)', fontWeight: 400, fontSize: 'clamp(40px, 5vw, 64px)', lineHeight: 1.0, letterSpacing: '-0.015em', color: 'var(--char)', margin: '0 0 28px' }}>
          Terms &amp; Conditions
        </h1>
        <dl style={{ display: 'grid', gridTemplateColumns: 'max-content minmax(0, 1fr)', gap: '8px 20px', margin: 0, fontFamily: 'var(--font-body)', fontSize: 15 }}>
          {[
            ['ABN', '35 270 229 860'],
            ['Registered Training Organisation', RTO],
            ['Website', 'www.pindantraining.com.au'],
            ['Email', 'info@pindantraining.com.au'],
            ['Phone', '0433 764 332']
          ].map(([k, v]) => (
            <React.Fragment key={k}>
              <dt style={{ color: 'var(--stone)', fontWeight: 600 }}>{k}</dt>
              <dd style={{ margin: 0, color: 'var(--char)' }}>{v}</dd>
            </React.Fragment>
          ))}
        </dl>
      </Container>
    </section>

    <section style={{ background: 'var(--bone)', padding: '64px 0 120px' }}>
      <Container narrow>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 16, paddingBottom: 40 }}>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 400, fontSize: 'clamp(24px, 2.2vw, 30px)', lineHeight: 1.15, color: 'var(--char)', margin: 0 }}>Introduction</h2>
          <p style={termsText}>Pindan Training provides first aid and workplace safety training to individuals, businesses and organisations across the Northern Territory and Western Australia.</p>
          <p style={termsText}>Nationally recognised training is delivered in partnership with {RTO}.</p>
          <p style={termsText}>These Terms &amp; Conditions apply to all public, individual, corporate, group and onsite training bookings.</p>
        </div>
        {TERMS.map(s => (
          <section key={s.title} style={{ display: 'flex', flexDirection: 'column', gap: 16, padding: '36px 0', borderTop: '1px solid var(--border-strong)' }}>
            <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 400, fontSize: 'clamp(24px, 2.2vw, 30px)', lineHeight: 1.15, color: 'var(--char)', margin: 0 }}>{s.title}</h2>
            <TermsBlock {...s} />
            {(s.subs || []).map(sub => (
              <div key={sub.title} style={{ display: 'flex', flexDirection: 'column', gap: 12, paddingTop: 12 }}>
                <h3 style={{ fontFamily: 'var(--font-body)', fontWeight: 700, fontSize: 16, color: 'var(--char)', margin: 0 }}>{sub.title}</h3>
                <TermsBlock {...sub} />
              </div>
            ))}
          </section>
        ))}
      </Container>
    </section>
  </>
);

Object.assign(window, { TermsPage });
