Hadith Search Results

Found 4 hadiths

New Hadith

Book: Sahih Al-Bukhari

Warning: include_once(/home/uplenvmg/hadithworld.com/wp-content/plugins/hadith-page/admin/partials/hadith-world-admin-translations.php): Failed to open stream: No such file or directory in /home/uplenvmg/hadithworld.com/wp-content/plugins/hadith-page/admin/class-hadith-world-admin.php on line 146

Warning: include_once(): Failed opening ‘/home/uplenvmg/hadithworld.com/wp-content/plugins/hadith-page/admin/partials/hadith-world-admin-translations.php’ for inclusion (include_path=’.:/opt/alt/php82/usr/share/pear:/opt/alt/php82/usr/share/php:/usr/share/pear:/usr/share/php’) in /home/uplenvmg/hadithworld.com/wp-content/plugins/hadith-page/admin/class-hadith-world-admin.php on line 146

Daif Topics: Importance Of Faith (Iman)

new hadith

Book: Sahih Al-Bukhari

Actions are judged by intentions, and each person will be rewarded according to their intentions. So whoever emigrates for the sake of Allah and His Messenger, then his emigration is for Allah and His Messenger. And whoever emigrates to acquire worldly things or to marry a woman, then his emigration is for what he emigrated for.’,
textAr: ‘إنما الأعمال بالنيات، وإنما لكل امرئ ما نوى، فمن كانت هجرته إلى الله ورسوله فهجرته إلى الله ورسوله، ومن كانت هجرته لدنيا يصيبها أو امرأة ينكحها فهجرته إلى ما هاجر إليه.’,
textUr: ‘اعمال کا دارومدار نیتوں پر ہے، اور ہر شخص کو وہی ملے گا جس کی اس نے نیت کی، پس جس کی ہجرت اللہ اور اس کے رسول کی طرف ہو، تو اس کی ہجرت اللہ اور اس کے رسول کی طرف ہے، اور جس کی ہجرت دنیا حاصل کرنے یا کسی عورت سے شادی کرنے کے لیے ہو، تو اس کی ہجرت اسی چیز کی طرف ہے جس کے لیے اس نے ہجرت کی۔’,
textBn: ‘কাজগুলি নিয়তের উপর নির্ভর করে, এবং প্রত্যেক ব্যক্তি তার নিয়ত অনুযায়ী পুরস্কৃত হবে। সুতরাং যে আল্লাহ এবং তাঁর রাসূলের জন্য হিজরত করে, তার হিজরত আল্লাহ এবং তাঁর রাসূলের জন্য। আর যে পার্থিব সম্পদ অর্জন করতে বা কোন নারীকে বিবাহ করতে হিজরত করে, তার হিজরত সেই জিনিসের জন্য যার জন্য সে হিজরত করেছে।’,
category: ‘intention’,
narrator: ‘Umar ibn Al-Khattab’,
source: ‘Sahih Bukhari’,
reference: ‘Book 1, Hadith 1’,
authenticity: ‘sahih’,
views: 1240
},
{
id: 2,
text: ‘Verily, Allah does not look at your appearance or wealth, but rather He looks at your hearts and your deeds.’,
textAr: ‘إن الله لا ينظر إلى صوركم وأموالكم، ولكن ينظر إلى قلوبكم وأعمالكم.’,
textUr: ‘بیشک اللہ تمہاری شکلوں اور مالوں کی طرف نہیں دیکھتا، بلکہ وہ تمہارے دلوں اور اعمال کی طرف دیکھتا ہے۔’,
textBn: ‘নিশ্চয়ই আল্লাহ তোমাদের চেহারা বা সম্পদের দিকে তাকান না, বরং তিনি তোমাদের হৃদয় এবং কর্মের দিকে তাকান।’,
category: ‘intention’,
narrator: ‘Abu Hurairah’,
source: ‘Sahih Muslim’,
reference: ‘Book 45, Hadith 2564’,
authenticity: ‘sahih’,
views: 980
},
{
id: 3,
text: ‘The most beloved deeds to Allah are those that are consistent, even if they are small.’,
textAr: ‘أحب الأعمال إلى الله أدومها وإن قل.’,
textUr: ‘اللہ کو سب سے زیادہ پسندیدہ عمل وہ ہے جو مستقل ہو، چاہے وہ تھوڑا ہی ہو۔’,
textBn: ‘আল্লাহর কাছে সবচেয়ে প্রিয় আমল হল যা নিয়মিত করা হয়, যদিও তা অল্প হয়।’,
category: ‘deeds’,
narrator: ‘Aisha’,
source: ‘Sahih Bukhari’,
reference: ‘Book 76, Hadith 469’,
authenticity: ‘sahih’,
views: 820
},
{
id: 4,
text: ‘Whoever believes in Allah and the Last Day, let him speak good or remain silent. Whoever believes in Allah and the Last Day, let him be kind to his neighbor. Whoever believes in Allah and the Last Day, let him be generous to his guest.’,
textAr: ‘من كان يؤمن بالله واليوم الآخر فليقل خيرا أو ليصمت، ومن كان يؤمن بالله واليوم الآخر فليكرم جاره، ومن كان يؤمن بالله واليوم الآخر فليكرم ضيفه.’,
textUr: ‘جو اللہ اور آخرت کے دن پر ایمان رکھتا ہے، وہ اچھی بات کہے یا خاموش رہے۔ جو اللہ اور آخرت کے دن پر ایمان رکھتا ہے، وہ اپنے پڑوسی کا احترام کرے۔ جو اللہ اور آخرت کے دن پر ایمان رکھتا ہے، وہ اپنے مہمان کا اکرام کرے۔’,
textBn: ‘যে আল্লাহ এবং শেষ দিনের প্রতি বিশ্বাস করে, সে যেন ভালো কথা বলে অথবা চুপ থাকে। যে আল্লাহ এবং শেষ দিনের প্রতি বিশ্বাস করে, সে যেন তার প্রতিবেশীর প্রতি সদয় হয়। যে আল্লাহ এবং শেষ দিনের প্রতি বিশ্বাস করে, সে যেন তার অতিথির প্রতি উদার হয়।’,
category: ‘character’,
narrator: ‘Abu Hurairah’,
source: ‘Sahih Bukhari’,
reference: ‘Book 78, Hadith 6018’,
authenticity: ‘sahih’,
views: 750
},
{
id: 5,
text: ‘Worship Allah as if you see Him, for even though you do not see Him, He surely sees you.’,
textAr: ‘اعبد الله كأنك تراه، فإن لم تكن تراه فإنه يراك.’,
textUr: ‘اللہ کی عبادت ایسے کرو جیسے تم اسے دیکھ رہے ہو، اور اگر تم اسے نہیں دیکھ سکتے تو وہ تمہیں دیکھ رہا ہے۔’,
textBn: ‘আল্লাহর ইবাদত এমনভাবে করো যেন তুমি তাকে দেখতে পাচ্ছ, কারণ যদিও তুমি তাকে দেখতে পাচ্ছ না, তিনি অবশ্যই তোমাকে দেখছেন।’,
category: ‘worship’,
narrator: ‘Umar ibn Al-Khattab’,
source: ‘Sahih Muslim’,
reference: ‘Book 1, Hadith 8’,
authenticity: ‘sahih’,
views: 1050
},
{
id: 6,
text: ‘The example of the one who remembers his Lord and the one who does not remember his Lord is like the example of the living and the dead.’,
textAr: ‘مثل الذي يذكر ربه والذي لا يذكر ربه مثل الحي والميت.’,
textUr: ‘اپنے رب کو یاد کرنے والے اور یاد نہ کرنے والے کی مثال زندہ اور مردہ کی طرح ہے۔’,
textBn: ‘যে তার প্রভুকে স্মরণ করে এবং যে তার প্রভুকে স্মরণ করে না, তাদের উদাহরণ জীবিত ও মৃতের মতো।’,
category: ‘worship’,
narrator: ‘Abu Musa’,
source: ‘Sahih Bukhari’,
reference: ‘Book 75, Hadith 6407’,
authenticity: ‘hassan’,
views: 620
},
{
id: 7,
text: ‘The strong person is not the one who can wrestle others to the ground. The strong person is the one who can control himself when angry.’,
textAr: ‘ليس الشديد بالصرعة، إنما الشديد الذي يملك نفسه عند الغضب.’,
textUr: ‘طاقتور وہ نہیں جو دوسروں کو پٹک دے، بلکہ طاقتور وہ ہے جو غصے کے وقت اپنے آپ پر قابو رکھے۔’,
textBn: ‘শক্তিশালী ব্যক্তি সে নয় যে অন্যদের মাটিতে কুস্তি করতে পারে। শক্তিশালী ব্যক্তি হল সে, যে রাগের সময় নিজেকে নিয়ন্ত্রণ করতে পারে।’,
category: ‘character’,
narrator: ‘Abu Hurairah’,
source: ‘Sahih Bukhari’,
reference: ‘Book 73, Hadith 135’,
authenticity: ‘hassan’,
views: 920
},
{
id: 8,
text: ‘Verily, deeds are judged by their outcomes.’,
textAr: ‘إنما الأعمال بخواتيمها.’,
textUr: ‘بیشک اعمال کا انحصار ان کے انجام پر ہے۔’,
textBn: ‘নিশ্চয়ই আমলসমূহ তার পরিণতি দ্বারা বিচার করা হয়।’,
category: ‘deeds’,
narrator: ‘Sahl ibn Sa\’d’,
source: ‘Sahih Bukhari’,
reference: ‘Book 83, Hadith 45’,
authenticity: ‘daif’,
views: 430
}
];

