// shared.jsx — design tokens, glass primitives, photos, data

// ─────────────────────────────────────────────────────────────
// Photos — Unsplash (curated for fitness / portraits)
// ─────────────────────────────────────────────────────────────
const photos = {
  coach: {
    marcus:  'https://images.unsplash.com/photo-1567013127542-490d757e51cd?w=400&q=80&auto=format&fit=crop',
    sarah:   'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=400&q=80&auto=format&fit=crop',
  },
  clients: {
    elena:   'https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=400&q=80&auto=format&fit=crop',
    james:   'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=400&q=80&auto=format&fit=crop',
    aisha:   'https://images.unsplash.com/photo-1531123897727-8f129e1688ce?w=400&q=80&auto=format&fit=crop',
    daniel:  'https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=400&q=80&auto=format&fit=crop',
    priya:   'https://images.unsplash.com/photo-1487412720507-e7ab37603c6f?w=400&q=80&auto=format&fit=crop',
    tom:     'https://images.unsplash.com/photo-1539571696357-5a69c17a67c6?w=400&q=80&auto=format&fit=crop',
    maya:    'https://images.unsplash.com/photo-1544005313-94ddf0286df2?w=400&q=80&auto=format&fit=crop',
    leo:     'https://images.unsplash.com/photo-1463453091185-61582044d556?w=400&q=80&auto=format&fit=crop',
    nora:    'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=400&q=80&auto=format&fit=crop',
    kai:     'https://images.unsplash.com/photo-1492562080023-ab3db95bfbce?w=400&q=80&auto=format&fit=crop',
  },
  hero: {
    gym1:    'https://images.unsplash.com/photo-1534438327276-14e5300c3a48?w=900&q=80&auto=format&fit=crop',
    barbell: 'https://images.unsplash.com/photo-1581009146145-b5ef050c2e1e?w=900&q=80&auto=format&fit=crop',
    squat:   'https://images.unsplash.com/photo-1574680096145-d05b474e2155?w=900&q=80&auto=format&fit=crop',
  },
};

// ─────────────────────────────────────────────────────────────
// Glass surface — the core look. "Refined" = restrained blur + tint.
// ─────────────────────────────────────────────────────────────
function Glass({
  children, style = {}, radius = 24, strength = 'normal',
  border = true, glow = false, onClick, className,
}) {
  const fills = {
    subtle: 'rgba(255,255,255,0.04)',
    normal: 'rgba(255,255,255,0.06)',
    strong: 'rgba(255,255,255,0.10)',
    solid:  'rgba(20,38,30,0.85)',
  };
  const blurs = {
    subtle: 'blur(20px) saturate(140%)',
    normal: 'blur(28px) saturate(160%)',
    strong: 'blur(36px) saturate(180%)',
    solid:  'blur(48px) saturate(180%)',
  };
  return (
    <div onClick={onClick} className={className} style={{
      position: 'relative',
      borderRadius: radius,
      background: fills[strength],
      backdropFilter: blurs[strength],
      WebkitBackdropFilter: blurs[strength],
      border: border ? '0.5px solid rgba(255,255,255,0.10)' : 'none',
      boxShadow: glow
        ? '0 1px 0 rgba(255,255,255,0.08) inset, 0 -1px 0 rgba(0,0,0,0.18) inset, 0 12px 32px rgba(0,0,0,0.28), 0 0 0 1px rgba(110,231,168,0.18), 0 0 40px rgba(110,231,168,0.12)'
        : '0 1px 0 rgba(255,255,255,0.08) inset, 0 -1px 0 rgba(0,0,0,0.18) inset, 0 8px 24px rgba(0,0,0,0.22)',
      ...style,
    }}>
      {children}
    </div>
  );
}

