// data.jsx — Initial seed + small helpers for MamaFlow

const PILLARS = {
  hijos:    { id: 'hijos',    label: 'Hijos',    emoji: '👶',    bg: '#FFF0F5', text: '#D4547A', border: '#FFB8CC' },
  escuela:  { id: 'escuela',  label: 'Escuela',  emoji: '📚',    bg: '#EEF2FF', text: '#4A5FD5', border: '#BCC8FF' },
  citas:    { id: 'citas',    label: 'Citas',    emoji: '🏥',    bg: '#FFF4E6', text: '#C47A1A', border: '#FFCF85' },
  personal: { id: 'personal', label: 'Tú',       emoji: '💆‍♀️', bg: '#F3EEFF', text: '#7A4DB5', border: '#CEBDFF', sacred: true },
};

const MOODS = [
  { id: 'pesado',  emoji: '😮‍💨', label: 'Pesado',    tagline: 'Hoy se vale menos',          cap: 3,    cta: 'Aplazamos las demás. No es flojera, es realidad.' },
  { id: 'bien',    emoji: '😊',    label: 'Bien',      tagline: 'Sin prisa, sin culpa',       cap: 6,    cta: 'Lo importante hoy, el resto puede esperar.' },
  { id: 'al100',   emoji: '🔥',    label: 'Al 100',    tagline: 'Tienes la energía hoy',      cap: 99,   cta: 'Vamos. Avísame si te paso un freno.' },
  { id: 'fluyendo',emoji: '✨',    label: 'Fluyendo',  tagline: 'Suave y sin lista larga',    cap: 5,    cta: 'Solo lo que disfrutes hacer.' },
];

// Etapas de la maternidad — adapta tono, sugerencias y prioridades
const STAGES = [
  { id: 'bebe',         emoji: '🍼', label: 'Bebé',                 sub: '0–2 años' },
  { id: 'preescolar',   emoji: '🧸', label: 'Preescolar',           sub: '3–5 años' },
  { id: 'escolar',      emoji: '🎒', label: 'En la escuela',        sub: '6–11 años' },
  { id: 'adolescente',  emoji: '🎧', label: 'Adolescentes',         sub: '12–17 años' },
  { id: 'adulto',       emoji: '🕊️', label: 'Adultos jóvenes',      sub: '18+' },
  { id: 'mezcla',       emoji: '🧩', label: 'Una mezcla',           sub: 'Más de una etapa' },
];

const SEED_FAMILY = [
  { id: 'me',     name: 'Tú',     short: 'V', color: '#C9626B', whatsapp: false },
  { id: 'papa',   name: 'Papá',   short: 'P', color: '#4A5FD5', whatsapp: true  },
  { id: 'abuela', name: 'Abuela', short: 'A', color: '#7A4DB5', whatsapp: true  },
];

// Avatar palette to auto-assign when a new member is added
const FAMILY_COLORS = ['#4A5FD5', '#7A4DB5', '#C47A1A', '#1F8A5B', '#D4547A', '#3D6BD9', '#A04AB0'];

function todayISO() {
  const d = new Date();
  return d.toISOString().slice(0, 10);
}
function tomorrowISO() {
  const d = new Date(); d.setDate(d.getDate() + 1);
  return d.toISOString().slice(0, 10);
}
function inDaysISO(n) {
  const d = new Date(); d.setDate(d.getDate() + n);
  return d.toISOString().slice(0, 10);
}