// Basic translations for essential elements
const translations = {
en: {
‘faith’: ‘Faith & Belief’,
‘worship’: ‘Worship’,
‘character’: ‘Character & Morals’,
‘family’: ‘Family Life’,
‘society’: ‘Society & Relations’,
‘knowledge’: ‘Knowledge’,
‘hadiths’: ‘hadiths’,
‘read-more’: ‘Read More’,
‘narrators’: ‘Narrators’,
‘all’: ‘All Topics’,
‘categories’: ‘Categories’,
‘view’: ‘View’,
‘topics’: ‘topics’,
‘collections’: ‘Collections’,
‘narrator-filter’: ‘Filter by Narrator’,
‘alphabet-filter’: ‘Alphabetical Filter’
},
ar: {
‘faith’: ‘الإيمان والعقيدة’,
‘worship’: ‘العبادات’,
‘character’: ‘الأخلاق والآداب’,
‘family’: ‘الحياة الأسرية’,
‘society’: ‘المجتمع والعلاقات’,
‘knowledge’: ‘العلم’,
‘hadiths’: ‘أحاديث’,
‘read-more’: ‘اقرأ المزيد’,
‘narrators’: ‘الرواة’,
‘all’: ‘جميع المواضيع’,
‘categories’: ‘الفئات’,
‘view’: ‘عرض’,
‘topics’: ‘المواضيع’,
‘collections’: ‘المجموعات’,
‘narrator-filter’: ‘تصفية حسب الراوي’,
‘alphabet-filter’: ‘تصفية أبجدية’
},
ur: {
‘faith’: ‘ایمان و عقیدہ’,
‘worship’: ‘عبادات’,
‘character’: ‘اخلاق و آداب’,
‘family’: ‘خاندانی زندگی’,
‘society’: ‘معاشرہ اور تعلقات’,
‘knowledge’: ‘علم’,
‘hadiths’: ‘احادیث’,
‘read-more’: ‘مزید پڑھیں’,
‘narrators’: ‘راویوں’,
‘all’: ‘تمام موضوعات’,
‘categories’: ‘زمرہ جات’,
‘view’: ‘نظارہ’,
‘topics’: ‘موضوعات’,
‘collections’: ‘مجموعے’,
‘narrator-filter’: ‘راوی کے مطابق فلٹر کریں’,
‘alphabet-filter’: ‘حروف تہجی فلٹر’
},
bn: {
‘faith’: ‘ঈমান ও বিশ্বাস’,
‘worship’: ‘ইবাদত’,
‘character’: ‘চরিত্র ও নৈতিকতা’,
‘family’: ‘পারিবারিক জীবন’,
‘society’: ‘সমাজ ও সম্পর্ক’,
‘knowledge’: ‘জ্ঞান’,
‘hadiths’: ‘হাদিস’,
‘read-more’: ‘আরও পড়ুন’,
‘narrators’: ‘বর্ণনাকারীগণ’,
‘all’: ‘সমস্ত বিষয়’,
‘categories’: ‘বিভাগসমূহ’,
‘view’: ‘দৃশ্য’,
‘topics’: ‘বিষয়সমূহ’,
‘collections’: ‘সংগ্রহ’,
‘narrator-filter’: ‘বর্ণনাকারী অনুযায়ী ফিল্টার করুন’,
‘alphabet-filter’: ‘বর্ণানুক্রমিক ফিল্টার’
}
};

// Global state
const state = {
currentLang: ‘en’,
currentCategory: ‘all’,
currentView: ‘grid’,
currentNarrator: ‘all’,
currentLetter: ‘all’,
searchTerm: ”,
currentPage: 1,
itemsPerPage: 6,
advancedFiltersOpen: false,
hadithLength: 3,
applyLengthFilter: false,
collection: ‘all’,
authenticity: ‘all’,
viewSortOption: ‘default’ // Default, mostViewed, recentlyViewed, etc.
};

