jQuery(document).ready(function($) {
    $('.qcld-color-picker').wpColorPicker();

    // Trigger Help Modal
    $('#qcld-faq-help-modal-trigger').on('click', function(e) {
        e.preventDefault();
        $('#qcld-faq-help-modal-overlay').addClass('is-open');
    });

    // Close Help Modal
    $('#qcld-faq-help-modal-close, #qcld-faq-help-modal-overlay').on('click', function(e) {
        if (e.target === this || $(e.target).attr('id') === 'qcld-faq-help-modal-close' || $(e.target).parent().attr('id') === 'qcld-faq-help-modal-close') {
            $('#qcld-faq-help-modal-overlay').removeClass('is-open');
        }
    });

    // Prevent close when clicking container itself
    $('.qcld-faq-modal-container').on('click', function(e) {
        e.stopPropagation();
    });

    // Tab switcher inside modal
    $('.qcld-faq-modal-tab-btn').on('click', function() {
        var targetTab = $(this).data('target');
        
        $('.qcld-faq-modal-tab-btn').removeClass('is-active');
        $(this).addClass('is-active');
        
        $('.qcld-faq-modal-tab-content').removeClass('is-active');
        $('#' + targetTab).addClass('is-active');
    });
});