const SEED_TASKS = [
  { id: 't1', title: 'Pediatra de Mateo',           date: todayISO(),    time: '16:30', pillar: 'citas',    who: 'me',     done: false,
    description: 'Revisión de los 9 meses. Llevar cartilla de vacunación y muestra de orina si la pide. Estacionamiento en sótano 2.' },
  { id: 't2', title: 'Junta de padres - escuela',   date: todayISO(),    time: '18:00', pillar: 'escuela',  who: 'papa',   done: false,
    description: 'Sala de usos múltiples. Hablan del viaje de fin de curso y de la cuota voluntaria. Llevar la libreta de avisos.' },
  { id: 't3', title: 'Comprar leche y pañales',     date: todayISO(),    time: null,    pillar: 'hijos',    who: 'papa',   done: false,
    description: 'Pañales etapa 4 (los morados, no los azules). Leche entera, 2 galones. Si hay, fruta para la lonchera de mañana.' },
  { id: 't4', title: 'Lunch de Sofía',              date: todayISO(),    time: '07:00', pillar: 'hijos',    who: 'me',     done: true  },
  { id: 't5', title: 'Yoga (30 min)',               date: todayISO(),    time: '06:30', pillar: 'personal', who: 'me',     done: true,
    description: 'Clase grabada de Adriene — la de cadera. No saltar el savasana esta vez.' },
  { id: 't6', title: 'Recoger uniformes lavandería',date: tomorrowISO(), time: null,    pillar: 'hijos',    who: 'abuela', done: false,
    description: 'Lavandería de la esquina, antes de las 7pm. Son 3 piezas, ticket amarillo en mi bolsa.' },
  { id: 't7', title: 'Dentista de Sofía',           date: tomorrowISO(), time: '11:00', pillar: 'citas',    who: 'me',     done: false,
    description: 'Revisión semestral. Posible sellado de molar inferior derecho. Cita con Dra. Mendoza.' },
  { id: 't8', title: 'Mandar permiso de excursión', date: tomorrowISO(), time: null,    pillar: 'escuela',  who: 'me',     done: false,
    description: 'Firmar la hoja verde y mandarla con el dinero ($150) en sobre. Va al museo de antropología.' },
  { id: 't9', title: 'Llamar a mamá',               date: inDaysISO(2),  time: '20:00', pillar: 'personal', who: 'me',     done: false,
    description: 'Lleva 2 semanas sin saber de mí. Preguntar por el resultado del análisis.' },
  { id: 't10',title: 'Cumpleaños primo Lucas',      date: inDaysISO(3),  time: '17:00', pillar: 'hijos',    who: 'me',     done: false,
    description: 'Salón de fiestas Los Pinos. Cumple 5. Regalo: ya lo compré, está en el clóset de arriba.' },
  { id: 't11',title: 'Reunión maestra Sofía',       date: inDaysISO(5),  time: '08:30', pillar: 'escuela',  who: 'me',     done: false,
    description: 'Quiere hablar de las matemáticas. Llevar libreta y posibles fechas para tutoría.' },
  { id: 't12',title: 'Pago colegiatura',            date: inDaysISO(7),  time: null,    pillar: 'escuela',  who: 'me',     done: false,
    description: 'Transferencia a cuenta del colegio. Si paso del 10, aplican recargo del 5%.' },
];

// Format helpers — Spanish, sin librerías
const DOW = ['DOMINGO','LUNES','MARTES','MIÉRCOLES','JUEVES','VIERNES','SÁBADO'];
const MON = ['ENERO','FEBRERO','MARZO','ABRIL','MAYO','JUNIO','JULIO','AGOSTO','SEPTIEMBRE','OCTUBRE','NOVIEMBRE','DICIEMBRE'];
const MON_SHORT = ['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];

function fmtDateLong(iso) {
  if (!iso) return '';
  const d = new Date(iso + 'T12:00:00');
  return `${DOW[d.getDay()]}, ${d.getDate()} DE ${MON[d.getMonth()]}`;
}
function fmtDateShort(iso) {
  if (!iso) return '';
  const d = new Date(iso + 'T12:00:00');
  return `${d.getDate()} ${MON_SHORT[d.getMonth()]}`;
}
function relativeDay(iso) {
  if (!iso) return '';
  const t = new Date(todayISO() + 'T12:00:00');
  const d = new Date(iso + 'T12:00:00');
  const diff = Math.round((d - t) / 86400000);
  if (diff === 0) return 'Hoy';
  if (diff === 1) return 'Mañana';
  if (diff === -1) return 'Ayer';
  if (diff > 0 && diff < 7) return ['Dom','Lun','Mar','Mié','Jue','Vie','Sáb'][d.getDay()];
  return fmtDateShort(iso);
}
function fmtTime(t) {
  if (!t) return '';
  const [h, m] = t.split(':').map(Number);
  const ampm = h >= 12 ? 'PM' : 'AM';
  const h12 = h === 0 ? 12 : h > 12 ? h - 12 : h;
  return `${h12}:${m.toString().padStart(2,'0')} ${ampm}`;
}

Object.assign(window, {
  PILLARS, MOODS, STAGES, SEED_FAMILY, FAMILY_COLORS, SEED_TASKS,
  todayISO, tomorrowISO, inDaysISO,
  fmtDateLong, fmtDateShort, relativeDay, fmtTime,
  DOW, MON, MON_SHORT,
});