// Mesh/aurora background used for both client (phone wallpaper)
// and coach (web canvas). Very subtle.
function AuroraBG({ variant = 'phone', children, style = {} }) {
  // variant: 'phone' (vertical, dramatic), 'web' (horizontal, restrained)
  return (
    <div style={{
      position: 'relative', overflow: 'hidden',
      background: variant === 'phone'
        ? 'radial-gradient(120% 80% at 20% 0%, #0f3a2a 0%, #0a2419 45%, #061410 100%)'
        : 'radial-gradient(80% 60% at 80% 0%, #103527 0%, #0a1f17 50%, #050e0b 100%)',
      ...style,
    }}>
      {/* mesh blobs */}
      <div style={{
        position: 'absolute', top: '-10%', left: '-10%', width: '60%', height: '60%',
        background: 'radial-gradient(closest-side, rgba(110,231,168,0.28), transparent 70%)',
        filter: 'blur(40px)', pointerEvents: 'none',
      }} />
      <div style={{
        position: 'absolute', top: variant === 'phone' ? '30%' : '20%',
        right: '-10%', width: '50%', height: '50%',
        background: 'radial-gradient(closest-side, rgba(34,211,238,0.18), transparent 70%)',
        filter: 'blur(50px)', pointerEvents: 'none',
      }} />
      <div style={{
        position: 'absolute', bottom: '-15%', left: '20%', width: '55%', height: '55%',
        background: 'radial-gradient(closest-side, rgba(52,211,153,0.16), transparent 70%)',
        filter: 'blur(50px)', pointerEvents: 'none',
      }} />
      {/* film grain — tiny noise via SVG */}
      <div style={{
        position: 'absolute', inset: 0, opacity: 0.08, pointerEvents: 'none',
        backgroundImage: `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>")`,
      }} />
      <div style={{ position: 'relative', zIndex: 1, width: '100%', height: '100%' }}>
        {children}
      </div>
    </div>
  );
}

// Photo avatar — circle with subtle ring
function Avatar({ src, size = 40, ring = true, style = {} }) {
  return (
    <div style={{
      width: size, height: size, borderRadius: '50%',
      backgroundImage: `url(${src})`, backgroundSize: 'cover', backgroundPosition: 'center',
      boxShadow: ring ? '0 0 0 1.5px rgba(255,255,255,0.18), 0 0 0 3px rgba(0,0,0,0.25)' : 'none',
      flexShrink: 0,
      ...style,
    }} />
  );
}

