/**
 * VMP Security Dashboard Widget JavaScript
 * @since 2.2.2
 */

jQuery(document).ready(function($) {
    'use strict';
    
    // Handle collapsible sections
    $('.vmpfence-widget-header').on('click', function() {
        var $section = $(this).closest('.vmpfence-widget-collapsible');
        $section.toggleClass('collapsed');
        
        // Save state to localStorage
        var sectionId = $(this).data('section');
        var isCollapsed = $section.hasClass('collapsed');
        localStorage.setItem('vmpfence_widget_' + sectionId, isCollapsed ? 'collapsed' : 'expanded');
    });
    
    // Restore collapsed state from localStorage
    $('.vmpfence-widget-header').each(function() {
        var sectionId = $(this).data('section');
        var state = localStorage.getItem('vmpfence_widget_' + sectionId);
        
        if (state === 'collapsed') {
            $(this).closest('.vmpfence-widget-collapsible').addClass('collapsed');
        }
    });
});