// Core Functionality – Renders hadiths in the grid
function renderTopics() {
console.log(‘Rendering topics with:’, state);

const topicsGrid = document.getElementById('topics-grid');
if (!topicsGrid) return;

// Clear grid
topicsGrid.innerHTML = '';

// Add appropriate class for view mode
if (state.currentView === 'grid') {
    topicsGrid.className = 'hadiths-grid';
} else if (state.currentView === 'list') {
    topicsGrid.className = 'hadiths-grid list-view';
} else if (state.currentView === 'masonry') {
    topicsGrid.className = 'hadiths-grid masonry-view';
}

// Filter topics based on current filters
let filteredTopics = hadithsData.filter(hadith => {
    // Match language - skip language check for sample data that doesn't have lang property
    if (hadith.lang && hadith.lang !== state.currentLang && hadith.lang !== 'all') {
        return false;
    }

    // Match category
    if (state.currentCategory !== 'all' && hadith.category !== state.currentCategory) {
        return false;
    }

    // Match narrator
    if (state.currentNarrator !== 'all' && hadith.narrator !== state.currentNarrator) {
        return false;
    }

    // Match collection
    if (state.collection !== 'all' && !hadith.source.toLowerCase().includes(state.collection.toLowerCase())) {
        return false;
    }

    // Match authenticity ONLY if hadith has authenticity property and state.authenticity is not 'all'
    if (state.authenticity !== 'all' && hadith.authenticity && hadith.authenticity !== state.authenticity) {
        return false;
    }

    // Match search term
    if (state.searchTerm && !hadith.text.toLowerCase().includes(state.searchTerm.toLowerCase())) {
        return false;
    }

    // Match hadith length filter (only if we're using this filter)
    if (state.hadithLength > 0 && state.applyLengthFilter) {
        const textLength = hadith.text.length;
        // Very basic length mapping - can be refined based on actual content
        const lengthMap = {
            1: {min: 0, max: 100}, // Very short
            2: {min: 100, max: 250}, // Short
            3: {min: 250, max: 500}, // Medium
            4: {min: 500, max: 800}, // Long
            5: {min: 800, max: Infinity} // Very long
        };

        const lengthRange = lengthMap[state.hadithLength];
        if (textLength < lengthRange.min || textLength > lengthRange.max) {
            return false;
        }
    }

    return true;
});

// Apply sorting
if (filteredTopics.length > 0) {
    switch(state.viewSortOption) {
        case 'mostViewed':
            // Simulate most viewed with some random view counts
            filteredTopics.sort((a, b) => (b.views || Math.random() * 1000) - (a.views || Math.random() * 1000));
            break;
        case 'recentlyViewed':
            // Simulate recently viewed with random timestamps
            filteredTopics.sort((a, b) => (b.lastViewed || Date.now() - Math.random() * 10000000) - 
                                         (a.lastViewed || Date.now() - Math.random() * 10000000));
            break;
        case 'narrator':
            filteredTopics.sort((a, b) => a.narrator.localeCompare(b.narrator));
            break;
        case 'collection':
            filteredTopics.sort((a, b) => a.source.localeCompare(b.source));
            break;
        case 'relevance':
        default:
            // Just keep the default sort by ID
            break;
    }
}

// Get topics for current page
const startIndex = (state.currentPage - 1) * state.itemsPerPage;
const paginatedTopics = filteredTopics.slice(startIndex, startIndex + state.itemsPerPage);

// Update count
const topicsCountElement = document.getElementById('topics-count');
if (topicsCountElement) {
    topicsCountElement.textContent = filteredTopics.length;
}

// Display message if no topics match filters
if (paginatedTopics.length === 0) {
    const noResultsDiv = document.createElement('div');
    noResultsDiv.className = 'no-results';
    noResultsDiv.innerHTML = `
        <i class="fas fa-search"></i>
        <p>No hadiths found matching your filters. Try adjusting your search criteria.</p>
    `;
    topicsGrid.appendChild(noResultsDiv);

    // Hide pagination if no results
    const paginationElement = document.querySelector('.pagination');
    if (paginationElement) {
        paginationElement.style.display = 'none';
    }

    return;
}

// Show pagination if we have results
const paginationElement = document.querySelector('.pagination');
if (paginationElement) {
    paginationElement.style.display = 'flex';
}

// Set item count per page based on view (more items in list view)
state.itemsPerPage = state.currentView === 'list' ? 8 : 6;

// Render topics
paginatedTopics.forEach(hadith => {
    const hadithCard = renderHadithCard(hadith);
    topicsGrid.appendChild(hadithCard);
});

// For masonry view, calculate and set heights
if (state.currentView === 'masonry') {
    initMasonryLayout();
}

// Update pagination
const totalPages = Math.ceil(filteredTopics.length / state.itemsPerPage);
updatePagination(totalPages);

}

// Initialize masonry layout
function initMasonryLayout() {
// Give time for the DOM to render
setTimeout(() => {
const cards = document.querySelectorAll(‘.hadiths-grid.masonry-view .hadith-card’);
cards.forEach(card => {
// Get the actual height and divide by the row height (20px)
const height = Math.ceil(card.getBoundingClientRect().height / 20);
card.style.setProperty(‘–card-height’, height);
});
}, 100);
}

// Update pagination controls
function updatePagination(totalPages) {
const paginationElement = document.querySelector(‘.pagination’);
const pageNumbersElement = document.getElementById(‘page-numbers’);
const prevButton = document.getElementById(‘prev-page’);
const nextButton = document.getElementById(‘next-page’);

if (!paginationElement || !pageNumbersElement) return;

// Show pagination if we have more than one page
if (totalPages <= 1) {
    paginationElement.style.display = 'none';
    return;
} else {
    paginationElement.style.display = 'flex';
}

// Clear page numbers
pageNumbersElement.innerHTML = '';

// Determine range of page numbers to show
let startPage = Math.max(1, state.currentPage - 2);
let endPage = Math.min(totalPages, startPage + 4);

// Adjust start if we're near the end
if (endPage - startPage < 4) {
    startPage = Math.max(1, endPage - 4);
}

// Add page numbers
for (let i = startPage; i <= endPage; i++) {
    const pageNumber = document.createElement('span');
    pageNumber.className = `page-number ${i === state.currentPage ? 'active' : ''}`;
    pageNumber.textContent = i;
    pageNumber.addEventListener('click', function() {
        state.currentPage = i;
        renderTopics();
        // Scroll to top of grid
        const gridElement = document.getElementById('topics-grid');
        if (gridElement) {
            gridElement.scrollIntoView({ behavior: 'smooth', block: 'start' });
        }
    });
    pageNumbersElement.appendChild(pageNumber);
}

// Update prev/next buttons
prevButton.disabled = state.currentPage === 1;
nextButton.disabled = state.currentPage === totalPages;

// Add event listeners to prev/next buttons
prevButton.onclick = function() {
    if (state.currentPage > 1) {
        state.currentPage--;
        renderTopics();
        // Scroll to top of grid
        const gridElement = document.getElementById('topics-grid');
        if (gridElement) {
            gridElement.scrollIntoView({ behavior: 'smooth', block: 'start' });
        }
    }
};

nextButton.onclick = function() {
    if (state.currentPage < totalPages) {
        state.currentPage++;
        renderTopics();
        // Scroll to top of grid
        const gridElement = document.getElementById('topics-grid');
        if (gridElement) {
            gridElement.scrollIntoView({ behavior: 'smooth', block: 'start' });
        }
    }
};

}

// Show hadith modal with full content
function showHadithModal(hadithId) {
const hadith = hadithsData.find(h => h.id === hadithId);
if (!hadith) return;

// Select content based on language
let textField;
if (state.currentLang === 'ar') {
    textField = 'textAr';
} else if (state.currentLang === 'ur') {
    textField = 'textUr';
} else if (state.currentLang === 'bn') {
    textField = 'textBn';
} else {
    textField = 'text';
}

// Get translated category
const lang = state.currentLang;
const categoryText = translations[lang][hadith.category] || hadith.category;

// Create modal element
const modal = document.createElement('div');
modal.className = 'hadith-modal';
modal.innerHTML = `
    <div class="hadith-modal-content">
        <span class="close-modal">&times;</span>
        <div class="hadith-modal-header">
            <div class="hadith-category-tag">${categoryText}</div>
            <h3>${hadith.narrator}</h3>
            <div class="hadith-modal-meta">
                <span><i class="fas fa-book"></i> ${hadith.source}</span>
                <span><i class="fas fa-bookmark"></i> ${hadith.reference}</span>
            </div>
        </div>
        <div class="hadith-modal-body">
            <i class="fas fa-quote-right quote-icon"></i>
            <p>${hadith[textField]}</p>
        </div>
    </div>
`;

// Add modal to body
document.body.appendChild(modal);

// Prevent body scrolling
document.body.style.overflow = 'hidden';

// Show modal with animation
setTimeout(() => {
    modal.classList.add('show');
}, 10);

// Close modal on click
const closeButton = modal.querySelector('.close-modal');
closeButton.addEventListener('click', function() {
    closeHadithModal(modal);
});

// Close modal when clicking outside content
modal.addEventListener('click', function(e) {
    if (e.target === modal) {
        closeHadithModal(modal);
    }
});

// Close modal on Escape key
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') {
        closeHadithModal(modal);
    }
});

}