// Icon set — minimal stroked line icons (Apple-style)
function Icon({ name, size = 20, color = 'currentColor', strokeWidth = 1.6, style = {} }) {
  const s = { width: size, height: size, ...style };
  const sw = strokeWidth;
  const stroke = { stroke: color, strokeWidth: sw, fill: 'none', strokeLinecap: 'round', strokeLinejoin: 'round' };
  const paths = {
    flame:  <><path d="M12 2c0 4-4 5-4 9a4 4 0 008 0c0-2-1-3-2-4 0 2-1 3-2 3 0-4 2-5 0-8z" {...stroke}/></>,
    bolt:   <><path d="M13 2L4 14h7l-1 8 9-12h-7l1-8z" {...stroke}/></>,
    chart:  <><path d="M3 17l5-5 4 4 8-8M21 8h-5M21 8v5" {...stroke}/></>,
    chat:   <><path d="M21 12a8 8 0 11-3.5-6.6L21 4l-1.4 3.5A8 8 0 0121 12z" {...stroke}/></>,
    video:  <><rect x="3" y="6" width="13" height="12" rx="2" {...stroke}/><path d="M16 10l5-3v10l-5-3" {...stroke}/></>,
    user:   <><circle cx="12" cy="8" r="4" {...stroke}/><path d="M4 21c0-4 4-7 8-7s8 3 8 7" {...stroke}/></>,
    home:   <><path d="M3 11l9-7 9 7v9a2 2 0 01-2 2h-4v-7H9v7H5a2 2 0 01-2-2v-9z" {...stroke}/></>,
    dumb:   <><path d="M6 10v4M2 11v2M22 11v2M18 10v4M6 12h12" {...stroke}/></>,
    library:<><path d="M4 4h6v16H4zM10 8h6v12h-6zM16 12h4v8h-4z" {...stroke}/></>,
    crm:    <><path d="M3 4h18v4H3zM3 12h18v8H3zM7 16h4" {...stroke}/></>,
    bell:   <><path d="M6 9a6 6 0 0112 0c0 7 3 7 3 9H3c0-2 3-2 3-9zM10 21a2 2 0 004 0" {...stroke}/></>,
    search: <><circle cx="11" cy="11" r="7" {...stroke}/><path d="M20 20l-4-4" {...stroke}/></>,
    play:   <><path d="M6 4l14 8-14 8V4z" stroke={color} strokeWidth={sw} fill={color} strokeLinejoin="round"/></>,
    plus:   <><path d="M12 5v14M5 12h14" {...stroke}/></>,
    check:  <><path d="M5 12l5 5L20 7" {...stroke}/></>,
    chevR:  <><path d="M9 6l6 6-6 6" {...stroke}/></>,
    chevD:  <><path d="M6 9l6 6 6-6" {...stroke}/></>,
    chevL:  <><path d="M15 6l-6 6 6 6" {...stroke}/></>,
    close:  <><path d="M6 6l12 12M18 6L6 18" {...stroke}/></>,
    filter: <><path d="M3 5h18M6 12h12M10 19h4" {...stroke}/></>,
    cal:    <><rect x="3" y="5" width="18" height="16" rx="2" {...stroke}/><path d="M3 9h18M8 3v4M16 3v4" {...stroke}/></>,
    cash:   <><rect x="2" y="6" width="20" height="12" rx="2" {...stroke}/><circle cx="12" cy="12" r="2.5" {...stroke}/></>,
    star:   <><path d="M12 3l2.6 5.5 6 .9-4.3 4.3 1 6L12 17l-5.4 2.8 1-6L3.3 9.4l6-.9L12 3z" {...stroke}/></>,
    target: <><circle cx="12" cy="12" r="9" {...stroke}/><circle cx="12" cy="12" r="5" {...stroke}/><circle cx="12" cy="12" r="1.5" fill={color}/></>,
    med:    <><path d="M3 12h4l3-8 4 16 3-8h4" {...stroke}/></>,
    settings: <><circle cx="12" cy="12" r="3" {...stroke}/><path d="M12 2v3M12 19v3M4.2 4.2l2.1 2.1M17.7 17.7l2.1 2.1M2 12h3M19 12h3M4.2 19.8l2.1-2.1M17.7 6.3l2.1-2.1" {...stroke}/></>,
    arrowR: <><path d="M5 12h14M13 6l6 6-6 6" {...stroke}/></>,
    mic:    <><rect x="9" y="3" width="6" height="12" rx="3" {...stroke}/><path d="M5 11a7 7 0 0014 0M12 18v3" {...stroke}/></>,
    phone:  <><path d="M5 4h4l2 5-3 2a11 11 0 005 5l2-3 5 2v4a2 2 0 01-2 2A16 16 0 013 6a2 2 0 012-2z" {...stroke}/></>,
    youtube:<><rect x="2" y="6" width="20" height="12" rx="3" {...stroke}/><path d="M10 9l5 3-5 3V9z" stroke={color} strokeWidth={sw} fill={color} strokeLinejoin="round"/></>,
    info:   <><circle cx="12" cy="12" r="9" {...stroke}/><path d="M12 8v.5M12 11v6" {...stroke}/></>,
    drag:   <><circle cx="9" cy="6" r="1.2" fill={color}/><circle cx="15" cy="6" r="1.2" fill={color}/><circle cx="9" cy="12" r="1.2" fill={color}/><circle cx="15" cy="12" r="1.2" fill={color}/><circle cx="9" cy="18" r="1.2" fill={color}/><circle cx="15" cy="18" r="1.2" fill={color}/></>,
    pin:    <><path d="M12 21s7-7 7-12a7 7 0 10-14 0c0 5 7 12 7 12z" {...stroke}/><circle cx="12" cy="9" r="2.5" {...stroke}/></>,
    warning:<><path d="M12 3l10 18H2L12 3z" {...stroke}/><path d="M12 10v5M12 18v.5" {...stroke}/></>,
  };
  return <svg viewBox="0 0 24 24" style={s} fill="none">{paths[name] || null}</svg>;
}

