// components/provider-card.jsx — service-provider data + the reusable provider summary card.
// Shared by the explore / provider-list screens and the booking flow.
// category: 探索大分類 key (sitter/behavior/groom/vet) · city/districts: 服務地區 · services: 可提供的服務項目

const PROVIDERS = [
  { id: 'lin',  name: '林依婷',     role: '到府保姆',   category: 'sitter',   city: '台北市', districts: ['大安', '信義', '大同'], rating: 4.9, n: 128, dist: '1.2km', price: 420,  tags: ['到府餵食', '清貓砂'],     services: ['到府餵食', '清貓砂', '餵藥', '陪玩'],        ai: true,  kind: 'person' },
  { id: 'afu',  name: '阿福獸醫',   role: '到府獸醫',   category: 'vet',      city: '台北市', districts: ['大安', '大同', '中正'], rating: 4.8, n: 86,  dist: '2.5km', price: 1200, tags: ['健康檢查', '打疫苗'],     services: ['健康檢查', '打疫苗', '採血'],                ai: false, kind: 'person' },
  { id: 'chen', name: '陳冠宇',     role: '行為諮詢師', category: 'behavior', city: '台北市', districts: ['全區'],                rating: 5.0, n: 54,  dist: '線上', price: 800,  tags: ['亂叫', '分離焦慮'],       services: ['亂叫', '分離焦慮', '多貓關係'],             ai: true,  kind: 'person', online: true },
  { id: 'wang', name: '王思婷',     role: '住宿托管',   category: 'sitter',   city: '台北市', districts: ['中山', '大同'],        rating: 4.7, n: 73,  dist: '3.1km', price: 650,  tags: ['住宿托管', '每日回報'],   services: ['住宿托管', '每日回報', '到府餵食'],         ai: false, kind: 'person' },
  { id: 'zhou', name: '周心怡',     role: '到府保姆',   category: 'sitter',   city: '台北市', districts: ['大同', '中正'],        rating: 4.8, n: 95,  dist: '0.9km', price: 400,  tags: ['到府餵食', '陪玩'],       services: ['到府餵食', '清貓砂', '陪玩'],               ai: true,  kind: 'person' },
  { id: 'li',   name: '李則安',     role: '行為諮詢師', category: 'behavior', city: '台北市', districts: ['大安', '信義'],        rating: 4.8, n: 41,  dist: '2.0km', price: 900,  tags: ['攻擊行為', '亂尿'],       services: ['攻擊行為', '亂尿', '亂叫'],                 ai: false, kind: 'person' },
  { id: 'mei',  name: '美玲貓美容', role: '美容師',     category: 'groom',    city: '台北市', districts: ['大同', '中山'],        rating: 4.9, n: 210, dist: '1.5km', price: 1100, tags: ['洗澡', '剪指甲'],         services: ['洗澡', '剪指甲', '剃毛'],                   ai: true,  kind: 'person' },
  { id: 'ali',  name: '阿狸寵物美容', role: '美容師',   category: 'groom',    city: '台北市', districts: ['信義'],                rating: 4.6, n: 88,  dist: '4.2km', price: 980,  tags: ['洗澡', '美容造型'],       services: ['洗澡', '清耳朵', '美容造型'],               ai: false, kind: 'person' },
  { id: 'he',   name: '林協和獸醫', role: '到府獸醫',   category: 'vet',      city: '台北市', districts: ['中山', '大同'],        rating: 4.9, n: 132, dist: '2.8km', price: 1500, tags: ['健康檢查', '慢性病追蹤'], services: ['健康檢查', '慢性病追蹤', '採血'],           ai: true,  kind: 'person' },
  { id: 'gao',  name: '高雅琪',     role: '到府保姆',   category: 'sitter',   city: '台北市', districts: ['信義', '松山'],        rating: 4.6, n: 62,  dist: '1.8km', price: 440,  tags: ['到府餵食', '清貓砂'],     services: ['到府餵食', '清貓砂', '陪玩'],               ai: false, kind: 'person' },
  { id: 'xu',   name: '許芷妍',     role: '住宿托管',   category: 'sitter',   city: '台北市', districts: ['大安', '文山'],        rating: 4.8, n: 110, dist: '3.4km', price: 700,  tags: ['住宿托管', '每日回報'],   services: ['住宿托管', '每日回報', '餵藥'],             ai: true,  kind: 'person' },
  { id: 'guo',  name: '郭立翔',     role: '行為諮詢師', category: 'behavior', city: '台北市', districts: ['中正', '大同'],        rating: 4.7, n: 38,  dist: '2.2km', price: 850,  tags: ['多貓關係', '緊張怕生'],   services: ['多貓關係', '緊張怕生', '亂叫'],             ai: false, kind: 'person' },
];

// loc: optional override for the location label (探索頁傳入服務地區；其它頁面沿用距離)
function ProviderCard({ p, onClick, loc }) {
  const locLabel = loc || p.dist;
  return A(Card, { onClick, pad: 13, style: { display: 'flex', gap: 12, position: 'relative' } },
    A(Avatar, { size: 56, kind: 'person', style: { borderRadius: 16 } }),
    A('div', { style: { flex: 1, minWidth: 0 } },
      A('div', { style: { display: 'flex', alignItems: 'center', gap: 7 } },
        A('span', { style: { fontSize: 15, fontWeight: 700 } }, p.name),
        A('span', { style: { fontSize: 11, color: 'var(--ink3)' } }, p.role)),
      A('div', { style: { display: 'flex', alignItems: 'center', gap: 6, margin: '4px 0 7px' } },
        A(Stars, { value: p.rating, size: 12 }),
        A('span', { className: 'num', style: { fontSize: 12, fontWeight: 700 } }, p.rating),
        A('span', { style: { fontSize: 11, color: 'var(--ink3)' } }, `(${p.n})`),
        locLabel && A('span', { style: { fontSize: 11, color: 'var(--ink3)', display: 'inline-flex', alignItems: 'center', gap: 2 } },
          A(Icon, { name: 'pin', size: 12 }), locLabel)),
      A('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
        p.tags.map(t => A('span', { key: t, style: { fontSize: 11, fontWeight: 600, color: 'var(--ink2)', background: 'var(--bgSoft)', padding: '3px 9px', borderRadius: 'var(--rpill)' } }, t)))),
    A('div', { style: { textAlign: 'right', alignSelf: 'flex-end', flexShrink: 0 } },
      A('div', { className: 'num', style: { fontSize: 16, fontWeight: 800, color: 'var(--accentDeep)' } }, `$${p.price}`),
      A('div', { style: { fontSize: 10, color: 'var(--ink3)' } }, '起 / 次')));
}

Object.assign(window, { PROVIDERS, ProviderCard });
