/**
 * Sifency Theme Builder Summary Dashboard Script
 * Handles toggle behavior for "View More" / "View Less" button in Theme Builder Summary.
 *
 * @package Sifency
 * @since 1.0.4
 */

(function () {
    'use strict';

    document.addEventListener('DOMContentLoaded', function () {
        const viewMoreBtn = document.getElementById('sifency-view-more-btn');
        const grid = document.getElementById('sifency-themebuilder-grid');

        if (viewMoreBtn && grid) {
            const viewMoreText = viewMoreBtn.getAttribute('data-view-more') || 'View More';
            const viewLessText = viewMoreBtn.getAttribute('data-view-less') || 'View Less';

            viewMoreBtn.addEventListener('click', function () {
                grid.classList.toggle('sifency-grid-expanded');

                // Change button text
                if (grid.classList.contains('sifency-grid-expanded')) {
                    this.textContent = viewLessText;
                } else {
                    this.textContent = viewMoreText;
                }
            });
        }
    });
})();
