// Home (pacientes) — primitivos propios sobre la paleta MEDIKADO
const HC = {
  ink: '#0B1F33', inkSoft: '#4A5B6E', inkMuted: '#8A9AAB',
  line: '#E4E9EE', lineStrong: '#D3DCE4',
  bg: '#FBFCFD', bgWarm: '#F4F6F8', bgCool: '#EEF3FA',
  blue: '#1863E0', blueSoft: '#E8F0FD', blueDark: '#0F4AB5', blueInk: '#0A2E73',
  green: '#13A579', greenSoft: '#E2F6EF',
  amber: '#F0A020', amberSoft: '#FDF2DF',
  yape: '#6E2EC2', yapeSoft: '#F1EAFB',
  red: '#E23B4D', redSoft: '#FCEBED',
  white: '#fff',
};
const HFONT = '"Manrope", -apple-system, system-ui, sans-serif';
// Detecta ancho móvil/tablet para ajustar tamaños que no se pueden hacer con CSS
// (p. ej. el ancho en px de los mockups de teléfono).
function useIsMobile(bp = 1040) {
  const [m, setM] = React.useState(typeof window !== 'undefined' ? window.innerWidth <= bp : false);
  React.useEffect(() => {
    const on = () => setM(window.innerWidth <= bp);
    on(); window.addEventListener('resize', on);
    return () => window.removeEventListener('resize', on);
  }, [bp]);
  return m;
}
const hueDot = (h) => `oklch(0.6 0.16 ${h})`;
const hueSoft = (h) => `oklch(0.95 0.04 ${h})`;
const hueIcon = (h) => `oklch(0.5 0.15 ${h})`;

function HSection({ id, children, bg, padY = 96 }) {
  return <section id={id} style={{ background: bg || 'transparent', padding: `${padY}px 0`, position: 'relative' }}>{children}</section>;
}
function HWrap({ children, max = 1160, style }) {
  return <div style={{ maxWidth: max, margin: '0 auto', padding: '0 24px', ...style }}>{children}</div>;
}
function Eyebrow({ children, color }) {
  return <div style={{ fontSize: 12, fontWeight: 800, letterSpacing: 2.6, textTransform: 'uppercase', color: color || HC.blue, marginBottom: 14 }}>{children}</div>;
}
function H2({ children, color, align = 'left', max }) {
  return <h2 className="h2" style={{ color: color || HC.ink, margin: 0, textAlign: align, maxWidth: max, marginLeft: align === 'center' ? 'auto' : undefined, marginRight: align === 'center' ? 'auto' : undefined }}>{children}</h2>;
}
function Lede({ children, color, align = 'left', max = 640 }) {
  return <p style={{ fontSize: 17.5, fontWeight: 500, lineHeight: 1.6, color: color || HC.inkSoft, maxWidth: max, margin: align === 'center' ? '16px auto 0' : '16px 0 0', textAlign: align, textWrap: 'pretty' }}>{children}</p>;
}
function Btn({ children, href, kind = 'primary', size = 'md', full }) {
  const s = { sm: { p: '11px 18px', fs: 14 }, md: { p: '15px 26px', fs: 15.5 }, lg: { p: '18px 32px', fs: 17 } }[size];
  const kinds = {
    primary: { background: `linear-gradient(135deg, ${HC.blue}, ${HC.blueDark})`, color: '#fff', border: '1.5px solid transparent', boxShadow: '0 8px 22px rgba(24,99,224,0.26)' },
    ghost: { background: '#fff', color: HC.ink, border: `1.5px solid ${HC.lineStrong}`, boxShadow: '0 1px 2px rgba(11,31,51,0.04)' },
    onDark: { background: '#fff', color: HC.blueDark, border: '1.5px solid transparent', boxShadow: '0 10px 30px rgba(3,20,45,0.28)' },
    outlineDark: { background: 'rgba(255,255,255,0.08)', color: '#fff', border: '1.5px solid rgba(255,255,255,0.45)', boxShadow: 'none' },
  }[kind];
  return (
    <a href={href} style={{
      display: full ? 'flex' : 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 9,
      padding: s.p, borderRadius: 14, fontSize: s.fs, fontWeight: 700, letterSpacing: -0.2,
      textDecoration: 'none', transition: 'transform .13s, box-shadow .13s', width: full ? '100%' : undefined, ...kinds,
    }}
      onMouseEnter={e => { e.currentTarget.style.transform = 'translateY(-2px)'; }}
      onMouseLeave={e => { e.currentTarget.style.transform = 'translateY(0)'; }}
    >{children}</a>
  );
}
function Pill({ children, color = HC.green, bg = HC.greenSoft, icon }) {
  return (
    <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7, padding: '7px 13px', borderRadius: 999, background: bg, color, fontSize: 13, fontWeight: 700 }}>
      {icon}{children}
    </span>
  );
}
function Card({ children, style, pad = 26 }) {
  return <div style={{ background: '#fff', border: `1px solid ${HC.line}`, borderRadius: 20, padding: pad, boxShadow: '0 1px 2px rgba(11,31,51,0.03)', ...style }}>{children}</div>;
}
function IconBubble({ hue, children, size = 48, bg, color }) {
  return (
    <div style={{ width: size, height: size, borderRadius: size * 0.32, background: bg || hueSoft(hue), color: color || hueIcon(hue), display: 'grid', placeItems: 'center', flexShrink: 0 }}>{children}</div>
  );
}