// Close hadith modal
function closeHadithModal(modal) {
modal.classList.remove(‘show’);
setTimeout(() => {
document.body.removeChild(modal);
document.body.style.overflow = ‘auto’;
}, 300);
}

// Generate narrators filter options
function populateNarratorsFilter() {
const narratorsFilter = document.getElementById(‘narrators-filter’);
if (!narratorsFilter) return;

// Get unique narrators
const narrators = [...new Set(hadithsData.map(hadith => hadith.narrator))];

// Clear previous options
narratorsFilter.innerHTML = '';

// Add "All Narrators" option
const allOption = document.createElement('option');
allOption.value = 'all';
allOption.textContent = translations[state.currentLang]['all'] || 'All Narrators';
narratorsFilter.appendChild(allOption);

// Add narrator options
narrators.forEach(narrator => {
    const option = document.createElement('option');
    option.value = narrator;
    option.textContent = narrator;
    narratorsFilter.appendChild(option);
});

// Set current selection
narratorsFilter.value = state.currentNarrator;

}

// Save user preferences to localStorage
function saveUserPreferences() {
try {
const preferences = {
language: state.currentLang,
category: state.currentCategory,
viewMode: state.currentView
};

    localStorage.setItem('userPreferences', JSON.stringify(preferences));
} catch (error) {
    console.error('Error saving user preferences:', error);
}

}

// Load user preferences from localStorage
function loadUserPreferences() {
try {
const savedPrefs = JSON.parse(localStorage.getItem(‘userPreferences’)) || {};

    // Restore category
    if (savedPrefs.category) {
        state.currentCategory = savedPrefs.category;

        // Update UI to match
        const categoryItem = document.querySelector(`.category-item[data-category="${savedPrefs.category}"]`);
        if (categoryItem) {
            document.querySelectorAll('.category-item').forEach(item => item.classList.remove('active'));
            categoryItem.classList.add('active');
        }
    }

    // Restore view mode
    if (savedPrefs.viewMode) {
        state.currentView = savedPrefs.viewMode;

        // Update UI to match
        const viewBtn = document.querySelector(`.view-btn[data-view="${savedPrefs.viewMode}"]`);
        if (viewBtn) {
            document.querySelectorAll('.view-btn').forEach(btn => btn.classList.remove('active'));
            viewBtn.classList.add('active');
        }
    }

    // Restore language
    if (savedPrefs.language) {
        state.currentLang = savedPrefs.language;

        // Update UI to match
        const langBtn = document.querySelector(`.lang-btn[data-lang="${savedPrefs.language}"]`);
        if (langBtn) {
            document.querySelectorAll('.lang-btn').forEach(btn => btn.classList.remove('active'));
            langBtn.classList.add('active');
        }

        // Set RTL for Arabic and Urdu
        document.documentElement.setAttribute('dir', 
            savedPrefs.language === 'ar' || savedPrefs.language === 'ur' ? 'rtl' : 'ltr');

        // Update language attribute for Bengali specific styling
        document.documentElement.setAttribute('lang', savedPrefs.language);
    }
} catch (error) {
    console.error('Error loading user preferences:', error);
}

}

