// coach-screens.jsx — web screens for coaches

// ─────────────────────────────────────────────────────────────
// CoachShell — sidebar + canvas, shared by every coach screen
// ─────────────────────────────────────────────────────────────
function CoachShell({ active = 'dashboard', children, accent = 'sky' }) {
  const accentColor = accent === 'sky' ? '#0ea5e9' : accent === 'azure' ? '#3b82f6' : '#38bdf8';
  const nav = [
    { id: 'dashboard', label: 'Dashboard', icon: 'home',    badge: 3 },
    { id: 'clients',   label: 'Clients',   icon: 'crm',     badge: 12 },
    { id: 'library',   label: 'Library',   icon: 'library' },
    { id: 'templates', label: 'Templates', icon: 'cal' },
    { id: 'inbox',     label: 'Inbox',     icon: 'chat',    badge: 4 },
    { id: 'calendar',  label: 'Calendar',  icon: 'cal' },
  ];
  return (
    <AuroraBG variant="web" style={{ width: '100%', height: '100%', display: 'flex' }}>
      {/* Sidebar */}
      <div style={{
        width: 240, padding: '20px 16px',
        display: 'flex', flexDirection: 'column', gap: 4,
        borderRight: '0.5px solid rgba(11,24,40,0.05)',
        background: 'rgba(255,255,255,0.55)',
        backdropFilter: 'blur(24px) saturate(180%)',
      }}>
        {/* logo */}
        <div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 8px 18px' }}>
          <div style={{
            width: 32, height: 32, borderRadius: 9,
            background: `linear-gradient(135deg, ${accentColor}, #22d3ee)`,
            display: 'flex', alignItems: 'center', justifyContent: 'center',
          }}>
            <Icon name="dumb" size={18} color="#fff" strokeWidth={2.2} />
          </div>
          <div>
            <div style={{ fontSize: 15, fontWeight: 600, letterSpacing: -0.2 }}>Gym app</div>
            <div style={{ fontSize: 10, color: 'var(--text-tertiary)', letterSpacing: 0.4 }}>Coach · Marcus T.</div>
          </div>
        </div>

        {nav.map(it => {
          const on = it.id === active;
          return (
            <div key={it.id} style={{
              display: 'flex', alignItems: 'center', gap: 12, padding: '9px 10px',
              borderRadius: 10, cursor: 'pointer', position: 'relative',
              background: on ? 'rgba(11,24,40,0.05)' : 'transparent',
              border: on ? '0.5px solid rgba(11,24,40,0.07)' : '0.5px solid transparent',
            }}>
              <Icon name={it.icon} size={16} color={on ? accentColor : 'rgba(11,24,40,0.50)'} />
              <div style={{ flex: 1, fontSize: 13, color: on ? 'var(--text-primary)' : 'rgba(11,24,40,0.68)', fontWeight: on ? 500 : 400 }}>{it.label}</div>
              {it.badge && (
                <div style={{
                  minWidth: 18, height: 18, padding: '0 5px', borderRadius: 9,
                  background: it.id === 'dashboard' ? '#ef4444' : 'rgba(11,24,40,0.10)',
                  fontSize: 10, fontWeight: 600,
                  color: it.id === 'dashboard' ? '#fff' : 'var(--text-secondary)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                }}>{it.badge}</div>
              )}
            </div>
          );
        })}

        <div style={{ flex: 1 }} />

        {/* user card */}
        <Glass radius={14} style={{ padding: 10, display: 'flex', alignItems: 'center', gap: 10 }}>
          <Avatar src={photos.coach.marcus} size={36} />
          <div style={{ flex: 1, minWidth: 0 }}>
            <div style={{ fontSize: 12, fontWeight: 500 }}>Marcus Thorne</div>
            <div style={{ fontSize: 10, color: 'var(--text-tertiary)' }}>Pro coach · 4.9★</div>
          </div>
          <Icon name="settings" size={14} color="rgba(11,24,40,0.42)" />
        </Glass>
      </div>

      {/* Main canvas */}
      <div style={{ flex: 1, minWidth: 0, overflowY: 'auto', overflowX: 'hidden' }}>
        {children}
      </div>
    </AuroraBG>
  );
}

// Header used inside the canvas
function CoachPageHeader({ kicker, title, subtitle, action, accent = '#6ee7a8' }) {
  return (
    <div style={{
      padding: '20px 32px', display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between',
      borderBottom: '0.5px solid rgba(11,24,40,0.05)', gap: 24,
    }}>
      <div>
        {kicker && <div style={{ fontSize: 10, color: accent, fontWeight: 600, letterSpacing: 1.4, textTransform: 'uppercase' }}>{kicker}</div>}
        <div style={{ fontFamily: 'Instrument Serif, serif', fontSize: 34, lineHeight: 1.05, letterSpacing: -0.4, marginTop: 4 }}>{title}</div>
        {subtitle && <div style={{ fontSize: 13, color: 'var(--text-secondary)', marginTop: 6, maxWidth: 560 }}>{subtitle}</div>}
      </div>
      {action}
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// HERO: Coach Dashboard — overdue-programs alert + today
// ─────────────────────────────────────────────────────────────
function CoachDashboard({ accent = 'sky' }) {
  const accentColor = accent === 'sky' ? '#0ea5e9' : accent === 'azure' ? '#3b82f6' : '#38bdf8';
  const [filterPaid, setFilterPaid] = React.useState('all');
  const [dismissedAlert, setDismissedAlert] = React.useState(false);

  const today = new Date('2026-05-17');
  const overdueClients = clientsData.filter(c => {
    const through = new Date(c.programThrough);
    const daysAhead = (through - today) / (1000 * 60 * 60 * 24);
    return daysAhead < 10;  // less than 10 days of program left
  });

  const unpaidCount = clientsData.filter(c => c.status === 'overdue').length;

  return (
    <CoachShell active="dashboard" accent={accent}>
      <CoachPageHeader
        kicker="Wednesday · May 17"
        title="Good morning, Marcus."
        subtitle="You have 4 sessions today and 12 active programs across 28 clients."
        accent={accentColor}
        action={
          <div style={{ display: 'flex', gap: 10 }}>
            <Glass radius={12} style={{ padding: '10px 16px', display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, fontWeight: 500, color: 'var(--text-secondary)' }}>
              <Icon name="search" size={14} color="rgba(11,24,40,0.42)" />
              <span style={{ color: 'var(--text-tertiary)' }}>Search clients, exercises…</span>
              <kbd style={{ marginLeft: 24, padding: '2px 6px', fontSize: 10, borderRadius: 4, background: 'rgba(11,24,40,0.05)', color: 'var(--text-tertiary)', fontFamily: 'JetBrains Mono' }}>⌘K</kbd>
            </Glass>
            <div style={{
              padding: '10px 16px', borderRadius: 12,
              background: `linear-gradient(135deg, ${accentColor}, #0284c7)`, color: '#fff',
              fontSize: 13, fontWeight: 600, display: 'flex', alignItems: 'center', gap: 6,
            }}>
              <Icon name="plus" size={14} color="#fff" strokeWidth={2.2} /> New program
            </div>
          </div>
        }
      />

      <div style={{ padding: '24px 32px 40px', display: 'flex', flexDirection: 'column', gap: 20 }}>

        {/* OVERDUE PROGRAMS ALERT — the headline feature */}
        {!dismissedAlert && (
          <Glass radius={20} strength="strong" style={{
            padding: 0, overflow: 'hidden',
            border: `0.5px solid rgba(251, 191, 36, 0.40)`,
            boxShadow: '0 1px 0 rgba(11,24,40,0.06) inset, 0 12px 40px rgba(251,191,36,0.10), 0 0 0 1px rgba(251,191,36,0.18)',
          }}>
            <div style={{ display: 'flex' }}>
              {/* left accent bar */}
              <div style={{
                width: 4, background: 'linear-gradient(180deg, #fbbf24, #f59e0b)',
              }} />
              <div style={{ flex: 1, padding: '18px 24px' }}>
                <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 14 }}>
                  <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
                    <div style={{
                      width: 32, height: 32, borderRadius: 10,
                      background: 'rgba(251, 191, 36, 0.16)', border: '0.5px solid rgba(251,191,36,0.4)',
                      display: 'flex', alignItems: 'center', justifyContent: 'center',
                    }}><Icon name="warning" size={16} color="#fbbf24" /></div>
                    <div>
                      <div style={{ fontSize: 15, fontWeight: 600, letterSpacing: -0.1 }}>
                        {overdueClients.length} clients need next week's program
                      </div>
                      <div style={{ fontSize: 12, color: 'var(--text-secondary)', marginTop: 1 }}>
                        Their current block ends in the next 10 days. Write or assign a template to keep momentum.
                      </div>
                    </div>
                  </div>
                  <div style={{ display: 'flex', gap: 8 }}>
                    <div onClick={() => setDismissedAlert(true)} style={{
                      padding: '7px 12px', borderRadius: 10,
                      background: 'rgba(11,24,40,0.05)', border: '0.5px solid rgba(11,24,40,0.07)',
                      fontSize: 12, fontWeight: 500, color: 'var(--text-secondary)', cursor: 'pointer',
                    }}>Snooze 1 day</div>
                    <div style={{
                      padding: '7px 14px', borderRadius: 10,
                      background: '#fbbf24', color: '#3a2a05',
                      fontSize: 12, fontWeight: 600, display: 'flex', alignItems: 'center', gap: 5,
                    }}>
                      Batch from template <Icon name="arrowR" size={12} color="#1a1208" strokeWidth={2.2} />
                    </div>
                  </div>
                </div>
                {/* client chips */}
                <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
                  {overdueClients.map(c => {
                    const daysLeft = Math.ceil((new Date(c.programThrough) - today) / (1000 * 60 * 60 * 24));
                    return (
                      <div key={c.id} style={{
                        display: 'flex', alignItems: 'center', gap: 8,
                        padding: '6px 10px 6px 6px', borderRadius: 999,
                        background: 'rgba(11,24,40,0.03)', border: '0.5px solid rgba(11,24,40,0.06)',
                      }}>
                        <Avatar src={c.photo} size={22} ring={false} />
                        <div style={{ fontSize: 12, fontWeight: 500 }}>{c.name.split(' ')[0]}</div>
                        <div style={{ fontSize: 10, color: daysLeft <= 3 ? '#ef4444' : '#fbbf24', fontWeight: 600 }}>
                          {daysLeft <= 0 ? `${Math.abs(daysLeft)}d over` : `${daysLeft}d left`}
                        </div>
                      </div>
                    );
                  })}
                </div>
              </div>
            </div>
          </Glass>
        )}

        {/* KPI strip */}
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14 }}>
          {[
            { label: 'Active clients', value: '28', delta: '+3', sub: 'this month', icon: 'user' },
            { label: 'MRR',           value: '$4,860', delta: '+12%', sub: 'vs Apr', icon: 'cash' },
            { label: 'Sessions / wk', value: '42', delta: '+6', sub: 'vs last', icon: 'flame' },
            { label: 'Unpaid',        value: unpaidCount.toString(), delta: 'review', sub: '2 over 14d', icon: 'warning', warn: true },
          ].map(k => (
            <Glass key={k.label} radius={16} style={{ padding: 16 }}>
              <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 }}>
                <div style={{ fontSize: 11, color: 'var(--text-tertiary)', fontWeight: 500, letterSpacing: 0.4, textTransform: 'uppercase' }}>{k.label}</div>
                <div style={{
                  width: 26, height: 26, borderRadius: 8,
                  background: k.warn ? 'rgba(239,68,68,0.14)' : 'rgba(11,24,40,0.03)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                }}><Icon name={k.icon} size={13} color={k.warn ? '#ef4444' : 'rgba(11,24,40,0.65)'} /></div>
              </div>
              <div style={{ fontSize: 26, fontWeight: 600, letterSpacing: -0.5 }}>{k.value}</div>
              <div style={{ fontSize: 11, color: k.warn ? '#ef4444' : accentColor, fontWeight: 500, marginTop: 2 }}>
                {k.delta} <span style={{ color: 'var(--text-tertiary)', fontWeight: 400 }}>· {k.sub}</span>
              </div>
            </Glass>
          ))}
        </div>

        {/* Two-column row */}
        <div style={{ display: 'grid', gridTemplateColumns: '1.4fr 1fr', gap: 16 }}>
          {/* Today's sessions */}
          <Glass radius={20} style={{ padding: 0, overflow: 'hidden' }}>
            <div style={{ padding: '16px 20px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', borderBottom: '0.5px solid rgba(11,24,40,0.05)' }}>
              <div>
                <div style={{ fontSize: 15, fontWeight: 600 }}>Today's sessions</div>
                <div style={{ fontSize: 11, color: 'var(--text-tertiary)', marginTop: 2 }}>4 scheduled · 1 unconfirmed</div>
              </div>
              <div style={{ fontSize: 12, color: accentColor, fontWeight: 500 }}>View calendar →</div>
            </div>
            {[
              { time: '7:00 AM', client: 'Elena Rossi',    photo: photos.clients.elena, type: 'In-person · Squat day',      mode: 'gym',    status: 'confirmed' },
              { time: '9:30 AM', client: 'James Whitaker', photo: photos.clients.james, type: 'Video check-in · 15 min',    mode: 'video',  status: 'confirmed' },
              { time: '12:00 PM',client: 'Aisha Bennani',  photo: photos.clients.aisha, type: 'In-person · Pull session',   mode: 'gym',    status: 'pending'   },
              { time: '5:30 PM', client: 'Priya Shah',     photo: photos.clients.priya, type: 'Form review · uploaded vid', mode: 'review', status: 'confirmed' },
            ].map((s, i, arr) => (
              <div key={s.time} style={{
                padding: '12px 20px', display: 'flex', alignItems: 'center', gap: 14,
                borderBottom: i < arr.length - 1 ? '0.5px solid rgba(11,24,40,0.03)' : 'none',
              }}>
                <div style={{ width: 64, fontSize: 12, color: 'var(--text-secondary)', fontFamily: 'JetBrains Mono', fontWeight: 500 }}>{s.time}</div>
                <Avatar src={s.photo} size={36} />
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ fontSize: 13, fontWeight: 500 }}>{s.client}</div>
                  <div style={{ fontSize: 11, color: 'var(--text-tertiary)' }}>{s.type}</div>
                </div>
                <div style={{
                  fontSize: 10, fontWeight: 600, letterSpacing: 0.4, textTransform: 'uppercase',
                  padding: '3px 8px', borderRadius: 6,
                  background: s.status === 'pending' ? 'rgba(251,191,36,0.14)' : 'rgba(110,231,168,0.14)',
                  color: s.status === 'pending' ? '#fbbf24' : accentColor,
                }}>{s.status}</div>
                <div style={{
                  width: 30, height: 30, borderRadius: 9,
                  background: 'rgba(11,24,40,0.05)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                }}>
                  <Icon name={s.mode === 'video' ? 'video' : s.mode === 'review' ? 'play' : 'pin'} size={13} color="rgba(11,24,40,0.65)" />
                </div>
              </div>
            ))}
          </Glass>

          {/* Recent activity */}
          <Glass radius={20} style={{ padding: 0, overflow: 'hidden' }}>
            <div style={{ padding: '16px 20px', borderBottom: '0.5px solid rgba(11,24,40,0.05)' }}>
              <div style={{ fontSize: 15, fontWeight: 600 }}>Recent activity</div>
              <div style={{ fontSize: 11, color: 'var(--text-tertiary)', marginTop: 2 }}>Across all clients</div>
            </div>
            <div style={{ padding: '8px 0' }}>
              {[
                { who: 'Elena',   ph: photos.clients.elena,  txt: 'completed Squat day · RPE 8',           time: '12m', kind: 'check'  },
                { who: 'James',   ph: photos.clients.james,  txt: 'hit a 5RM PR on bench (110kg)',         time: '1h',  kind: 'star'   },
                { who: 'Aisha',   ph: photos.clients.aisha,  txt: 'asked for RDL sub · LB tight',           time: '2h',  kind: 'chat'   },
                { who: 'Daniel',  ph: photos.clients.daniel, txt: "payment failed · $100",                 time: '4h',  kind: 'warn'   },
                { who: 'Priya',   ph: photos.clients.priya,  txt: 'uploaded a form-check video',           time: '6h',  kind: 'video'  },
                { who: 'Nora',    ph: photos.clients.nora,   txt: 'flagged Hard on hip thrusts · feedback',time: '8h',  kind: 'flame'  },
              ].map((a, i) => (
                <div key={i} style={{ padding: '8px 20px', display: 'flex', alignItems: 'center', gap: 10 }}>
                  <Avatar src={a.ph} size={28} ring={false} />
                  <div style={{ flex: 1, fontSize: 12, lineHeight: 1.4 }}>
                    <span style={{ fontWeight: 500 }}>{a.who}</span>
                    <span style={{ color: 'var(--text-secondary)' }}> {a.txt}</span>
                  </div>
                  <div style={{ fontSize: 10, color: 'var(--text-tertiary)' }}>{a.time}</div>
                </div>
              ))}
            </div>
          </Glass>
        </div>

        {/* Payments overview */}
        <Glass radius={20} style={{ padding: 0, overflow: 'hidden' }}>
          <div style={{ padding: '16px 20px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', borderBottom: '0.5px solid rgba(11,24,40,0.05)' }}>
            <div>
              <div style={{ fontSize: 15, fontWeight: 600 }}>Revenue · last 12 weeks</div>
              <div style={{ fontSize: 11, color: 'var(--text-tertiary)', marginTop: 2 }}>$48,920 collected · $1,200 outstanding</div>
            </div>
            <div style={{ display: 'flex', gap: 4, padding: 4, borderRadius: 10, background: 'rgba(11,24,40,0.03)', border: '0.5px solid rgba(11,24,40,0.06)' }}>
              {['12w', '6mo', '1y'].map((p, i) => (
                <div key={p} style={{
                  padding: '4px 10px', borderRadius: 7, fontSize: 11, fontWeight: 500, cursor: 'pointer',
                  background: i === 0 ? 'rgba(11,24,40,0.07)' : 'transparent',
                  color: i === 0 ? 'var(--text-primary)' : 'var(--text-secondary)',
                }}>{p}</div>
              ))}
            </div>
          </div>
          <RevenueBars accent={accentColor} />
        </Glass>
      </div>
    </CoachShell>
  );
}

