function analyzeSEOContent() {
var content = document.getElementById('textContent').value;
var keyword = document.getElementById('focusKeyword').value.trim().toLowerCase();
var resultsBox = document.getElementById('seoResults');
var checklist = document.getElementById('seoChecklist');
if (!content || !keyword) {
alert('Please enter both a keyword and content.');
return;
}
var words = content.toLowerCase().match(/\w+/g) || [];
var wordCount = words.length;
var kwRegex = new RegExp('\\b' + keyword + '\\b', 'gi');
var kwMatches = content.match(kwRegex) || [];
var kwCount = kwMatches.length;
var density = wordCount > 0 ? ((kwCount / wordCount) * 100).toFixed(2) : 0;
document.getElementById('resWordCount').innerText = wordCount;
document.getElementById('resDensity').innerText = density + '%';
var checks = [];
// Length Check
if (wordCount < 300) {
checks.push('
Content is too short (Under 300 words).
');
} else {
checks.push('
Good content length.
');
}
// Density Check
if (density > 0.5 && density < 2.5) {
checks.push('