// Set up event listeners for core functionality
function setupEventListeners() {
console.log(‘Setting up event listeners…’);

// Category selection
const categoryItems = document.querySelectorAll('.category-item');
categoryItems.forEach(item => {
    item.addEventListener('click', function() {
        // Update active state
        categoryItems.forEach(cat => cat.classList.remove('active'));
        this.classList.add('active');

        // Update state and render
        state.currentCategory = this.getAttribute('data-category');

        // Reset other filters when changing category
        state.currentLetter = 'all';
        updateAlphabetFilterUI();

        // Save user preferences
        saveUserPreferences();

        renderTopics();
    });
});

// Alphabet filter buttons
const alphabetButtons = document.querySelectorAll('.alphabet-btn');
alphabetButtons.forEach(btn => {
    btn.addEventListener('click', function() {
        // Update active state
        alphabetButtons.forEach(b => b.classList.remove('active'));
        this.classList.add('active');

        // Update state and render
        state.currentLetter = this.getAttribute('data-letter');
        state.currentPage = 1; // Reset to first page when filtering
        renderTopics();
    });
});

// View buttons
const viewButtons = document.querySelectorAll('.view-btn');
viewButtons.forEach(button => {
    button.addEventListener('click', () => {
        // Remove active class from all buttons
        viewButtons.forEach(b => b.classList.remove('active'));

        // Add active class to clicked button
        button.classList.add('active');

        // Update state
        state.currentView = button.dataset.view;

        // Re-render topics
        renderTopics();
    });
});

// Language switcher
const langButtons = document.querySelectorAll('.lang-btn');
langButtons.forEach(btn => {
    btn.addEventListener('click', function() {
        // Update active state
        langButtons.forEach(b => b.classList.remove('active'));
        this.classList.add('active');

        // Update state and render
        state.currentLang = this.getAttribute('data-lang');

        // Set RTL for Arabic and Urdu
        document.documentElement.setAttribute('dir', 
            state.currentLang === 'ar' || state.currentLang === 'ur' ? 'rtl' : 'ltr');

        // Update language attribute for Bengali specific styling
        document.documentElement.setAttribute('lang', state.currentLang);

        // Update filter labels based on language
        updateInterfaceTranslations();

        // Repopulate narrator filter with translated labels
        populateNarratorsFilter();

        // Save user preferences
        saveUserPreferences();

        renderTopics();
    });
});

// Narrators filter
const narratorsFilter = document.getElementById('narrators-filter');
if (narratorsFilter) {
    narratorsFilter.addEventListener('change', function() {
        state.currentNarrator = this.value;
        renderTopics();
    });
}

// Sort topics
const sortSelect = document.getElementById('sort-topics');
if (sortSelect) {
    sortSelect.addEventListener('change', function() {
        const sortBy = this.value;

        // Sort topics based on selection
        if (sortBy === 'newest') {
            hadithsData.sort((a, b) => b.id - a.id);
        } else if (sortBy === 'oldest') {
            hadithsData.sort((a, b) => a.id - b.id);
        } else if (sortBy === 'most-hadith') {
            hadithsData.sort((a, b) => b.count - a.count);
        } else {
            // Default sort by ID
            hadithsData.sort((a, b) => a.id - b.id);
        }

        renderTopics();
    });
}

// Scroll to top button
const scrollTopBtn = document.getElementById('scroll-top');
if (scrollTopBtn) {
    // Show/hide button on scroll
    window.addEventListener('scroll', function() {
        if (window.pageYOffset > 300) {
            scrollTopBtn.classList.add('visible');
        } else {
            scrollTopBtn.classList.remove('visible');
        }
    });

    // Scroll to top on click
    scrollTopBtn.addEventListener('click', function() {
        window.scrollTo({ top: 0, behavior: 'smooth' });
    });
}

// New filter functionality
const advancedFilterToggle = document.querySelector('.advanced-filter-toggle');
const advancedFilters = document.querySelector('.advanced-filters');
const filterTags = document.querySelectorAll('.filter-tag');
const filterSelect = document.querySelectorAll('.filter-select');
const filterSearch = document.querySelector('.filter-search input');
const resetFilterBtn = document.querySelector('.filter-action-btn:not(.primary)');
const applyFilterBtn = document.querySelector('.filter-action-btn.primary');
const lengthSlider = document.getElementById('length-slider');

if (advancedFilterToggle) {
    advancedFilterToggle.addEventListener('click', function() {
        state.advancedFiltersOpen = !state.advancedFiltersOpen;
        if (state.advancedFiltersOpen) {
            advancedFilters.classList.add('open');
            advancedFilterToggle.classList.add('open');
        } else {
            advancedFilters.classList.remove('open');
            advancedFilterToggle.classList.remove('open');
        }
    });
}

// Filter tags click events
if (filterTags) {
    filterTags.forEach(tag => {
        tag.addEventListener('click', function() {
            // Remove active class from all tags
            filterTags.forEach(t => t.classList.remove('active'));

            // Add active class to clicked tag
            this.classList.add('active');

            // Get category from tag's text content
            const tagText = this.textContent.trim().toLowerCase();
            if (tagText.includes('all')) {
                state.currentCategory = 'all';
            } else if (tagText.includes('worship')) {
                state.currentCategory = 'worship';
            } else if (tagText.includes('character')) {
                state.currentCategory = 'character';
            } else if (tagText.includes('good deeds')) {
                state.currentCategory = 'deeds';
            } else if (tagText.includes('featured')) {
                state.currentCategory = 'featured';
            }

            // Render with new filters
            state.currentPage = 1;
            renderTopics();
        });
    });
}

// Filter select change events
if (filterSelect) {
    filterSelect.forEach(select => {
        select.addEventListener('change', function() {
            const filterType = this.previousElementSibling?.textContent.trim().toLowerCase();

            if (filterType.includes('collection')) {
                state.collection = this.value;
            } else if (filterType.includes('category')) {
                state.currentCategory = this.value;
            } else if (filterType.includes('narrator')) {
                state.currentNarrator = this.value;
            }
        });
    });
}

// Filter search input
if (filterSearch) {
    filterSearch.addEventListener('input', debounce(function() {
        state.searchTerm = this.value.trim().toLowerCase();
    }, 300));
}

// Hadith length slider
if (lengthSlider) {
    lengthSlider.addEventListener('input', function() {
        state.hadithLength = parseInt(this.value);
    });
}

// Reset filters button
if (resetFilterBtn) {
    resetFilterBtn.addEventListener('click', function() {
        // Reset state
        state.currentCategory = 'all';
        state.currentNarrator = 'all';
        state.collection = 'all';
        state.searchTerm = '';
        state.hadithLength = 3;

        // Reset UI
        filterTags.forEach(tag => {
            if (tag.textContent.trim().toLowerCase().includes('all')) {
                tag.classList.add('active');
            } else {
                tag.classList.remove('active');
            }
        });

        filterSelect.forEach(select => {
            select.value = 'all';
        });

        if (filterSearch) {
            filterSearch.value = '';
        }

        if (lengthSlider) {
            lengthSlider.value = 3;
        }

        // Render with reset filters
        state.currentPage = 1;
        renderTopics();
    });
}

// Apply filters button
if (applyFilterBtn) {
    applyFilterBtn.addEventListener('click', function() {
        // Apply filters and update display
        state.currentPage = 1;
        renderTopics();

        // Add visual feedback
        this.innerHTML = '<i class="fas fa-check"></i> Filters Applied';
        setTimeout(() => {
            this.innerHTML = '<i class="fas fa-check"></i> Apply Filters';
        }, 2000);
    });
}

// Authenticity filter tags
const authenticityTags = document.querySelectorAll('.authenticity-tag');
authenticityTags.forEach(tag => {
    tag.addEventListener('click', () => {
        // Toggle active class
        const wasActive = tag.classList.contains('active');
        authenticityTags.forEach(t => t.classList.remove('active'));

        // If it was already active, deselect it (set to 'all')
        if (wasActive) {
            state.authenticity = 'all';
        } else {
            // Add active class to clicked tag
            tag.classList.add('active');

            // Extract authenticity value from the tag's text content
            const tagText = tag.textContent.trim().toLowerCase();
            if (tagText.includes('sahih')) {
                state.authenticity = 'sahih';
            } else if (tagText.includes('hassan')) {
                state.authenticity = 'hassan';
            } else if (tagText.includes('da\'if') || tagText.includes('daif')) {
                state.authenticity = 'daif';
            } else if (tagText.includes('mawdu')) {
                state.authenticity = 'mawdu';
            } else {
                state.authenticity = 'all';
            }
        }

        state.currentPage = 1; // Reset to first page

        // Re-render topics
        renderTopics();
    });
});

// Filter tags for view options (Most Viewed, Recently Viewed, etc.)
const filterTagsView = document.querySelectorAll('.filter-tag');
filterTagsView.forEach(tag => {
    tag.addEventListener('click', () => {
        // Remove active class from all tags
        filterTagsView.forEach(t => t.classList.remove('active'));

        // Add active class to clicked tag
        tag.classList.add('active');

        // Update state based on the tag text
        const tagText = tag.textContent.trim().toLowerCase();
        if (tagText.includes('most viewed')) {
            state.viewSortOption = 'mostViewed';
        } else if (tagText.includes('recently viewed')) {
            state.viewSortOption = 'recentlyViewed';
        } else if (tagText.includes('bookmarked')) {
            state.viewSortOption = 'bookmarked';
        } else if (tagText.includes('most shared')) {
            state.viewSortOption = 'mostShared';
        } else {
            state.viewSortOption = 'default';
        }

        state.currentPage = 1; // Reset to first page

        // Re-render topics
        renderTopics();
    });
});

}

// Update interface translations based on current language
function updateInterfaceTranslations() {
const lang = state.currentLang;

// Update category titles
document.querySelectorAll('[data-i18n]').forEach(el => {
    const key = el.getAttribute('data-i18n');
    if (translations[lang] && translations[lang][key]) {
        el.textContent = translations[lang][key];
    }
});

// Update narrator filter label
const narratorLabel = document.querySelector('.narrator-filter-label');
if (narratorLabel) {
    narratorLabel.textContent = translations[lang]['narrator-filter'] || 'Filter by Narrator';
}

// Update search placeholder
const searchInput = document.getElementById('search-input');
if (searchInput) {
    if (lang === 'ar') {
        searchInput.placeholder = 'ابحث عن المواضيع أو الرواة أو الفئات...';
    } else if (lang === 'ur') {
        searchInput.placeholder = 'موضوعات، راویوں، یا زمرہ جات تلاش کریں...';
    } else if (lang === 'bn') {
        searchInput.placeholder = 'বিষয়, বর্ণনাকারী, বা বিভাগ অনুসন্ধান করুন...';
    } else {
        searchInput.placeholder = 'Search topics, narrators, or categories...';
    }
}

}

