/* Iconos y utilidades compartidas (JSX) */
const Icon = {
  cal: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><rect x="3" y="4" width="18" height="17" rx="2.5" stroke="currentColor" strokeWidth="1.8"/><path d="M3 9h18M8 2.5v3M16 2.5v3" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>,
  grid: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><rect x="3" y="3" width="7.5" height="7.5" rx="1.6" stroke="currentColor" strokeWidth="1.8"/><rect x="13.5" y="3" width="7.5" height="7.5" rx="1.6" stroke="currentColor" strokeWidth="1.8"/><rect x="3" y="13.5" width="7.5" height="7.5" rx="1.6" stroke="currentColor" strokeWidth="1.8"/><rect x="13.5" y="13.5" width="7.5" height="7.5" rx="1.6" stroke="currentColor" strokeWidth="1.8"/></svg>,
  chart: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M4 20V10M10 20V4M16 20v-7M22 20H2" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>,
  chevR: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M9 6l6 6-6 6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  chevL: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M15 6l-6 6 6 6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  plus: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M12 5v14M5 12h14" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/></svg>,
  x: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M6 6l12 12M18 6L6 18" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/></svg>,
  users: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><circle cx="9" cy="8" r="3.2" stroke="currentColor" strokeWidth="1.8"/><path d="M3.5 19a5.5 5.5 0 0111 0M16 5.2a3.2 3.2 0 010 5.6M17 13.5a5.5 5.5 0 013.5 5.5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>,
  trash: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M4 7h16M9 7V5a1 1 0 011-1h4a1 1 0 011 1v2M6 7l1 13a1 1 0 001 1h8a1 1 0 001-1l1-13" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  alert: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M12 8v5M12 16.5v.5" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/><path d="M10.3 3.9L2.6 17.5A2 2 0 004.3 20.5h15.4a2 2 0 001.7-3L13.7 3.9a2 2 0 00-3.4 0z" stroke="currentColor" strokeWidth="1.7"/></svg>,
  sun: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><circle cx="12" cy="12" r="4" stroke="currentColor" strokeWidth="1.8"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M5 5l1.4 1.4M17.6 17.6L19 19M19 5l-1.4 1.4M6.4 17.6L5 19" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>,
  book: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M4 5a2 2 0 012-2h13v16H6a2 2 0 00-2 2V5z" stroke="currentColor" strokeWidth="1.7" strokeLinejoin="round"/><path d="M4 19a2 2 0 002 2h13" stroke="currentColor" strokeWidth="1.7"/></svg>,
  doc: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M6 3h8l4 4v14H6z" stroke="currentColor" strokeWidth="1.7" strokeLinejoin="round"/><path d="M14 3v4h4M9 13h6M9 16.5h4" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round"/></svg>,
  target: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><circle cx="12" cy="12" r="8.5" stroke="currentColor" strokeWidth="1.7"/><circle cx="12" cy="12" r="4.5" stroke="currentColor" strokeWidth="1.7"/><circle cx="12" cy="12" r="1.3" fill="currentColor"/></svg>,
  pencil: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M14.5 5.5l4 4M4 20l1-4L16 5a2.1 2.1 0 013 3L8 19l-4 1z" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  download: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M12 3v12m0 0l-4-4m4 4l4-4M4 17v2a1 1 0 001 1h14a1 1 0 001-1v-2" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  upload: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M12 21V9m0 0l-4 4m4-4l4 4M4 7V5a1 1 0 011-1h14a1 1 0 011 1v2" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  chevDown: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M6 9l6 6 6-6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  refresh: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M3 12a9 9 0 0115.5-6.2L21 8M21 3v5h-5M21 12a9 9 0 01-15.5 6.2L3 16M3 21v-5h5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  sheet: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><rect x="4" y="3" width="16" height="18" rx="2" stroke="currentColor" strokeWidth="1.7"/><path d="M4 9h16M4 15h16M10 3v18" stroke="currentColor" strokeWidth="1.5"/></svg>,
  check: (p) => <svg viewBox="0 0 24 24" fill="none" {...p}><path d="M5 12.5l4.5 4.5L19 7" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round"/></svg>,
};

// Color de ocupación (escala blanco -> morado -> rojo)
function occColor(pct) {
  if (pct <= 0) return "#F1EEF8";
  if (pct < 40) return "#EDE4FB";
  if (pct < 65) return "#CBB2F0";
  if (pct < 85) return "#9B6CE0";
  if (pct <= 100) return "#7C3AED";
  if (pct <= 130) return "#C026A8";
  return "#E11D2A"; // sobrecarga fuerte
}
function occText(pct) { return pct >= 60 ? "#fff" : "var(--tinta)"; }

// icono por tipo de evento
function evIcon(type, props) {
  if (type === "vacaciones") return Icon.sun(props);
  if (type === "licencia") return Icon.doc(props);
  if (type === "capacitacion") return Icon.book(props);
  return Icon.doc(props);
}

Object.assign(window, { Icon, occColor, occText, evIcon });