function RevenueBars({ accent = '#6ee7a8' }) {
  const data = [3.2, 3.6, 3.4, 3.8, 4.0, 4.1, 3.9, 4.3, 4.5, 4.4, 4.7, 4.86];
  const max = 5;
  return (
    <div style={{ padding: '16px 20px 20px' }}>
      <div style={{ display: 'flex', alignItems: 'flex-end', gap: 8, height: 140 }}>
        {data.map((v, i) => {
          const last = i === data.length - 1;
          return (
            <div key={i} style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 6 }}>
              <div style={{ flex: 1, width: '100%', display: 'flex', alignItems: 'flex-end' }}>
                <div style={{
                  width: '100%', borderRadius: 6,
                  height: `${(v / max) * 100}%`,
                  background: last ? `linear-gradient(180deg, ${accent}, #0284c7)` : 'rgba(11,24,40,0.07)',
                  border: last ? `0.5px solid ${accent}80` : 'none',
                  boxShadow: last ? `0 4px 16px ${accent}40` : 'none',
                }} />
              </div>
              <div style={{ fontSize: 10, color: last ? 'var(--text-primary)' : 'var(--text-tertiary)', fontFamily: 'JetBrains Mono', fontWeight: last ? 600 : 400 }}>W{i + 1}</div>
            </div>
          );
        })}
      </div>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// Library — exercise library with YouTube cards