// Display error message to user
function showError(message) {
// Create error element
const errorElement = document.createElement(‘div’);
errorElement.className = ‘error-message’;
errorElement.innerHTML = <i class="fas fa-exclamation-circle"></i> ${message};

// Find a good place to show the error
const container = document.querySelector('.topics-container') || document.body;
container.prepend(errorElement);

// Auto-remove after 5 seconds
setTimeout(() => {
    if (errorElement.parentNode) {
        errorElement.parentNode.removeChild(errorElement);
    }
}, 5000);

}

// Helper function to update alphabet filter UI
function updateAlphabetFilterUI() {
const alphabetButtons = document.querySelectorAll(‘.alphabet-btn’);
alphabetButtons.forEach(btn => {
btn.classList.toggle(‘active’, btn.getAttribute(‘data-letter’) === state.currentLetter);
});
}

// Initialize the app
function initApp() {
console.log(‘Initializing application’);

try {
    // Generate hadith cards
    renderTopics();

    // Setup event listeners
    setupEventListeners();

    // Initialize filters
    setupCollectionsFilter();

    // Load user preferences (language, theme, etc.)
    loadUserPreferences();

    // Update interface translations based on current language
    updateInterfaceTranslations();

    // Add any dynamic styles
    addDynamicStyles();

    // For masonry layout
    window.addEventListener('resize', debounce(() => {
        if (state.currentView === 'masonry') {
            initMasonryLayout();
        }
    }, 200));

    // Initialize new UI enhancements
    setupHeroAnimations();
    setupTopicInfoSection();

    console.log('App initialization successful');
} catch (error) {
    console.error('Error initializing app:', error);
    showError('Failed to initialize the application. Please refresh the page.');
}

}

// Add CSS styles for modal and animations
function addDynamicStyles() {
const styleElement = document.createElement(‘style’);
styleElement.textContent = `
/* Animation for cards */
.fade-in {
animation: fadeIn 0.5s ease-in-out;
}

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* Hover effects for cards */
    .topic-card {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }

    .topic-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    }

    .topic-card:before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 4px;
        height: 100%;
        background-color: var(--primary-color);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .topic-card:hover:before {
        opacity: 1;
    }

    /* Modal styles */
    .hadith-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.7);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .hadith-modal.show {
        opacity: 1;
        visibility: visible;
    }

    .hadith-modal-content {
        background-color: var(--card-bg);
        color: var(--text-color);
        border-radius: 12px;
        padding: 30px;
        max-width: 800px;
        width: 90%;
        max-height: 80vh;
        overflow-y: auto;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
        transform: scale(0.9);
        transition: transform 0.3s ease;
    }

    .hadith-modal.show .hadith-modal-content {
        transform: scale(1);
    }

    .close-modal {
        float: right;
        font-size: 28px;
        font-weight: bold;
        cursor: pointer;
        color: var(--text-color);
    }

    .hadith-modal-header {
        margin-bottom: 20px;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 10px;
    }

    .hadith-modal-header h3 {
        margin-top: 0;
        color: var(--primary-color);
    }

    .hadith-modal-meta {
        display: flex;
        gap: 15px;
        font-size: 0.9rem;
        color: var(--text-muted);
    }

    .hadith-modal-body {
        position: relative;
        padding: 20px;
        font-size: 1.1rem;
        line-height: 1.6;
    }

    .hadith-modal-body .quote-icon {
        position: absolute;
        top: 0;
        left: 0;
        font-size: 2rem;
        color: var(--primary-color);
        opacity: 0.2;
    }

    .hadith-modal-body p {
        font-size: 1.2rem;
        line-height: 1.8;
        margin-top: 15px;
        padding: 0 10px;
    }

    .hadith-category-tag {
        display: inline-block;
        background-color: var(--primary-color);
        color: white;
        padding: 5px 12px;
        border-radius: 20px;
        font-size: 0.85rem;
        margin-bottom: 12px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }

    /* Search improvements */
    .search-container {
        position: relative;
    }

    .clear-search-btn {
        position: absolute;
        right: 50px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 0;
        font-size: 16px;
        display: none;
        z-index: 5;
    }

    .clear-search-btn:hover {
        color: var(--primary-color);
    }

    [dir="rtl"] .clear-search-btn {
        right: auto;
        left: 50px;
    }

    /* Pagination improvements */
    .pagination {
        margin-top: 30px;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 10px;
    }

    .pagination-btn {
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        color: var(--text-color);
        padding: 8px 15px;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .pagination-btn:hover:not(:disabled) {
        background-color: var(--primary-color);
        color: white;
    }

    .pagination-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .page-numbers {
        display: flex;
        gap: 5px;
    }

    .page-number {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 35px;
        height: 35px;
        border-radius: 50%;
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .page-number:hover {
        background-color: var(--primary-hover);
        color: white;
    }

    .page-number.active {
        background-color: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }

    /* RTL adjustments for modal */
    [dir="rtl"] .hadith-modal-body .quote-icon {
        left: auto;
        right: 0;
    }

    [dir="rtl"] .close-modal {
        float: left;
    }

    /* Error handling styles */
    .error-message {
        background-color: #ffebee;
        color: #c62828;
        padding: 10px 15px;
        border-radius: 4px;
        margin: 10px 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .error-message i {
        font-size: 20px;
    }

    /* Dark theme adjustments */
    [data-theme="dark"] .error-message {
        background-color: #4a0f0f;
        color: #ffcdd2;
    }

    /* Add modal styles */
    .modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(5px);
        z-index: 1000;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 20px;
        overflow-y: auto;
    }

    .modal-content {
        background-color: var(--card-bg);
        border-radius: var(--radius);
        max-width: 800px;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
        position: relative;
        box-shadow: var(--shadow-lg);
        animation: modalFadeIn 0.3s ease-out;
    }

    .modal-close {
        position: absolute;
        top: 15px;
        right: 15px;
        background: none;
        border: none;
        color: var(--text-color);
        font-size: 1.2rem;
        cursor: pointer;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: all 0.2s;
        z-index: 2;
    }

    .modal-close:hover {
        background-color: rgba(0, 0, 0, 0.1);
        transform: rotate(90deg);
    }

    .modal-header {
        padding: 1.5rem;
        border-bottom: 1px solid var(--border-color);
        position: relative;
    }

    .modal-header::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 100px;
        height: 3px;
        background: var(--gradient-primary);
        border-radius: 3px;
    }

    .modal-header h2 {
        font-family: var(--font-primary);
        font-size: 1.5rem;
        margin: 0;
        color: var(--text-color);
    }

    .modal-body {
        padding: 1.5rem;
    }

    .topic-info-modal h3 {
        font-family: var(--font-primary);
        color: var(--primary-dark);
        margin-top: 1.5rem;
        font-size: 1.2rem;
    }

    .topic-info-modal p {
        margin-bottom: 1rem;
        line-height: 1.6;
    }

    .topic-info-modal ul {
        padding-left: 1.5rem;
        margin-bottom: 1rem;
    }

    .topic-info-modal li {
        margin-bottom: 0.5rem;
        line-height: 1.6;
    }

    .topic-info-modal strong {
        color: var(--primary-dark);
    }

    @keyframes modalFadeIn {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Add transitions to hero quote */
    .hero-quote {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
`;
document.head.appendChild(styleElement);

}

// Debounce function to limit how often a function can be called
function debounce(func, wait) {
let timeout;
return function(…args) {
const context = this;
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(context, args), wait);
};
}

