import React from 'react';

/**
 * D8. 保险与消费者保护 - 平台保障体系管理
 *
 * 消费者保护基金、保险机制、赔付记录、IPO准备度
 */

const protectionStats = [
  { label: '消费者保护基金', value: '$2,345,678', color: 'var(--color-success)' },
  { label: '本月赔付', value: '$12,340', color: 'var(--color-warning)' },
  { label: '赔付率', value: '0.08%', color: 'var(--color-info)' },
  { label: 'IPO准备度', value: '72%', color: 'var(--color-primary)' },
];

const recentClaims = [
  { id: 'CLM-001', user: 'User#12345', reason: '发行方破产', amount: '$250', status: '已赔付', date: '2026-02-08' },
  { id: 'CLM-002', user: 'User#23456', reason: '券核销失败', amount: '$100', status: '处理中', date: '2026-02-09' },
  { id: 'CLM-003', user: 'User#34567', reason: '重复扣款', amount: '$42.50', status: '已赔付', date: '2026-02-07' },
];

const ipoChecklist = [
  { item: 'SOX合规审计', status: 'done' },
  { item: '消费者保护机制', status: 'done' },
  { item: 'AML/KYC合规体系', status: 'done' },
  { item: 'SEC披露文件准备', status: 'progress' },
  { item: '独立审计报告', status: 'progress' },
  { item: '市场做市商协议', status: 'pending' },
  { item: '牌照申请', status: 'pending' },
];

export const InsurancePage: React.FC = () => {
  return (
    <div>
      <h1 style={{ font: 'var(--text-h1)', color: 'var(--color-text-primary)', marginBottom: 24 }}>保险与消费者保护</h1>

      {/* Stats */}
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16, marginBottom: 24 }}>
        {protectionStats.map(s => (
          <div key={s.label} style={{
            background: 'var(--color-surface)', borderRadius: 'var(--radius-md)',
            border: '1px solid var(--color-border-light)', padding: 20,
          }}>
            <div style={{ font: 'var(--text-body-sm)', color: 'var(--color-text-tertiary)', marginBottom: 8 }}>{s.label}</div>
            <div style={{ font: 'var(--text-h1)', color: s.color }}>{s.value}</div>
          </div>
        ))}
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 24 }}>
        {/* Claims */}
        <div style={{ background: 'var(--color-surface)', borderRadius: 'var(--radius-md)', border: '1px solid var(--color-border-light)', padding: 20 }}>
          <h2 style={{ font: 'var(--text-h2)', marginBottom: 16 }}>最近赔付记录</h2>
          <table style={{ width: '100%', borderCollapse: 'collapse' }}>
            <thead>
              <tr>{['编号', '用户', '原因', '金额', '状态'].map(h => (
                <th key={h} style={{ padding: '8px 0', textAlign: 'left', font: 'var(--text-label-sm)', color: 'var(--color-text-tertiary)', borderBottom: '1px solid var(--color-border-light)' }}>{h}</th>
              ))}</tr>
            </thead>
            <tbody>
              {recentClaims.map(c => (
                <tr key={c.id} style={{ borderBottom: '1px solid var(--color-border-light)' }}>
                  <td style={{ padding: '10px 0', fontFamily: 'var(--font-family-mono)', font: 'var(--text-body-sm)' }}>{c.id}</td>
                  <td style={{ padding: '10px 0', font: 'var(--text-body)' }}>{c.user}</td>
                  <td style={{ padding: '10px 0', font: 'var(--text-body)' }}>{c.reason}</td>
                  <td style={{ padding: '10px 0', font: 'var(--text-label)', color: 'var(--color-error)' }}>{c.amount}</td>
                  <td style={{ padding: '10px 0' }}>
                    <span style={{
                      padding: '2px 8px', borderRadius: 'var(--radius-full)', font: 'var(--text-caption)', fontWeight: 600,
                      background: c.status === '已赔付' ? 'var(--color-success-light)' : 'var(--color-warning-light)',
                      color: c.status === '已赔付' ? 'var(--color-success)' : 'var(--color-warning)',
                    }}>{c.status}</span>
                  </td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>

        {/* IPO Readiness */}
        <div style={{ background: 'var(--color-surface)', borderRadius: 'var(--radius-md)', border: '1px solid var(--color-border-light)', padding: 20 }}>
          <h2 style={{ font: 'var(--text-h2)', marginBottom: 16 }}>IPO准备度检查清单</h2>
          {ipoChecklist.map((item, i) => (
            <div key={i} style={{ display: 'flex', alignItems: 'center', padding: '10px 0', borderBottom: '1px solid var(--color-border-light)' }}>
              <div style={{
                width: 20, height: 20, borderRadius: '50%', marginRight: 12, display: 'flex', alignItems: 'center', justifyContent: 'center',
                background: item.status === 'done' ? 'var(--color-success)' : item.status === 'progress' ? 'var(--color-warning)' : 'var(--color-gray-200)',
                color: item.status === 'pending' ? 'var(--color-text-tertiary)' : 'white', fontSize: 12,
              }}>
                {item.status === 'done' ? '✓' : item.status === 'progress' ? '…' : '○'}
              </div>
              <span style={{ flex: 1, font: 'var(--text-body)', color: 'var(--color-text-primary)' }}>{item.item}</span>
              <span style={{
                font: 'var(--text-caption)',
                color: item.status === 'done' ? 'var(--color-success)' : item.status === 'progress' ? 'var(--color-warning)' : 'var(--color-text-tertiary)',
              }}>
                {item.status === 'done' ? '已完成' : item.status === 'progress' ? '进行中' : '待开始'}
              </span>
            </div>
          ))}
          {/* Progress Bar */}
          <div style={{ marginTop: 16 }}>
            <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
              <span style={{ font: 'var(--text-body-sm)', color: 'var(--color-text-secondary)' }}>总体进度</span>
              <span style={{ font: 'var(--text-label-sm)', color: 'var(--color-primary)' }}>72%</span>
            </div>
            <div style={{ height: 8, background: 'var(--color-gray-100)', borderRadius: 'var(--radius-full)', overflow: 'hidden' }}>
              <div style={{ width: '72%', height: '100%', background: 'var(--color-primary)', borderRadius: 'var(--radius-full)' }} />
            </div>
          </div>
        </div>
      </div>
    </div>
  );
};