// ─────────────────────────────────────────────────────────────
function CoachLibrary({ accent = 'sky' }) {
  const accentColor = accent === 'sky' ? '#0ea5e9' : accent === 'azure' ? '#3b82f6' : '#38bdf8';
  const [cat, setCat] = React.useState('All');
  const filtered = cat === 'All' ? libraryMoves : libraryMoves.filter(m => m.cat === cat);
  return (
    <CoachShell active="library" accent={accent}>
      <CoachPageHeader
        kicker="Exercise library"
        title="240 movements"
        subtitle="Drag any move into a template or session. Every move links to a coaching cue video on YouTube."
        accent={accentColor}
        action={
          <div style={{
            padding: '10px 16px', borderRadius: 12,
            background: 'rgba(11,24,40,0.05)', border: '0.5px solid rgba(11,24,40,0.07)',
            fontSize: 13, fontWeight: 500, display: 'flex', alignItems: 'center', gap: 6,
          }}>
            <Icon name="plus" size={14} color="rgba(11,24,40,0.86)" /> Add custom move
          </div>
        }
      />
      <div style={{ padding: '20px 32px 40px' }}>
        {/* category tabs */}
        <div style={{ display: 'flex', gap: 6, flexWrap: 'wrap', marginBottom: 20 }}>
          {libraryCats.map(c => {
            const on = c === cat;
            return (
              <div key={c} onClick={() => setCat(c)} style={{
                padding: '7px 14px', borderRadius: 999, cursor: 'pointer', fontSize: 12, fontWeight: 500,
                background: on ? `${accentColor}1f` : 'rgba(11,24,40,0.03)',
                border: on ? `0.5px solid ${accentColor}60` : '0.5px solid rgba(11,24,40,0.06)',
                color: on ? accentColor : 'var(--text-secondary)',
              }}>{c}</div>
            );
          })}
        </div>

        {/* grid */}
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(220px, 1fr))', gap: 14 }}>
          {filtered.map((m, i) => (
            <Glass key={m.name} radius={16} style={{ padding: 0, overflow: 'hidden' }}>
              {/* video preview */}
              <div style={{
                aspectRatio: '16 / 10', position: 'relative',
                background: `linear-gradient(135deg, oklch(0.${20 + (i % 5) * 3} 0.04 ${140 + i * 13}), oklch(0.${30 + (i % 4) * 4} 0.06 ${165 + i * 7}))`,
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                overflow: 'hidden',
              }}>
                {/* diagonal stripe texture */}
                <div style={{
                  position: 'absolute', inset: 0, opacity: 0.18,
                  backgroundImage: 'repeating-linear-gradient(45deg, rgba(11,24,40,0.32) 0 1px, transparent 1px 14px)',
                }} />
                {/* play */}
                <div style={{
                  width: 44, height: 44, borderRadius: 22,
                  background: 'rgba(11,24,40,0.55)', border: '0.5px solid rgba(11,24,40,0.40)',
                  backdropFilter: 'blur(20px)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  position: 'relative', zIndex: 1,
                }}><Icon name="play" size={16} color="#fff" /></div>
                <div style={{
                  position: 'absolute', top: 8, left: 8,
                  padding: '3px 7px', borderRadius: 6,
                  background: 'rgba(0,0,0,0.5)', backdropFilter: 'blur(10px)',
                  fontSize: 9, fontWeight: 600, letterSpacing: 0.4, textTransform: 'uppercase',
                  color: m.diff === 'Beginner' ? '#6ee7a8' : m.diff === 'Intermediate' ? '#fbbf24' : '#ef9a9a',
                }}>{m.diff}</div>
                <div style={{
                  position: 'absolute', bottom: 8, right: 8,
                  padding: '3px 7px', borderRadius: 6, gap: 4,
                  background: 'rgba(0,0,0,0.5)', backdropFilter: 'blur(10px)',
                  display: 'flex', alignItems: 'center',
                  fontSize: 9, fontWeight: 600, color: '#fff',
                }}>
                  <Icon name="youtube" size={10} color="#ef4444" strokeWidth={1.4} /> YouTube
                </div>
              </div>
              <div style={{ padding: '12px 14px' }}>
                <div style={{ fontSize: 13, fontWeight: 500, letterSpacing: -0.1 }}>{m.name}</div>
                <div style={{ fontSize: 11, color: 'var(--text-tertiary)', marginTop: 3, display: 'flex', alignItems: 'center', gap: 4 }}>
                  <span>{m.cat}</span>
                  <span style={{ width: 3, height: 3, borderRadius: 2, background: 'rgba(11,24,40,0.14)' }} />
                  <span>{m.equip}</span>
                </div>
              </div>
            </Glass>
          ))}
        </div>
      </div>
    </CoachShell>
  );
}