// Run initialization when DOM is loaded
document.addEventListener(‘DOMContentLoaded’, function() {
console.log(‘DOM loaded, starting initialization…’);
addDynamicStyles();
initApp();
});

function initAdvancedFilters() {
console.log(‘Initializing advanced filters…’);

// Get elements
const advancedFilterToggle = document.querySelector('.advanced-filter-toggle');
const advancedFilters = document.querySelector('.advanced-filters');

// If toggle exists, add functionality
if (advancedFilterToggle && advancedFilters) {
    // Initially hide advanced filters
    advancedFilters.classList.remove('open');
    advancedFilterToggle.classList.remove('open');

    // Add click handler
    advancedFilterToggle.addEventListener('click', function() {
        state.advancedFiltersOpen = !state.advancedFiltersOpen;

        if (state.advancedFiltersOpen) {
            advancedFilters.classList.add('open');
            advancedFilterToggle.classList.add('open');
        } else {
            advancedFilters.classList.remove('open');
            advancedFilterToggle.classList.remove('open');
        }
    });
}

}

// Function to render a single hadith card
function renderHadithCard(hadith) {
// Determine text field based on current language
let textField;
if (state.currentLang === ‘ar’) {
textField = ‘textAr’;
} else if (state.currentLang === ‘ur’) {
textField = ‘textUr’;
} else if (state.currentLang === ‘bn’) {
textField = ‘textBn’;
} else {
textField = ‘text’;
}

// Create card element
const card = document.createElement('div');
card.className = 'topic-card hadith-card';
card.setAttribute('data-category', hadith.category);
card.setAttribute('data-narrator', hadith.narrator);
card.setAttribute('data-id', hadith.id);

// Category indicator
const category = document.createElement('div');
category.className = 'topic-category';
category.setAttribute('data-category', hadith.category);
card.appendChild(category);

// Hadith content
const content = document.createElement('div');
content.className = 'hadith-content';
content.setAttribute('data-hadith-number', hadith.id.toString().padStart(2, '0'));

// Hadith text container
const textContainer = document.createElement('div');
textContainer.className = 'hadith-text-container';

// Hadith text content
const textContent = document.createElement('p');
textContent.className = 'hadith-text-content';
textContent.innerHTML = hadith[textField];

textContainer.appendChild(textContent);
content.appendChild(textContainer);

// Metadata section
const meta = document.createElement('div');
meta.className = 'topic-meta';

// Narrator
const narrator = document.createElement('div');
narrator.className = 'topic-narrator';
narrator.innerHTML = `<i class="fas fa-user"></i> ${hadith.narrator}`;
meta.appendChild(narrator);

// Source
const source = document.createElement('div');
source.className = 'hadith-source';
source.innerHTML = `<i class="fas fa-book"></i> ${hadith.source}`;
meta.appendChild(source);

// Reference (if available)
if (hadith.reference) {
    const reference = document.createElement('div');
    reference.className = 'hadith-reference';
    reference.innerHTML = `<i class="fas fa-bookmark"></i> ${hadith.reference}`;
    meta.appendChild(reference);
}

// Read more link
const link = document.createElement('a');
link.className = 'topic-link';
link.href = '#';
link.setAttribute('data-id', hadith.id);
link.innerHTML = `${translations[state.currentLang]['read-more'] || 'Read More'} <i class="fas fa-arrow-right"></i>`;
link.addEventListener('click', function(e) {
    e.preventDefault();
    showHadithModal(hadith.id);
});
meta.appendChild(link);

// Add metadata to content
card.appendChild(content);
card.appendChild(meta);

return card;

}

// Setup collections filter
function setupCollectionsFilter() {
const collectionItems = document.querySelectorAll(‘.collection-item’);
collectionItems.forEach(item => {
item.addEventListener(‘click’, () => {
// Toggle active class
collectionItems.forEach(i => i.classList.remove(‘active’));
item.classList.add(‘active’);

        // Get collection name
        const collectionName = item.querySelector('span').textContent.trim();

        // Update state
        state.collection = collectionName;
        state.currentPage = 1; // Reset to first page

        // Re-render topics
        renderTopics();
    });
});

}

function setupHeroAnimations() {
// Animate hero section patterns on scroll
window.addEventListener(‘scroll’, function() {
const heroSection = document.querySelector(‘.hero-section’);
if (!heroSection) return;

    const scrollPosition = window.scrollY;
    const heroRect = heroSection.getBoundingClientRect();

    // Only animate when hero section is visible
    if (heroRect.bottom > 0 && heroRect.top < window.innerHeight) {
        const decorationCircle = document.querySelector('.decoration-circle');
        const decorationPattern = document.querySelector('.decoration-pattern');
        const decorationStars = document.querySelector('.decoration-stars');
        const decorationIslamic = document.querySelector('.decoration-islamic-pattern');

        // Parallax effect for decorations
        if (decorationCircle) {
            decorationCircle.style.transform = `translate(${scrollPosition * 0.03}px, ${scrollPosition * 0.02}px)`;
        }

        if (decorationPattern) {
            decorationPattern.style.backgroundPosition = `${scrollPosition * 0.01}px ${scrollPosition * 0.01}px`;
        }

        if (decorationStars) {
            decorationStars.style.transform = `translateY(${scrollPosition * 0.02}px)`;
        }

        if (decorationIslamic) {
            decorationIslamic.style.transform = `rotate(${5 + scrollPosition * 0.01}deg)`;
        }
    }
});

// Add subtle animation to the hero quote
const heroQuote = document.querySelector('.hero-quote');
if (heroQuote) {
    heroQuote.addEventListener('mouseenter', function() {
        heroQuote.style.transform = 'translateY(-5px)';
        heroQuote.style.boxShadow = '0 8px 20px rgba(0, 0, 0, 0.15)';
    });

    heroQuote.addEventListener('mouseleave', function() {
        heroQuote.style.transform = 'translateY(0)';
        heroQuote.style.boxShadow = '0 5px 15px rgba(0, 0, 0, 0.1)';
    });
}

}

function setupTopicInfoSection() {
// Handle learn more button click in About This Topic section
const learnMoreBtn = document.querySelector(‘.topic-info-section .learn-more-btn’);
if (learnMoreBtn) {
learnMoreBtn.addEventListener(‘click’, function() {
// Show a modal with more information about Ikhlas
showTopicInfoModal();
});
}

// Handle related concept tags
const relatedConceptTags = document.querySelectorAll('.related-concept-tag');
relatedConceptTags.forEach(tag => {
    tag.addEventListener('click', function() {
        const conceptName = this.textContent.trim();
        showRelatedConceptInfo(conceptName);
    });
});

// Animate stats numbers on scroll
const statsSection = document.querySelector('.topic-detail-stats');
if (statsSection) {
    // Initial state - hide the real numbers and show zeros
    const statNumbers = statsSection.querySelectorAll('.stat-number');
    const originalValues = [];

    statNumbers.forEach((stat, index) => {
        originalValues[index] = parseInt(stat.textContent);
        stat.setAttribute('data-value', originalValues[index]);
        stat.textContent = '0';
    });

    // Function to check if element is in viewport
    function isInViewport(element) {
        const rect = element.getBoundingClientRect();
        return (
            rect.top >= 0 &&
            rect.left >= 0 &&
            rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
            rect.right <= (window.innerWidth || document.documentElement.clientWidth)
        );
    }

    // Function to animate the counter
    function animateCounter(element, targetValue) {
        let currentValue = 0;
        const duration = 1500; // Animation duration in ms
        const increment = targetValue / (duration / 16); // Update every 16ms (60fps)

        function updateCounter() {
            currentValue += increment;
            if (currentValue >= targetValue) {
                element.textContent = targetValue;
            } else {
                element.textContent = Math.floor(currentValue);
                requestAnimationFrame(updateCounter);
            }
        }

        updateCounter();
    }

    // Check if stats are visible and animate them
    let hasAnimated = false;
    window.addEventListener('scroll', function() {
        if (!hasAnimated && isInViewport(statsSection)) {
            hasAnimated = true;
            statNumbers.forEach(stat => {
                const targetValue = parseInt(stat.getAttribute('data-value'));
                animateCounter(stat, targetValue);
            });
        }
    });

    // Also check once on page load in case stats are already visible
    setTimeout(() => {
        if (!hasAnimated && isInViewport(statsSection)) {
            hasAnimated = true;
            statNumbers.forEach(stat => {
                const targetValue = parseInt(stat.getAttribute('data-value'));
                animateCounter(stat, targetValue);
            });
        }
    }, 500);
}

}

