/**
* Template Name: KnightOne
* Template URL: https://bootstrapmade.com/knight-simple-one-page-bootstrap-template/
* Updated: Oct 16 2024 with Bootstrap v5.3.3
* Author: BootstrapMade.com
* License: https://bootstrapmade.com/license/
*/

(function() {
  "use strict";

 
	var swiper = new Swiper(".extswiper", {
    loop: true,                // continuous loop
    speed: 1900,                // smooth transition speed (ms)
    autoplay: {
        delay: 3000,           // time between slides
        disableOnInteraction: false,
    },
    navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev",
    },
});
 
 
 
	var currentStep = 1;
var totalSteps = 4; // 👈 now using 4 steps
var updateProgressBar;

function displayStep(stepNumber) {
  if (stepNumber >= 1 && stepNumber <= totalSteps) {
    $(".step-" + currentStep).hide();
    $(".step-" + stepNumber).show();
    currentStep = stepNumber;
    updateProgressBar();
  }
}

$(document).ready(function () {
  // Hide all steps except the first
  $('#multi-step-form').find('.step').slice(1).hide();

  // Next button
  $(".next-step").click(function () {
    if (currentStep < totalSteps) {
      $(".step-" + currentStep).addClass("animate__animated animate__fadeOutLeft");
      currentStep++;
      setTimeout(function () {
        $(".step").removeClass("animate__animated animate__fadeOutLeft").hide();
        $(".step-" + currentStep).show().addClass("animate__animated animate__fadeInRight");
        updateProgressBar();
      }, 500);
    }
  });

  // Previous button
  $(".prev-step").click(function () {
    if (currentStep > 1) {
      $(".step-" + currentStep).addClass("animate__animated animate__fadeOutRight");
      currentStep--;
      setTimeout(function () {
        $(".step").removeClass("animate__animated animate__fadeOutRight").hide();
        $(".step-" + currentStep).show().addClass("animate__animated animate__fadeInLeft");
        updateProgressBar();
      }, 500);
    }
  });

  // Progress bar logic
  updateProgressBar = function () {
    // For 4 steps: 0%, 33.33%, 66.66%, 100%
    var progressPercentage = ((currentStep - 1) / (totalSteps - 1)) * 100;
    $(".progress-bar").css("width", progressPercentage + "%");
  }

  // Initial progress state
  updateProgressBar();
});

 
 $(document).ready(function () {
    $('a[href^="#"]').on('click', function (e) {
        e.preventDefault();

        var target = this.hash;
        var $target = $(target);

        // Adjust this offset based on your navbar height
        var offset = 80; 

        $('html, body').animate({
            scrollTop: $target.offset().top - offset
        }, 1600); // 600 = speed
    });
});
 

})();