// ─────────────────────────────────────────────────────────────
// Templates — list + 4-week builder preview
// ─────────────────────────────────────────────────────────────
function CoachTemplates({ accent = 'sky' }) {
  const accentColor = accent === 'sky' ? '#0ea5e9' : accent === 'azure' ? '#3b82f6' : '#38bdf8';
  const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
  const weekPattern = [
    ['Lower · strength', 'Upper · push', 'rest',          'Lower · power',  'Upper · pull',   'Conditioning', 'rest'],
    ['Lower · strength', 'Upper · push', 'Mobility flow', 'Lower · power',  'Upper · pull',   'Conditioning', 'rest'],
    ['Lower · strength', 'Upper · push', 'rest',          'Lower · volume', 'Upper · vol',    'Conditioning', 'rest'],
    ['Deload lower',     'Deload upper', 'rest',          'Deload lower',   'Deload upper',   'rest',         'Test'],
  ];
  return (
    <CoachShell active="templates" accent={accent}>
      <CoachPageHeader
        kicker="Programming · Templates"
        title="Hypertrophy · Lower A"
        subtitle="4 weeks · 4 sessions/wk · 14 clients on this template. Assign once, then individualize."
        accent={accentColor}
        action={
          <div style={{ display: 'flex', gap: 10 }}>
            <Glass radius={12} style={{ padding: '10px 14px', fontSize: 12, fontWeight: 500, color: 'var(--text-secondary)' }}>Duplicate</Glass>
            <div style={{
              padding: '10px 16px', borderRadius: 12,
              background: `linear-gradient(135deg, ${accentColor}, #0284c7)`, color: '#fff',
              fontSize: 13, fontWeight: 600, display: 'flex', alignItems: 'center', gap: 6,
            }}>
              <Icon name="user" size={14} color="#fff" strokeWidth={2} /> Assign to client
            </div>
          </div>
        }
      />

      <div style={{ padding: '20px 32px 40px', display: 'grid', gridTemplateColumns: '1fr 320px', gap: 20 }}>
        <div>
          {/* week tabs */}
          <div style={{ display: 'flex', gap: 8, marginBottom: 16 }}>
            {[1, 2, 3, 4].map(w => (
              <div key={w} style={{
                flex: 1, padding: '11px 0', borderRadius: 12, textAlign: 'center',
                background: w === 2 ? 'rgba(11,24,40,0.06)' : 'rgba(11,24,40,0.025)',
                border: w === 2 ? '0.5px solid rgba(11,24,40,0.10)' : '0.5px solid rgba(11,24,40,0.05)',
                fontSize: 12, fontWeight: 500,
                color: w === 2 ? 'var(--text-primary)' : 'var(--text-secondary)',
              }}>
                <div style={{ fontSize: 10, color: w === 4 ? '#fbbf24' : 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.4, textTransform: 'uppercase' }}>{w === 4 ? 'Deload' : `Block`}</div>
                <div style={{ marginTop: 2 }}>Week {w}</div>
              </div>
            ))}
          </div>

          {/* day grid */}
          <Glass radius={20} style={{ padding: 20 }}>
            <div style={{ fontSize: 13, fontWeight: 600, marginBottom: 12 }}>Week 2 · Block (current view)</div>
            <div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: 8, marginBottom: 16 }}>
              {days.map((d, di) => {
                const session = weekPattern[1][di];
                const rest = session === 'rest';
                return (
                  <div key={d} style={{
                    minHeight: 92, padding: 10, borderRadius: 12,
                    background: rest ? 'rgba(11,24,40,0.02)' : 'rgba(11,24,40,0.04)',
                    border: rest ? '0.5px dashed rgba(11,24,40,0.07)' : '0.5px solid rgba(11,24,40,0.07)',
                    display: 'flex', flexDirection: 'column',
                  }}>
                    <div style={{ fontSize: 10, color: 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.4, textTransform: 'uppercase' }}>{d}</div>
                    {!rest ? (
                      <>
                        <div style={{ fontSize: 11, fontWeight: 500, marginTop: 6, lineHeight: 1.3 }}>{session}</div>
                        <div style={{ flex: 1 }} />
                        <div style={{ display: 'flex', gap: 3 }}>
                          {Array.from({ length: 7 }).map((_, i) => (
                            <div key={i} style={{ flex: 1, height: 3, borderRadius: 1.5, background: i < 5 ? accentColor : 'rgba(11,24,40,0.06)' }} />
                          ))}
                        </div>
                      </>
                    ) : (
                      <div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 10, color: 'var(--text-tertiary)' }}>rest</div>
                    )}
                  </div>
                );
              })}
            </div>

            {/* exercise list for current day */}
            <div style={{ fontSize: 11, color: 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.4, textTransform: 'uppercase', marginBottom: 10 }}>
              Mon · Lower · strength
            </div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
              {exercisesToday.slice(0, 5).map((ex, i) => (
                <div key={ex.id} style={{
                  display: 'flex', alignItems: 'center', gap: 12,
                  padding: '8px 12px', borderRadius: 10,
                  background: 'rgba(11,24,40,0.025)',
                  border: '0.5px solid rgba(11,24,40,0.05)',
                }}>
                  <Icon name="drag" size={14} color="rgba(11,24,40,0.20)" />
                  <div style={{ width: 20, fontSize: 11, color: 'var(--text-tertiary)', fontFamily: 'JetBrains Mono' }}>{i + 1}.</div>
                  <div style={{ flex: 1, fontSize: 13, fontWeight: 500 }}>{ex.name}</div>
                  <div style={{ fontSize: 11, color: 'var(--text-secondary)', fontFamily: 'JetBrains Mono' }}>{ex.sets}×{ex.reps} @ RPE {ex.rpe}</div>
                  <div style={{ fontSize: 11, color: 'var(--text-secondary)', fontFamily: 'JetBrains Mono' }}>{ex.weight}kg</div>
                  <Icon name="youtube" size={14} color="#ef4444" />
                </div>
              ))}
              <div style={{
                padding: '8px 12px', borderRadius: 10,
                border: '0.5px dashed rgba(11,24,40,0.08)',
                display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6,
                fontSize: 12, color: 'var(--text-tertiary)', cursor: 'pointer',
              }}>
                <Icon name="plus" size={12} color="rgba(11,24,40,0.32)" /> Add exercise
              </div>
            </div>
          </Glass>
        </div>

        {/* right rail: assign + template list */}
        <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
          <Glass radius={18} style={{ padding: 16 }}>
            <div style={{ fontSize: 12, color: 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.4, textTransform: 'uppercase', marginBottom: 10 }}>Assigned to</div>
            <div style={{ display: 'flex', flexWrap: 'wrap', gap: 6, marginBottom: 12 }}>
              {[photos.clients.elena, photos.clients.priya, photos.clients.maya, photos.clients.nora].map((p, i) => (
                <Avatar key={i} src={p} size={32} ring={false} />
              ))}
              <div style={{
                width: 32, height: 32, borderRadius: 16,
                background: 'rgba(11,24,40,0.05)',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                fontSize: 11, fontWeight: 600, color: 'var(--text-secondary)',
              }}>+10</div>
            </div>
            <div style={{
              padding: '8px 12px', borderRadius: 10,
              background: 'rgba(11,24,40,0.03)', border: '0.5px solid rgba(11,24,40,0.06)',
              fontSize: 11, color: 'var(--text-secondary)', lineHeight: 1.5,
            }}>
              Tweaks per client (load, ROM, sub) carry over when you push edits.
            </div>
          </Glass>

          <Glass radius={18} style={{ padding: 0, overflow: 'hidden' }}>
            <div style={{ padding: '12px 16px', borderBottom: '0.5px solid rgba(11,24,40,0.05)', fontSize: 12, color: 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.4, textTransform: 'uppercase' }}>All templates</div>
            {templatesData.map((t, i) => (
              <div key={t.name} style={{
                padding: '12px 16px',
                borderBottom: i < templatesData.length - 1 ? '0.5px solid rgba(11,24,40,0.03)' : 'none',
                background: i === 0 ? 'rgba(110,231,168,0.04)' : 'transparent',
              }}>
                <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
                  <div style={{ fontSize: 12, fontWeight: 500, color: i === 0 ? accentColor : 'var(--text-primary)' }}>{t.name}</div>
                  <div style={{ fontSize: 10, color: 'var(--text-tertiary)' }}>{t.lastEdited}</div>
                </div>
                <div style={{ fontSize: 10, color: 'var(--text-tertiary)', marginTop: 2 }}>
                  {t.weeks}w · {t.sessions} sessions · {t.clients} clients
                </div>
              </div>
            ))}
          </Glass>
        </div>
      </div>
    </CoachShell>
  );
}

