jQuery(document).ready(function($) {
  var toggle = $('#griffinforms-settings-general-enablenativelogging');
  if (!toggle.length) return; // safety

  // Rows to show/hide
  var rowTypes     = $('#griffinforms-settings-general-logmessagetypes').closest('tr');
  var rowRetention = $('#griffinforms-settings-general-logretention').closest('tr');

  function updateLoggingVisibility() {
    var enabled = toggle.is(':checked');
    if (enabled) {
      rowTypes.stop(true, true).fadeIn();
      rowRetention.stop(true, true).fadeIn();
    } else {
      rowTypes.stop(true, true).hide();
      rowRetention.stop(true, true).hide();
    }
  }

  // Initial state
  updateLoggingVisibility();

  // On change
  toggle.on('change', updateLoggingVisibility);
});