// ─────────────────────────────────────────────────────────────
// Exercises
// ─────────────────────────────────────────────────────────────
const exercisesToday = [
  { id: 1, name: 'Back Squat',          tag: 'Strength',  sets: 5, reps: '5', weight: 145, rpe: 8, video: 'bEv6CCg2BC8' },
  { id: 2, name: 'Romanian Deadlift',   tag: 'Strength',  sets: 4, reps: '8', weight: 110, rpe: 7, video: 'JCXUYuzwNrM' },
  { id: 3, name: 'Bulgarian Split Squat',tag: 'Unilateral',sets: 3, reps: '10/leg', weight: 24, rpe: 7, video: '2C-uNgKwPLE' },
  { id: 4, name: 'Hip Thrust',          tag: 'Glutes',    sets: 4, reps: '12', weight: 80, rpe: 7, video: 'xDmFkJxPzeM' },
  { id: 5, name: 'Walking Lunge',       tag: 'Unilateral',sets: 3, reps: '12/leg', weight: 20, rpe: 8, video: 'L8fvypPrzzs' },
  { id: 6, name: 'Leg Curl',            tag: 'Isolation', sets: 3, reps: '12', weight: 35, rpe: 8, video: '1Tq3QdYUuHs' },
  { id: 7, name: 'Standing Calf Raise', tag: 'Isolation', sets: 4, reps: '15', weight: 60, rpe: 9, video: 'YMmgqO8Jo-k' },
];
const drillsToday = [
  { id: 8, name: 'Copenhagen Plank', sets: 3, reps: '30s/side' },
  { id: 9, name: 'Banded Glute Bridge', sets: 2, reps: '20' },
  { id: 10, name: 'Cossack Squat (mobility)', sets: 2, reps: '8/side' },
];

// 1RM history (12 weeks)
const oneRMHistory = [
  { w: 1, sq: 152, dl: 175, bp: 95  },
  { w: 2, sq: 155, dl: 180, bp: 97  },
  { w: 3, sq: 158, dl: 182, bp: 100 },
  { w: 4, sq: 160, dl: 185, bp: 100 },
  { w: 5, sq: 162, dl: 188, bp: 102 },
  { w: 6, sq: 165, dl: 190, bp: 105 },
  { w: 7, sq: 168, dl: 192, bp: 105 },
  { w: 8, sq: 170, dl: 195, bp: 107 },
  { w: 9, sq: 172, dl: 198, bp: 108 },
  { w: 10,sq: 175, dl: 200, bp: 110 },
  { w: 11,sq: 178, dl: 202, bp: 112 },
  { w: 12,sq: 180, dl: 205, bp: 115 },
];