function showTopicInfoModal() {
// Create modal element
const modal = document.createElement(‘div’);
modal.className = ‘modal-overlay’;
modal.innerHTML = `

Understanding Sincerity (Ikhlas) in Islam

Ikhlas (الإخلاص) in Arabic means “sincerity” or “purity of intention.” It is one of the most important principles in Islamic faith and practice.

            <h3>Key Aspects of Ikhlas:</h3>
            <ul>
                <li><strong>Definition:</strong> Performing acts of worship and good deeds solely for the sake of Allah, without any worldly motives or desire for recognition from others.</li>
                <li><strong>Mentioned in Quran:</strong> "And they were not commanded except to worship Allah, [being] sincere to Him in religion." (Quran 98:5)</li>
                <li><strong>Hadith Emphasis:</strong> The Prophet Muhammad ﷺ stressed the importance of sincerity in numerous hadiths, most famously: "Actions are judged by intentions, and each person will be rewarded according to their intentions."</li>
            </ul>

            <h3>Importance in Faith:</h3>
            <p>Ikhlas is considered essential for any deed to be accepted by Allah. A sincere action, even if small, is better than many actions done without sincerity. It purifies the heart and protects against showing off (riya') or seeking fame.</p>

            <h3>Signs of Sincerity:</h3>
            <ul>
                <li>Being equal in doing good whether in public or private</li>
                <li>Not seeking praise from others for good deeds</li>
                <li>Accepting both criticism and praise with equanimity</li>
                <li>Focusing on perfecting the action rather than on its outcomes</li>
            </ul>

            <p>This collection brings together authentic hadiths that explain, exemplify, and emphasize this crucial concept in Islam.</p>
        </div>
    </div>
`;

document.body.appendChild(modal);

// Prevent scrolling when modal is open
document.body.style.overflow = 'hidden';

// Close modal when clicking close button or outside the modal
const closeBtn = modal.querySelector('.modal-close');
closeBtn.addEventListener('click', function() {
    document.body.removeChild(modal);
    document.body.style.overflow = '';
});

modal.addEventListener('click', function(e) {
    if (e.target === modal) {
        document.body.removeChild(modal);
        document.body.style.overflow = '';
    }
});

}

function showRelatedConceptInfo(conceptName) {
let conceptInfo = {
title: conceptName,
description: ”,
quranReference: ”,
hadithReference: ”
};

// Set specific information based on the concept
switch(conceptName) {
    case 'Taqwa':
        conceptInfo.description = 'Taqwa refers to the consciousness of God and the fear of displeasing Him. It is often translated as "God-consciousness" or "piety."';
        conceptInfo.quranReference = '"O you who believe! Fear Allah (have Taqwa) as He should be feared and die not except in a state of Islam." (Quran 3:102)';
        conceptInfo.hadithReference = 'The Prophet ﷺ said: "The most common thing which leads people to Paradise is Taqwa of Allah and good conduct." (Tirmidhi)';
        break;
    case 'Ihsan':
        conceptInfo.description = 'Ihsan represents the highest level of faith and refers to worshipping Allah as if you see Him, knowing that even if you cannot see Him, He sees you.';
        conceptInfo.quranReference = '"Indeed, Allah is with those who fear Him and those who are doers of good (Muhsinun)." (Quran 16:128)';
        conceptInfo.hadithReference = 'When asked about Ihsan, the Prophet ﷺ replied: "It is to worship Allah as though you see Him, and though you cannot see Him, you know that He sees you." (Bukhari)';
        break;
    case 'Niyyah':
        conceptInfo.description = 'Niyyah means intention, and refers to the purpose or motive behind an action. In Islam, the intention transforms mundane actions into acts of worship.';
        conceptInfo.quranReference = '"And they were not commanded except to worship Allah, [being] sincere to Him in religion." (Quran 98:5)';
        conceptInfo.hadithReference = 'The Prophet ﷺ said: "Actions are judged by intentions, and each person will be rewarded according to their intentions." (Bukhari)';
        break;
    default:
        conceptInfo.description = 'This is an important concept in Islamic theology related to faith and practice.';
}

// Create modal element
const modal = document.createElement('div');
modal.className = 'modal-overlay';
modal.innerHTML = `
    <div class="modal-content topic-info-modal">
        <button class="modal-close"><i class="fas fa-times"></i></button>
        <div class="modal-header">
            <h2>${conceptInfo.title}</h2>
        </div>
        <div class="modal-body">
            <p>${conceptInfo.description}</p>

            <h3>In the Quran:</h3>
            <blockquote class="concept-quote">${conceptInfo.quranReference}</blockquote>

            <h3>In Hadith:</h3>
            <blockquote class="concept-quote">${conceptInfo.hadithReference}</blockquote>

            <div class="concept-relation">
                <h3>Relation to Ikhlas:</h3>
                <p>Both ${conceptInfo.title} and Ikhlas (sincerity) are essential qualities that complement each other in the pursuit of spiritual excellence in Islam.</p>
            </div>
        </div>
    </div>
`;

document.body.appendChild(modal);

// Prevent scrolling when modal is open
document.body.style.overflow = 'hidden';

// Close modal when clicking close button or outside the modal
const closeBtn = modal.querySelector('.modal-close');
closeBtn.addEventListener('click', function() {
    document.body.removeChild(modal);
    document.body.style.overflow = '';
});

modal.addEventListener('click', function(e) {
    if (e.target === modal) {
        document.body.removeChild(modal);
        document.body.style.overflow = '';
    }
});

}

Hassan Narrators: `Abdullah ibn `Abbas(RA) Topics: salat

hadith 432

Book: Revelation

Narated By Abu Huraira : Allah’s Apostle said, “The first group of people who will enter Paradise, will be glittering like the full moon and those who will follow them, will glitter like the most brilliant star in the sky. They will not urinate, relieve nature, spit, or have any nasal secretions. Their combs will be of gold, and their sweat will smell like musk. The aloes-wood will be used in their centers. Their wives will be houris. All of them will look alike and will resemble their father Adam (in statute), sixty cubits tall.”

hadith 1

Book: Sahih Al-Bukhari

sample

The Messenger of Allah ﷺ said: “Verily, Allah does not look at your appearance or wealth, but rather He looks at your hearts and your deeds.”

Sahih Narrators: Abu Hurairah(RA), Sahaba Topics: Importance Of Faith (Iman)