document.addEventListener('DOMContentLoaded', function() {
    const faqQuestions = document.querySelectorAll('.faq-question');
    const faqAnswers = document.querySelectorAll('.faq-answer');
    
    // Initial alle Antworten schließen
    faqAnswers.forEach(answer => {
        answer.classList.remove('show');
    });
    
    faqQuestions.forEach(question => {
        question.addEventListener('click', function(e) {
            e.preventDefault();
            const answer = document.querySelector(this.getAttribute('data-bs-target'));
            const isExpanded = this.getAttribute('aria-expanded') === 'true';
            
            // Alle Fragen auf "nicht expandiert" setzen
            faqQuestions.forEach(q => {
                q.setAttribute('aria-expanded', 'false');
            });
            
            // Alle Antworten schließen
            faqAnswers.forEach(a => {
                a.classList.remove('show');
            });
            
            // Wenn die Frage nicht expandiert war, öffne sie
            if (!isExpanded) {
                answer.classList.add('show');
                this.setAttribute('aria-expanded', 'true');
            }
        });
    });
    
    // Tastaturnavigation
    faqQuestions.forEach(question => {
        question.addEventListener('keydown', function(e) {
            if (e.key === 'Enter' || e.key === ' ') {
                e.preventDefault();
                this.click();
            }
        });
    });
}); 