// ─────────────────────────────────────────────────────────────
// CRM — paid/unpaid, program status
// ─────────────────────────────────────────────────────────────
function CoachCRM({ accent = 'sky' }) {
  const accentColor = accent === 'sky' ? '#0ea5e9' : accent === 'azure' ? '#3b82f6' : '#38bdf8';
  const [filter, setFilter] = React.useState('all');

  const today = new Date('2026-05-17');
  const decorated = clientsData.map(c => {
    const daysLeft = Math.ceil((new Date(c.programThrough) - today) / (1000 * 60 * 60 * 24));
    return { ...c, daysLeft };
  });

  const filtered = filter === 'all' ? decorated :
                   filter === 'overdue' ? decorated.filter(c => c.status === 'overdue') :
                   filter === 'program' ? decorated.filter(c => c.daysLeft < 10) :
                   decorated;

  const filters = [
    { id: 'all',     label: 'All',                count: decorated.length },
    { id: 'overdue', label: 'Payment overdue',    count: decorated.filter(c => c.status === 'overdue').length, warn: true },
    { id: 'program', label: 'Programming due',    count: decorated.filter(c => c.daysLeft < 10).length },
    { id: 'paid',    label: 'Active subscribers', count: decorated.filter(c => c.status === 'paid').length },
  ];

  return (
    <CoachShell active="clients" accent={accent}>
      <CoachPageHeader
        kicker="Client relationship"
        title="Your roster"
        subtitle="Who paid, who hasn't, and whose programming is running thin. Click any client to open their workspace."
        accent={accentColor}
        action={
          <div style={{ display: 'flex', gap: 10 }}>
            <Glass radius={12} style={{ padding: '10px 16px', display: 'flex', alignItems: 'center', gap: 8, fontSize: 12, color: 'var(--text-secondary)' }}>
              <Icon name="search" size={14} color="rgba(11,24,40,0.42)" />
              <span style={{ color: 'var(--text-tertiary)' }}>Filter by name…</span>
            </Glass>
            <div style={{
              padding: '10px 16px', borderRadius: 12,
              background: `linear-gradient(135deg, ${accentColor}, #0284c7)`, color: '#fff',
              fontSize: 13, fontWeight: 600, display: 'flex', alignItems: 'center', gap: 6,
            }}>
              <Icon name="plus" size={14} color="#fff" strokeWidth={2.2} /> Invite client
            </div>
          </div>
        }
      />
      <div style={{ padding: '20px 32px 40px' }}>
        {/* filter pills */}
        <div style={{ display: 'flex', gap: 8, marginBottom: 16 }}>
          {filters.map(f => {
            const on = filter === f.id;
            return (
              <div key={f.id} onClick={() => setFilter(f.id)} style={{
                padding: '8px 14px', borderRadius: 999, cursor: 'pointer',
                fontSize: 12, fontWeight: 500, display: 'flex', alignItems: 'center', gap: 8,
                background: on ? (f.warn ? 'rgba(239,68,68,0.14)' : `${accentColor}1f`) : 'rgba(11,24,40,0.03)',
                border: on ? (f.warn ? '0.5px solid rgba(239,68,68,0.4)' : `0.5px solid ${accentColor}60`) : '0.5px solid rgba(11,24,40,0.06)',
                color: on ? (f.warn ? '#ef4444' : accentColor) : 'var(--text-secondary)',
              }}>
                {f.label}
                <span style={{
                  fontSize: 10, fontWeight: 600,
                  padding: '1px 6px', borderRadius: 99,
                  background: on ? 'rgba(11,24,40,0.07)' : 'rgba(11,24,40,0.03)',
                  color: 'inherit',
                }}>{f.count}</span>
              </div>
            );
          })}
        </div>

        {/* Table */}
        <Glass radius={18} style={{ padding: 0, overflow: 'hidden' }}>
          <div style={{
            display: 'grid', gridTemplateColumns: '2fr 1.2fr 1.2fr 1.4fr 1.2fr 100px',
            padding: '10px 20px', gap: 12,
            borderBottom: '0.5px solid rgba(11,24,40,0.05)',
            fontSize: 10, color: 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.4, textTransform: 'uppercase',
          }}>
            <div>Client</div>
            <div>Plan</div>
            <div>Paid through</div>
            <div>Program runs through</div>
            <div>Next session</div>
            <div style={{ textAlign: 'right' }}>Action</div>
          </div>
          {filtered.map(c => {
            const overduePay = c.status === 'overdue';
            const needsProgram = c.daysLeft < 10;
            return (
              <div key={c.id} style={{
                display: 'grid', gridTemplateColumns: '2fr 1.2fr 1.2fr 1.4fr 1.2fr 100px',
                padding: '12px 20px', gap: 12, alignItems: 'center',
                borderBottom: '0.5px solid rgba(11,24,40,0.03)',
                fontSize: 13,
                background: overduePay ? 'rgba(239,68,68,0.04)' : needsProgram ? 'rgba(251,191,36,0.03)' : 'transparent',
              }}>
                {/* client */}
                <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
                  <Avatar src={c.photo} size={32} ring={false} />
                  <div>
                    <div style={{ fontSize: 13, fontWeight: 500 }}>{c.name}</div>
                    <div style={{ fontSize: 10, color: 'var(--text-tertiary)' }}>
                      {c.streak > 0 ? `${c.streak}-day streak` : 'No sessions logged · 8d'}
                    </div>
                  </div>
                </div>
                {/* plan */}
                <div style={{ fontSize: 12, color: 'var(--text-secondary)' }}>{c.plan}</div>
                {/* paid through */}
                <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
                  <div style={{
                    width: 6, height: 6, borderRadius: 3,
                    background: overduePay ? '#ef4444' : accentColor,
                  }} />
                  <div style={{ fontSize: 12, color: overduePay ? '#ef4444' : 'var(--text-secondary)', fontWeight: overduePay ? 600 : 400 }}>{c.paidThru}</div>
                </div>
                {/* program runs through */}
                <div>
                  <div style={{ fontSize: 12, color: needsProgram ? '#fbbf24' : 'var(--text-secondary)', fontWeight: needsProgram ? 600 : 400 }}>
                    {c.daysLeft <= 0 ? `${Math.abs(c.daysLeft)}d overdue` : `${c.daysLeft} days left`}
                  </div>
                  <div style={{
                    marginTop: 4, height: 3, borderRadius: 2,
                    background: 'rgba(11,24,40,0.05)', overflow: 'hidden',
                  }}>
                    <div style={{
                      width: `${Math.max(0, Math.min(100, c.daysLeft / 30 * 100))}%`,
                      height: '100%',
                      background: needsProgram ? '#fbbf24' : accentColor,
                    }} />
                  </div>
                </div>
                {/* next session */}
                <div style={{ fontSize: 12, color: 'var(--text-secondary)' }}>{c.nextSession}</div>
                {/* action */}
                <div style={{ display: 'flex', justifyContent: 'flex-end', gap: 6 }}>
                  {overduePay && (
                    <div style={{
                      padding: '5px 9px', borderRadius: 8,
                      background: 'rgba(239,68,68,0.14)', border: '0.5px solid rgba(239,68,68,0.3)',
                      fontSize: 11, fontWeight: 500, color: '#ef4444',
                    }}>Remind</div>
                  )}
                  {!overduePay && needsProgram && (
                    <div style={{
                      padding: '5px 9px', borderRadius: 8,
                      background: 'rgba(251,191,36,0.14)', border: '0.5px solid rgba(251,191,36,0.3)',
                      fontSize: 11, fontWeight: 500, color: '#fbbf24',
                    }}>Program</div>
                  )}
                  {!overduePay && !needsProgram && (
                    <div style={{
                      padding: '5px 9px', borderRadius: 8,
                      background: 'rgba(11,24,40,0.03)', border: '0.5px solid rgba(11,24,40,0.06)',
                      fontSize: 11, fontWeight: 500, color: 'var(--text-secondary)',
                    }}>Open</div>
                  )}
                </div>
              </div>
            );
          })}
        </Glass>
      </div>
    </CoachShell>
  );
}