// Coach clients (CRM data)
const clientsData = [
  { id: 1,  name: 'Elena Rossi',     photo: photos.clients.elena,  plan: 'Annual',  paidThru: 'Mar 2027', nextSession: 'Today · 5:30 PM', programThrough: '2026-06-21', overdue: 0,  status: 'paid',   streak: 14 },
  { id: 2,  name: 'James Whitaker',  photo: photos.clients.james,  plan: 'Monthly', paidThru: 'May 28',   nextSession: 'Tue · 7:00 AM',  programThrough: '2026-05-24', overdue: 7,  status: 'paid',   streak: 32 },
  { id: 3,  name: 'Aisha Bennani',   photo: photos.clients.aisha,  plan: 'Quarterly',paidThru: 'Jul 12',  nextSession: 'Wed · 6:00 PM',  programThrough: '2026-05-17', overdue: 14, status: 'paid',   streak: 8  },
  { id: 4,  name: 'Daniel Park',     photo: photos.clients.daniel, plan: 'Monthly', paidThru: 'May 14',   nextSession: '—',              programThrough: '2026-05-31', overdue: 0,  status: 'overdue',streak: 0  },
  { id: 5,  name: 'Priya Shah',      photo: photos.clients.priya,  plan: 'Annual',  paidThru: 'Jan 2027', nextSession: 'Thu · 6:30 AM',  programThrough: '2026-06-14', overdue: 0,  status: 'paid',   streak: 47 },
  { id: 6,  name: 'Tom Reilly',      photo: photos.clients.tom,    plan: 'Monthly', paidThru: 'May 30',   nextSession: 'Fri · 5:00 PM',  programThrough: '2026-05-19', overdue: 12, status: 'paid',   streak: 5  },
  { id: 7,  name: 'Maya Lindgren',   photo: photos.clients.maya,   plan: 'Quarterly',paidThru: 'Aug 02',  nextSession: 'Sat · 9:00 AM',  programThrough: '2026-06-28', overdue: 0,  status: 'paid',   streak: 21 },
  { id: 8,  name: 'Leo Martín',      photo: photos.clients.leo,    plan: 'Monthly', paidThru: 'May 22',   nextSession: 'Mon · 7:00 PM',  programThrough: '2026-05-25', overdue: 6,  status: 'paid',   streak: 11 },
  { id: 9,  name: 'Nora Achebe',     photo: photos.clients.nora,   plan: 'Annual',  paidThru: 'Nov 2026', nextSession: 'Wed · 7:30 AM',  programThrough: '2026-06-07', overdue: 0,  status: 'paid',   streak: 63 },
  { id: 10, name: 'Kai Tanaka',      photo: photos.clients.kai,    plan: 'Monthly', paidThru: 'May 09',   nextSession: '—',              programThrough: '2026-05-26', overdue: 5,  status: 'overdue',streak: 0  },
];

// Exercise library — categories + moves
const libraryCats = ['All', 'Lower body', 'Upper push', 'Upper pull', 'Hinge', 'Core', 'Mobility', 'Power'];
const libraryMoves = [
  { name: 'Back Squat',         cat: 'Lower body', equip: 'Barbell', diff: 'Intermediate', tut: 'bEv6CCg2BC8' },
  { name: 'Front Squat',        cat: 'Lower body', equip: 'Barbell', diff: 'Advanced',     tut: 'tlfahNdNPPI' },
  { name: 'Bulgarian Split Sq', cat: 'Lower body', equip: 'Dumbbell',diff: 'Intermediate', tut: '2C-uNgKwPLE' },
  { name: 'Romanian Deadlift',  cat: 'Hinge',      equip: 'Barbell', diff: 'Intermediate', tut: 'JCXUYuzwNrM' },
  { name: 'Hip Thrust',         cat: 'Hinge',      equip: 'Barbell', diff: 'Beginner',     tut: 'xDmFkJxPzeM' },
  { name: 'Conventional DL',    cat: 'Hinge',      equip: 'Barbell', diff: 'Advanced',     tut: 'op9kVnSso6Q' },
  { name: 'Bench Press',        cat: 'Upper push', equip: 'Barbell', diff: 'Intermediate', tut: 'rT7DgCr-3pg' },
  { name: 'Overhead Press',     cat: 'Upper push', equip: 'Barbell', diff: 'Intermediate', tut: '2yjwXTZQDDI' },
  { name: 'Dumbbell Bench',     cat: 'Upper push', equip: 'Dumbbell',diff: 'Beginner',     tut: 'VmB1G1K7v94' },
  { name: 'Pull-up',            cat: 'Upper pull', equip: 'Bar',     diff: 'Intermediate', tut: 'eGo4IYlbE5g' },
  { name: 'Barbell Row',        cat: 'Upper pull', equip: 'Barbell', diff: 'Intermediate', tut: 'kBWAon7ItDw' },
  { name: 'Lat Pulldown',       cat: 'Upper pull', equip: 'Cable',   diff: 'Beginner',     tut: 'CAwf7n6Luuc' },
  { name: 'Copenhagen Plank',   cat: 'Core',       equip: 'Bench',   diff: 'Intermediate', tut: '6IM9R3a-Pzs' },
  { name: 'Hanging Leg Raise',  cat: 'Core',       equip: 'Bar',     diff: 'Intermediate', tut: 'Pr1ieGZ5atk' },
  { name: 'Pallof Press',       cat: 'Core',       equip: 'Cable',   diff: 'Beginner',     tut: 'AH_QZLm_0-s' },
  { name: '90/90 Hip',          cat: 'Mobility',   equip: 'None',    diff: 'Beginner',     tut: '8K8YxX9oYwI' },
  { name: 'Cossack Squat',      cat: 'Mobility',   equip: 'None',    diff: 'Intermediate', tut: 'PUmTRGUjkkk' },
  { name: 'Power Clean',        cat: 'Power',      equip: 'Barbell', diff: 'Advanced',     tut: 'KjGvwQl8tis' },
  { name: 'Box Jump',           cat: 'Power',      equip: 'Box',     diff: 'Intermediate', tut: '52r_Ul5k03g' },
  { name: 'KB Swing',           cat: 'Power',      equip: 'Kettlebell',diff:'Intermediate',tut: 'cKx8XE6a5Zw' },
];

