`).join('');
};
// --- AI FEATURE HANDLERS ---
getInsightsBtn.addEventListener('click', async () => {
const mood = moodInput.value;
const symptoms = physicalSymptomsInput.value;
const journal = journalEntryInput.value;
if (!mood && !symptoms && !journal) {
insightsResult.innerHTML = "Please enter how you're feeling or your symptoms to get an insight.";
insightsResult.classList.remove('hidden');
return;
}
const prompt = `As a friendly and supportive AI assistant for a new mother, provide a short, gentle, and encouraging insight based on her daily log. Do not provide medical advice. Be warm and empathetic.
Her log today:
- Mood: ${mood}
- Physical Symptoms: ${symptoms || 'Not specified'}
- Private thoughts: ${journal || 'Not specified'}
Respond with 2-3 sentences of encouragement or a simple mindfulness tip.`;
const response = await callGeminiApi(prompt, insightsLoader, insightsResult, getInsightsBtn);
insightsResult.innerHTML = `
${response.replace(/\n/g, '
')}
Disclaimer: This is an AI-generated insight and not medical advice. Always consult a healthcare professional.
`; insightsResult.classList.remove('hidden'); }); getQuestionsBtn.addEventListener('click', async () => { const apptFor = apptForInput.value; const reason = apptProviderInput.value; if (!reason) { apptNotesInput.value = "Please enter a reason for the appointment to get suggested questions."; return; } const prompt = `Generate a helpful list of 5-7 questions a new parent should ask a healthcare provider during an appointment. The appointment is for the "${apptFor}" and the reason is "${reason}". Format the output as a numbered list. Do not include a preamble or conclusion, just the list of questions.`; const response = await callGeminiApi(prompt, questionsLoader, null, getQuestionsBtn); const currentNotes = apptNotesInput.value; const separator = currentNotes.trim() === '' ? '' : '\n\n--- Suggested Questions ---\n'; apptNotesInput.value = currentNotes + separator + response; }); // --- SUMMARY & PDF GENERATION --- renderSummary = () => { summaryDateEl.textContent = `Report generated on ${new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}`; summaryAppointmentsContainer.innerHTML = plannerData.appointments.length > 0 ? `Appointments
${plannerData.appointments.map(a => ``).join('')}
` : `${formatDate(a.date)}: ${a.provider} (For: ${a.for})
${a.notes ? `Notes: ${a.notes}
` : ''}No Appointments Logged
`; summaryLogsContainer.innerHTML = plannerData.logs.length > 0 ? `Daily Log Summary
${plannerData.logs.map(l => ``).join('')}
` : `${formatDate(l.date)}: Mood: ${l.mood}
${l.symptoms ? `Symptoms: ${l.symptoms}
` : ''}${l.journal ? `Journal: ${l.journal}
` : ''}${l.feedType ? `Feeding: ${l.feedTime}, ${l.feedType}, ${l.feedAmount}
` : ''}No Daily Logs Recorded
`; summaryResourcesContainer.innerHTML = plannerData.resources.length > 0 ? `My Support Team
${plannerData.resources.map(r => ``).join('')}
` : `${r.name} - ${r.role}
${r.phone || ''} ${r.email ? `| ${r.email}` : ''}