// ─────────────────────────────────────────────────────────────
// Coach messaging — inbox + thread
// ─────────────────────────────────────────────────────────────
function CoachMessaging({ accent = 'sky' }) {
  const accentColor = accent === 'sky' ? '#0ea5e9' : accent === 'azure' ? '#3b82f6' : '#38bdf8';
  const msgs = [
    { from: 'them', text: 'Knee felt great today, thanks for the cue!', time: '8:14' },
    { from: 'them', text: 'Hit 145×5 clean, set 4 was a grinder but I held position', time: '8:15' },
    { from: 'me',   text: 'Beautiful work. How was knee tracking on the descent?', time: '8:16' },
    { from: 'them', text: 'Solid — sending video', time: '8:16' },
    { from: 'me',   text: "Push 147.5 next Wed. RPE 8 target. Don't grind past 9.", time: '8:17' },
  ];
  return (
    <CoachShell active="inbox" accent={accent}>
      <div style={{ height: '100%', display: 'flex' }}>
        {/* Inbox list */}
        <div style={{ width: 340, borderRight: '0.5px solid rgba(11,24,40,0.05)', display: 'flex', flexDirection: 'column' }}>
          <div style={{ padding: '20px 20px 14px' }}>
            <div style={{ fontFamily: 'Instrument Serif, serif', fontSize: 26, letterSpacing: -0.3 }}>Inbox</div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 10, padding: '8px 12px', borderRadius: 10, background: 'rgba(11,24,40,0.03)', border: '0.5px solid rgba(11,24,40,0.06)' }}>
              <Icon name="search" size={14} color="rgba(11,24,40,0.42)" />
              <input placeholder="Search clients…" style={{ flex: 1, background: 'transparent', border: 'none', outline: 'none', color: 'var(--text-primary)', fontSize: 12, fontFamily: 'Inter' }} />
            </div>
          </div>
          <div style={{ flex: 1, overflowY: 'auto' }}>
            {coachMessageThreads.map((t, i) => (
              <div key={t.id} style={{
                padding: '12px 20px', display: 'flex', alignItems: 'center', gap: 12,
                background: i === 0 ? 'rgba(110,231,168,0.06)' : 'transparent',
                borderLeft: i === 0 ? `2px solid ${accentColor}` : '2px solid transparent',
                cursor: 'pointer',
              }}>
                <div style={{ position: 'relative' }}>
                  <Avatar src={t.photo} size={40} ring={false} />
                  {t.online && (
                    <div style={{
                      position: 'absolute', bottom: -1, right: -1,
                      width: 11, height: 11, borderRadius: 6,
                      background: accentColor, border: '2px solid #ffffff',
                    }} />
                  )}
                </div>
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
                    <div style={{ fontSize: 13, fontWeight: t.unread ? 600 : 500 }}>{t.name}</div>
                    <div style={{ fontSize: 10, color: 'var(--text-tertiary)' }}>{t.time}</div>
                  </div>
                  <div style={{
                    fontSize: 12, color: t.unread ? 'var(--text-secondary)' : 'var(--text-tertiary)',
                    overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
                    marginTop: 2,
                  }}>{t.last}</div>
                </div>
                {t.unread > 0 && (
                  <div style={{
                    minWidth: 18, height: 18, padding: '0 5px', borderRadius: 9,
                    background: accentColor, color: '#fff',
                    fontSize: 10, fontWeight: 700,
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                  }}>{t.unread}</div>
                )}
              </div>
            ))}
          </div>
        </div>

        {/* Thread */}
        <div style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
          <div style={{ padding: '16px 24px', borderBottom: '0.5px solid rgba(11,24,40,0.05)', display: 'flex', alignItems: 'center', gap: 14 }}>
            <Avatar src={photos.clients.elena} size={42} />
            <div style={{ flex: 1 }}>
              <div style={{ fontSize: 15, fontWeight: 600 }}>Elena Rossi</div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
                <div style={{ width: 6, height: 6, borderRadius: 3, background: accentColor }} />
                <div style={{ fontSize: 11, color: 'var(--text-secondary)' }}>Online · Annual · 14-day streak</div>
              </div>
            </div>
            <Glass radius={10} style={{ padding: '8px 12px', display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, fontWeight: 500, color: 'var(--text-secondary)' }}>
              <Icon name="phone" size={13} color="rgba(11,24,40,0.65)" /> Call
            </Glass>
            <div style={{
              padding: '8px 14px', borderRadius: 10,
              background: `${accentColor}1f`, border: `0.5px solid ${accentColor}60`,
              fontSize: 12, fontWeight: 600, color: accentColor,
              display: 'flex', alignItems: 'center', gap: 6,
            }}>
              <Icon name="video" size={13} color={accentColor} /> Video call
            </div>
          </div>

          <div style={{ flex: 1, overflowY: 'auto', padding: '20px 24px', display: 'flex', flexDirection: 'column', gap: 10 }}>
            <div style={{ alignSelf: 'center', fontSize: 11, color: 'var(--text-tertiary)', fontWeight: 500, margin: '4px 0' }}>Today · 8:14 AM</div>
            {msgs.map((m, i) => (
              <div key={i} style={{
                alignSelf: m.from === 'me' ? 'flex-end' : 'flex-start',
                maxWidth: '60%',
                padding: '10px 14px', borderRadius: 18,
                background: m.from === 'me'
                  ? `linear-gradient(135deg, ${accentColor}, #0284c7)`
                  : 'rgba(11,24,40,0.06)',
                border: m.from === 'me' ? 'none' : '0.5px solid rgba(11,24,40,0.06)',
                fontSize: 13, lineHeight: 1.4,
                color: m.from === 'me' ? '#fff' : 'var(--text-primary)',
                fontWeight: m.from === 'me' ? 500 : 400,
                borderBottomRightRadius: m.from === 'me' ? 6 : 18,
                borderBottomLeftRadius:  m.from === 'me' ? 18 : 6,
              }}>{m.text}</div>
            ))}
            {/* uploaded video card */}
            <Glass radius={16} style={{ padding: 10, alignSelf: 'flex-start', maxWidth: 280, display: 'flex', gap: 10, alignItems: 'center' }}>
              <div style={{
                width: 80, height: 56, borderRadius: 10,
                background: `linear-gradient(135deg, #c9d8e8, #b5c8dc)`,
                position: 'relative',
                display: 'flex', alignItems: 'center', justifyContent: 'center',
              }}>
                <div style={{
                  width: 28, height: 28, borderRadius: 14,
                  background: 'rgba(11,24,40,0.55)', backdropFilter: 'blur(8px)',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                }}><Icon name="play" size={12} color="#fff" /></div>
              </div>
              <div style={{ flex: 1 }}>
                <div style={{ fontSize: 12, fontWeight: 500 }}>squat_set3.mp4</div>
                <div style={{ fontSize: 10, color: 'var(--text-tertiary)', marginTop: 2 }}>0:14 · just now</div>
              </div>
            </Glass>
          </div>

          <div style={{ padding: '14px 24px' }}>
            <Glass radius={16} style={{ display: 'flex', alignItems: 'center', padding: '6px 6px 6px 16px', gap: 8 }}>
              <Icon name="plus" size={18} color="rgba(11,24,40,0.55)" />
              <input placeholder="Reply to Elena…" style={{ flex: 1, background: 'transparent', border: 'none', outline: 'none', color: 'var(--text-primary)', fontSize: 14, fontFamily: 'Inter', padding: '8px 0' }} />
              <div style={{
                padding: '8px 14px', borderRadius: 10,
                background: accentColor, color: '#fff',
                fontSize: 12, fontWeight: 600,
              }}>Send</div>
            </Glass>
          </div>
        </div>
      </div>
    </CoachShell>
  );
}

