/**
 * Summer Fashion Store Theme - Main JavaScript
 * Handles theme interactive functionality
 */
// jQuery(document).ready(function ($) {

//   // Slider
//   $('.slider.owl-carousel').owlCarousel({
//       nav: true,
//       autoplay: true,
//       margin: 20,
//       lazyLoad: true,
//       autoplayTimeout: 2000,
//       loop: true,
//       dots: false,
//       navText: ["<span class='dashicons dashicons-arrow-left-alt'></span>", "<span class='dashicons dashicons-arrow-right-alt'></span>"],
//       responsive: {
//         0: { items: 1 },
//         768: { items: 1 },
//         992: { items: 1 },
//         1200: { items: 1 }
//       },
//       autoplayHoverPause: true,
//       mouseDrag: true
//   });


//   // Category
//   $('.category.owl-carousel').owlCarousel({
//       nav: false,
//       autoplay: true,
//       margin: 20,
//       lazyLoad: true,
//       autoplayTimeout: 1500,
//       loop: true,
//       dots: false,
//       responsive: {
//         0: { items: 1 },
//         768: { items: 3 },
//         992: { items: 3.5 },
//         1200: { items: 4.5 }
//       },
//       autoplayHoverPause: true,
//       mouseDrag: true
//   });


// });

jQuery('document').ready(function($) {
  var $sidebar = $(".sidebar");
  var $toggleBtn = $(".toggle-btn-main");
  var $crossBtn = $(".cross-btn-main");

  // Toggle button click
  $toggleBtn.on("click", function() {
    if ($sidebar.hasClass("is-hidden")) {
      // Show sidebar
      $sidebar
        .removeClass("is-hidden")
        .attr({
          "aria-hidden": "false",
          "tabindex": "-1"
        })
        .focus();

      $toggleBtn
        .removeClass("dashiconss-menu")
        .addClass("dashiconss-no-alt")
        .attr("aria-expanded", "true");
    } else {
      // Hide sidebar
      $sidebar
        .addClass("is-hidden")
        .attr("aria-hidden", "true");

      $toggleBtn
        .removeClass("dashiconss-no-alt")
        .addClass("dashiconss-menu")
        .attr("aria-expanded", "false")
        .trigger("focus"); // explicitly return focus
    }
  });

  // Cross button click → hide safely
  $crossBtn.on("click", function(e) {
    e.preventDefault(); // prevent unwanted focus loss
    e.stopPropagation();

    $sidebar
      .addClass("is-hidden")
      .attr("aria-hidden", "true");

    // Return focus *asynchronously* to avoid Chrome accessibility reset
    setTimeout(function() {
      $toggleBtn
        .removeClass("dashiconss-no-alt")
        .addClass("dashiconss-menu")
        .attr("aria-expanded", "false")
        .trigger("focus");
    }, 50);
  });


  var owl = jQuery('.slider-main.owl-carousel');
    owl.owlCarousel({
    margin: 20,
    nav: true,
    navText: ["<span class='dashicons dashicons-arrow-left-alt'></span>", "<span class='dashicons dashicons-arrow-right-alt'></span>"],
    autoplay: true,
    autoplayTimeout: 3000,
    lazyLoad: true,
    loop: true,
    dots: false,
    responsive: {
      0: {
        items: 1
      },
      600: {
        items: 1
      },
      1000: {
        items: 1
      }
    },
    mouseDrag: true
  });


  var owl = jQuery('.gallery-section.owl-carousel');
    owl.owlCarousel({
    margin: 20,
    nav: false,
    navText: ["<span class='dashicons dashicons-arrow-left-alt'></span>", "<span class='dashicons dashicons-arrow-right-alt'></span>"],
    autoplay: true,
    autoplayTimeout: 3000,
    lazyLoad: true,
    loop: true,
    dots: false,
    responsive: {
      0: {
        items: 1
      },
      600: {
        items: 2
      },
      1000: {
        items: 4
      }
    },
    mouseDrag: true
  });
});