// Templates
const templatesData = [
  { name: 'Hypertrophy · Lower A',  weeks: 4, sessions: 12, lastEdited: '2d ago', clients: 14 },
  { name: 'Powerbuild · Upper/Lwr', weeks: 8, sessions: 32, lastEdited: '1w ago', clients: 9 },
  { name: 'Posterior Chain Reset',  weeks: 3, sessions: 9,  lastEdited: '5d ago', clients: 6 },
  { name: 'Return to Lifting · ACL',weeks: 6, sessions: 18, lastEdited: '3w ago', clients: 3 },
  { name: 'In-season Athlete',      weeks: 12,sessions: 36, lastEdited: '1mo ago',clients: 5 },
  { name: 'Glute Specialization',   weeks: 6, sessions: 18, lastEdited: 'today',  clients: 11 },
];

// Messages
const messageThreads = [
  { id: 1, name: 'Marcus Thorne (Coach)', photo: photos.coach.marcus, last: 'Nice work on the 145×5. Push 147.5 next week.', time: '2m', unread: 1, online: true },
  { id: 2, name: 'Team chat — Squad A',    photo: photos.clients.maya,  last: 'Aisha: anyone doing AM session tomorrow?', time: '14m', unread: 0 },
];

const coachMessageThreads = [
  { id: 1, name: 'Elena Rossi',     photo: photos.clients.elena, last: 'Knee felt great today, thanks for the cue!', time: '2m',  unread: 2, online: true },
  { id: 2, name: 'James Whitaker',  photo: photos.clients.james, last: 'Hit 145×5 — feeling strong 💪',              time: '14m', unread: 0, online: true },
  { id: 3, name: 'Aisha Bennani',   photo: photos.clients.aisha, last: 'Sub for RDL? Lower back tight today.',       time: '1h',  unread: 1, online: false },
  { id: 4, name: 'Daniel Park',     photo: photos.clients.daniel,last: 'Can we move Thu to Fri?',                    time: '3h',  unread: 0, online: false },
  { id: 5, name: 'Priya Shah',      photo: photos.clients.priya, last: 'Form check video sent →',                    time: 'Yest',unread: 0, online: false },
  { id: 6, name: 'Tom Reilly',      photo: photos.clients.tom,   last: 'Travel next week — bodyweight plan?',        time: 'Yest',unread: 0, online: false },
];

Object.assign(window, {
  photos, Glass, AuroraBG, Avatar, Icon,
  exercisesToday, drillsToday, oneRMHistory,
  clientsData, libraryCats, libraryMoves, templatesData,
  messageThreads, coachMessageThreads,
});