// ─────────────────────────────────────────────────────────────
// Coach profile
// ─────────────────────────────────────────────────────────────
function CoachProfile({ accent = 'sky' }) {
  const accentColor = accent === 'sky' ? '#0ea5e9' : accent === 'azure' ? '#3b82f6' : '#38bdf8';
  const lifts = [
    { name: 'Back Squat',     value: 220, unit: 'kg', sub: 'Bw 2.5×' },
    { name: 'Deadlift',       value: 260, unit: 'kg', sub: 'Bw 2.9×' },
    { name: 'Bench Press',    value: 145, unit: 'kg', sub: 'Bw 1.6×' },
    { name: 'Overhead Press', value: 95,  unit: 'kg', sub: 'Bw 1.1×' },
  ];
  return (
    <CoachShell active="dashboard" accent={accent}>
      <div style={{ padding: '24px 32px 40px' }}>
        {/* hero card */}
        <Glass radius={24} strength="strong" style={{ padding: 28, marginBottom: 18, position: 'relative', overflow: 'hidden' }}>
          {/* bg accent gradient */}
          <div style={{
            position: 'absolute', top: -80, right: -80, width: 360, height: 360, borderRadius: '50%',
            background: `radial-gradient(closest-side, ${accentColor}30, transparent 70%)`,
            filter: 'blur(20px)', pointerEvents: 'none',
          }} />
          <div style={{ display: 'flex', gap: 28, alignItems: 'flex-start', position: 'relative' }}>
            <div style={{ position: 'relative' }}>
              <Avatar src={photos.coach.marcus} size={140} />
              <div style={{
                position: 'absolute', bottom: 6, right: 6,
                padding: '4px 8px', borderRadius: 999,
                background: `linear-gradient(135deg, ${accentColor}, #0284c7)`,
                fontSize: 10, fontWeight: 700, color: '#fff', letterSpacing: 0.4,
              }}>PRO</div>
            </div>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ fontSize: 11, fontWeight: 600, letterSpacing: 1.4, color: accentColor, textTransform: 'uppercase' }}>Strength & barbell coaching · Brooklyn, NY</div>
              <div style={{ fontFamily: 'Instrument Serif, serif', fontSize: 44, letterSpacing: -0.5, lineHeight: 1.05, marginTop: 6 }}>Marcus Thorne</div>
              <div style={{ display: 'flex', gap: 16, marginTop: 10, marginBottom: 14 }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
                  <Icon name="star" size={14} color={accentColor} />
                  <span style={{ fontSize: 13, fontWeight: 600 }}>4.92</span>
                  <span style={{ fontSize: 12, color: 'var(--text-tertiary)' }}>· 184 reviews</span>
                </div>
                <div style={{ fontSize: 12, color: 'var(--text-tertiary)' }}>8 years coaching</div>
                <div style={{ fontSize: 12, color: 'var(--text-tertiary)' }}>NSCA-CSCS · USAW-L2</div>
              </div>
              <p style={{ fontSize: 14, lineHeight: 1.6, color: 'var(--text-secondary)', margin: 0, maxWidth: 640 }}>
                I coach barbell strength for adults who don't want to grind themselves into the ground.
                Method-over-mood: we pick three lifts that matter to you, and we drag them up over the next six months.
                I've coached competitive powerlifters and people who just want their first bodyweight squat — same patience, same care.
              </p>
              <div style={{ display: 'flex', gap: 8, marginTop: 18 }}>
                <div style={{
                  padding: '10px 16px', borderRadius: 12,
                  background: `linear-gradient(135deg, ${accentColor}, #0284c7)`, color: '#fff',
                  fontSize: 13, fontWeight: 600,
                }}>Book consult</div>
                <Glass radius={12} style={{ padding: '10px 16px', fontSize: 12, fontWeight: 500, color: 'var(--text-secondary)', display: 'flex', alignItems: 'center', gap: 6 }}>
                  <Icon name="chat" size={13} color="rgba(11,24,40,0.65)" /> Message
                </Glass>
                <Glass radius={12} style={{ padding: '10px 16px', fontSize: 12, fontWeight: 500, color: 'var(--text-secondary)', display: 'flex', alignItems: 'center', gap: 6 }}>
                  <Icon name="video" size={13} color="rgba(11,24,40,0.65)" /> Watch intro
                </Glass>
              </div>
            </div>
          </div>
        </Glass>

        <div style={{ display: 'grid', gridTemplateColumns: '1.4fr 1fr', gap: 18 }}>
          {/* Expertise */}
          <Glass radius={20} style={{ padding: 22 }}>
            <div style={{ fontSize: 12, color: 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.6, textTransform: 'uppercase', marginBottom: 14 }}>Expertise</div>
            <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, marginBottom: 22 }}>
              {[
                ['Powerlifting peaking', 92],
                ['Hypertrophy blocks',    88],
                ['Return-to-lift post-injury', 78],
                ['Olympic lift technique',     70],
                ['Women\'s strength',          85],
                ['In-season athletes',         72],
              ].map(([label, pct]) => (
                <div key={label} style={{
                  padding: '8px 14px', borderRadius: 12,
                  background: 'rgba(11,24,40,0.03)', border: '0.5px solid rgba(11,24,40,0.06)',
                  display: 'flex', alignItems: 'center', gap: 10,
                }}>
                  <div style={{ fontSize: 12, fontWeight: 500 }}>{label}</div>
                  <div style={{ width: 56, height: 4, borderRadius: 2, background: 'rgba(11,24,40,0.06)' }}>
                    <div style={{ width: `${pct}%`, height: '100%', borderRadius: 2, background: accentColor }} />
                  </div>
                </div>
              ))}
            </div>

            <div style={{ fontSize: 12, color: 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.6, textTransform: 'uppercase', marginBottom: 14 }}>How I coach</div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
              {[
                { i: 'cal',   t: 'Programs by month', d: 'I write you 4 weeks at a time. You see the current week — I see the whole arc.' },
                { i: 'video', t: 'Weekly form review', d: 'Send me a working set video each week. I send back cues within 24h.' },
                { i: 'chat',  t: 'Same-day messaging', d: 'Tweaks, subs, life-happens questions. Reply latency under 4 hours, weekdays.' },
              ].map(b => (
                <div key={b.t} style={{ display: 'flex', gap: 12, alignItems: 'flex-start' }}>
                  <div style={{
                    width: 32, height: 32, borderRadius: 9,
                    background: `${accentColor}1a`, border: `0.5px solid ${accentColor}30`,
                    display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0,
                  }}><Icon name={b.i} size={15} color={accentColor} /></div>
                  <div>
                    <div style={{ fontSize: 13, fontWeight: 500 }}>{b.t}</div>
                    <div style={{ fontSize: 12, color: 'var(--text-secondary)', marginTop: 2, lineHeight: 1.5 }}>{b.d}</div>
                  </div>
                </div>
              ))}
            </div>
          </Glass>

          {/* Max lifts */}
          <Glass radius={20} style={{ padding: 22 }}>
            <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', marginBottom: 4 }}>
              <div style={{ fontSize: 12, color: 'var(--text-tertiary)', fontWeight: 600, letterSpacing: 0.6, textTransform: 'uppercase' }}>My max lifts</div>
              <div style={{ fontSize: 10, color: 'var(--text-tertiary)' }}>Total · 720 kg</div>
            </div>
            <div style={{ fontSize: 11, color: 'var(--text-secondary)', marginBottom: 18 }}>Walking the talk. Updated quarterly.</div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
              {lifts.map(l => (
                <div key={l.name} style={{
                  padding: '14px 16px', borderRadius: 14,
                  background: 'rgba(11,24,40,0.03)', border: '0.5px solid rgba(11,24,40,0.06)',
                  display: 'flex', alignItems: 'center', gap: 14,
                }}>
                  <div style={{
                    width: 38, height: 38, borderRadius: 10,
                    background: `${accentColor}1f`,
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                  }}><Icon name="dumb" size={18} color={accentColor} strokeWidth={2} /></div>
                  <div style={{ flex: 1 }}>
                    <div style={{ fontSize: 13, fontWeight: 500 }}>{l.name}</div>
                    <div style={{ fontSize: 10, color: 'var(--text-tertiary)', marginTop: 1 }}>{l.sub}</div>
                  </div>
                  <div style={{ fontSize: 22, fontWeight: 600, letterSpacing: -0.3, fontFamily: 'Instrument Serif, serif' }}>
                    {l.value}<span style={{ fontSize: 11, color: 'var(--text-tertiary)', fontFamily: 'Inter', fontWeight: 400 }}> {l.unit}</span>
                  </div>
                </div>
              ))}
            </div>
            <div style={{
              marginTop: 16, padding: 12, borderRadius: 12,
              background: `${accentColor}0c`, border: `0.5px solid ${accentColor}28`,
              fontSize: 11, color: 'var(--text-secondary)', lineHeight: 1.5,
            }}>
              <span style={{ color: accentColor, fontWeight: 600 }}>Note · </span>
              Numbers from a tested meet, Brooklyn Open '25. Not the point — I just want you to know I lift.
            </div>
          </Glass>
        </div>
      </div>
    </CoachShell>
  );
}

Object.assign(window, {
  CoachShell, CoachPageHeader, CoachDashboard, CoachLibrary, CoachTemplates, CoachCRM, CoachMessaging, CoachProfile,
});