// Iconos (línea, 24px grid)
const HI = {
  Home: (p) => <Ic {...p}><path d="M4 11.5 12 4l8 7.5V20a1 1 0 0 1-1 1h-4v-6H9v6H5a1 1 0 0 1-1-1z"/></Ic>,
  Stetho: (p) => <Ic {...p}><path d="M6 3v6a4 4 0 0 0 8 0V3"/><path d="M10 13v3a5 5 0 0 0 5 5 4 4 0 0 0 4-4v-2"/><circle cx="19" cy="9" r="2"/></Ic>,
  Bolt: (p) => <Ic {...p}><path d="M13 2 5 14h6l-1 8 8-12h-6z"/></Ic>,
  Shield: (p) => <Ic {...p}><path d="M12 3l8 3v6c0 5-4 8-8 9-4-1-8-4-8-9V6z"/><path d="M9 12l2 2 4-4"/></Ic>,
  Flask: (p) => <Ic {...p}><path d="M9 3h6M10 3v5l-5 9a2 2 0 0 0 2 3h10a2 2 0 0 0 2-3l-5-9V3"/><path d="M7.5 15h9"/></Ic>,
  Lungs: (p) => <Ic {...p}><path d="M12 3v9"/><path d="M12 8c-1.5 0-3 1-3.5 3L7 16a2 2 0 0 0 2 3h1a2 2 0 0 0 2-2z"/><path d="M12 8c1.5 0 3 1 3.5 3L17 16a2 2 0 0 1-2 3h-1a2 2 0 0 1-2-2z"/></Ic>,
  Body: (p) => <Ic {...p}><circle cx="12" cy="5" r="2.2"/><path d="M12 9v6m0 0-3 6m3-6 3 6M6 11h12"/></Ic>,
  Heart: (p) => <Ic {...p}><path d="M12 20s-7-4.4-7-9.2A4 4 0 0 1 12 8a4 4 0 0 1 7 2.8C19 15.6 12 20 12 20z"/></Ic>,
  Pin: (p) => <Ic {...p}><path d="M12 22s-7-7.5-7-13a7 7 0 0 1 14 0c0 5.5-7 13-7 13z"/><circle cx="12" cy="9" r="2.5"/></Ic>,
  Clock: (p) => <Ic {...p}><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3.5 2"/></Ic>,
  Card: (p) => <Ic {...p}><rect x="3" y="5" width="18" height="14" rx="2.5"/><path d="M3 10h18"/></Ic>,
  Badge: (p) => <Ic {...p}><circle cx="12" cy="10" r="6"/><path d="M9.5 10l1.8 1.8L15 8.3"/><path d="M8.5 15.5 7 22l5-2.4 5 2.4-1.5-6.5"/></Ic>,
  Search: (p) => <Ic {...p}><circle cx="11" cy="11" r="6.5"/><path d="M16 16l4.5 4.5"/></Ic>,
  Chat: (p) => <Ic {...p}><path d="M21 12a8 8 0 0 1-8 8H8l-4 2 1-4.2A8 8 0 1 1 21 12z"/></Ic>,
  Star: ({ size = 16, color = '#F5A623', filled = true }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill={filled ? color : 'none'} stroke={color} strokeWidth="1.6" strokeLinejoin="round"><path d="M12 3l2.9 5.9 6.5.9-4.7 4.6 1.1 6.5L12 17.8 6.2 20.9l1.1-6.5L2.6 9.8l6.5-.9z"/></svg>
  ),
  Arrow: ({ size = 18, color = '#fff' }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14m-5-5 5 5-5 5"/></svg>
  ),
  Chevron: ({ size = 18, color = HC.inkMuted, open }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="2.3" strokeLinecap="round" strokeLinejoin="round" style={{ transition: 'transform .2s', transform: open ? 'rotate(180deg)' : 'none' }}><path d="M6 9l6 6 6-6"/></svg>
  ),
  Check: ({ size = 20, color = HC.green }) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="11" fill={color} opacity="0.14"/><path d="M7 12.5l3.5 3.5L17 9" stroke={color} strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/></svg>
  ),
};
function Ic({ size = 24, color = 'currentColor', children }) {
  return <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="1.9" strokeLinecap="round" strokeLinejoin="round">{children}</svg>;
}

Object.assign(window, { HC, HFONT, useIsMobile, hueDot, hueSoft, hueIcon, HSection, HWrap, Eyebrow, H2, Lede, Btn, Pill, Card, IconBubble, HI, Ic });
