/* Base menu styles (desktop) */
.sf-menu,
.sf-menu * {
  background: #fff;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sf-menu > li {
  float: left;
}

/* Only apply hover behavior on desktop */
@media screen and (min-width: 1161px) {
  .sf-menu li:hover > ul {
    display: block;
  }
}

.sf-menu ul ul {
  top: 0;
  left: 100%;
}

.sf-menu ul {
  position: absolute;
  display: none;
  top: 100%;
  left: 0;
  z-index: 99;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.2);
  min-width: 12em; /* allow long menu items to determine submenu width */
}

.sf-menu a {
  color: #000;
  display: block;
  position: relative;
  padding: 0.75rem;
  text-decoration: none;
}

.sf-menu li {
  position: relative;
  border-bottom: 2px solid transparent;
  white-space: nowrap; /* no need for Supersubs plugin */
}

.sf-menu li:hover {
  border-bottom: 2px solid #09f;
}

.sf-arrows .sf-with-ul {
  padding-right: 2.5em;
}

/* styling for both css and generated arrows */
.sf-arrows .sf-with-ul:after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1em;
  margin-top: -3px;
  height: 0;
  width: 0;
  /* order of following 3 rules important for fallbacks to work */
  border: 5px solid transparent;
  border-top-color: rgba(204, 204, 204, 0.5);
}

.sf-arrows > li > .sf-with-ul:focus:after,
.sf-arrows > li:hover > .sf-with-ul:after {
  border-top-color: #ccc;
}

/* styling for right-facing arrows */
.sf-arrows ul .sf-with-ul:after {
  margin-top: -5px;
  margin-right: -3px;
  border-color: transparent;
  border-left-color: rgba(204, 204, 204, 0.5);
}

.sf-arrows ul li > .sf-with-ul:focus:after,
.sf-arrows ul li:hover > .sf-with-ul:after {
  border-left-color: #ccc;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: none;
  cursor: pointer;
  padding: 10px;
  position: absolute;
  right: 15px;
  z-index: 1000;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: top 0.3s ease, right 0.3s ease;
}

.mobile-menu-toggle.active {
  position: fixed;
  top: 20px !important;
  right: 20px;
}

.mobile-menu-toggle span {
  display: block;
  width: 25px;
  height: 3px;
  margin-bottom: 5px;
  position: relative;
  background: #333;
  border-radius: 3px;
  transform-origin: center;
  transition: transform 0.3s ease-out;
}

.mobile-menu-toggle span:last-child {
  margin-bottom: 0;
}

/* Mobile menu toggle animation */
.mobile-menu-toggle.active span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Responsive styles for mobile devices */
@media screen and (max-width: 1200px) {
  .mobile-menu-toggle {
    display: block;
  }

  #main-navigation {
    position: fixed;
    top: 0;
    right: -350px; /* Start off-screen */
    width: 350px;
    height: 100vh;
    background: #fff;
    overflow-y: auto;
    transition: right 0.3s ease;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
    z-index: 999;
    padding-top: 0; /* Remove top padding */
  }

  /* Add a fixed header inside the menu */
  #main-navigation:before {
    content: "";
    display: block;
    height: 60px; /* Space for the toggle button */
    width: 100%;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
  }

  /* Adjust menu items to start below the fixed header */
  #main-navigation > li:first-child {
    margin-top: 60px;
  }

  #main-navigation.active {
    right: 0; /* Slide in */
  }

  #main-navigation > li {
    float: none;
    width: 100%;
    border-bottom: 2px solid #eee !important;
  }

  #main-navigation li:hover {
    border-color: transparent;
  }

  /* Keep submenus visible on hover for mobile */
  #main-navigation li:hover > ul.show-submenu {
    display: block !important;
  }

  #main-navigation ul {
    position: static !important;
    display: none;
    box-shadow: none !important;
    width: 100% !important;
    padding-left: 15px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: #eee; /* Light grey background for submenus */
    border-top: 2px solid transparent !important;
  }

  /* Don't hide submenus on hover if they were previously shown */
  #main-navigation li:hover > ul {
    display: none !important; /* Only hide if not already shown by JS */
  }

  #main-navigation ul.show-submenu {
    display: block !important;
    max-height: 1000px; /* Large enough to show all content */
    border-top: 2px solid #09f !important;
  }

  /* Fix for deeply nested submenus */
  #main-navigation ul {
    width: calc(
      100% - 15px
    ) !important; /* Adjust width to account for padding */
  }

  /* Ensure nested submenus don't get too narrow */
  #main-navigation ul ul {
    width: calc(100% - 15px) !important;
  }

  /* Ensure text doesn't get cut off by scrollbar */
  #main-navigation ul a {
    padding-right: 35px !important; /* Extra space for scrollbar */
    word-break: break-word; /* Allow long words to break */
  }

  /* Make menu items easier to tap */
  #main-navigation a {
    padding: 12px 15px !important;
    border-bottom: none !important;
  }

  /* Fix arrow display for mobile */
  .sf-arrows > li > .sf-with-ul:after {
    border-top-color: transparent !important;
    border-left-color: rgba(204, 204, 204, 0.5) !important;
    right: 25px;
    transition: transform 0.3s ease;
  }

  .sf-arrows > li > .sf-with-ul.submenu-open:after {
    transform: rotate(90deg);
    border-left-color: #09f !important;
  }

  /* Ensure submenu arrows display correctly */
  .sf-arrows ul .sf-with-ul:after {
    right: 25px;
    border-left-color: rgba(204, 204, 204, 0.5) !important;
    transition: transform 0.3s ease;
  }

  .sf-arrows ul .sf-with-ul.submenu-open:after {
    transform: rotate(90deg);
    border-left-color: #09f !important;
  }

  /* Add some body styles when menu is open */
  body.menu-open {
    overflow: hidden;
  }

  /* Ensure submenus don't overflow */
  #main-navigation li {
    position: relative !important;
  }

  /* Prevent text wrapping in menu items */
  #main-navigation a {
    white-space: normal !important;
  }

  /* Add overlay when menu is open */
  body.menu-open:before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }

  /* Ensure the toggle button stays above the menu */
  .mobile-menu-toggle.active {
    z-index: 1001;
  }
}

/* Simple dropdown menu styles - non-reactive */
.simple-dropdown {
  list-style: none;
  padding: 0;
  margin: 0;
  background: #fff;
}

.simple-dropdown li {
  position: relative;
  display: inline-block;
  margin-right: 10px;
  border-bottom: 2px solid transparent;
}

.simple-dropdown li:hover {
  border-bottom: 2px solid #09f;
}

.simple-dropdown li a {
  display: block;
  padding: 8px 15px;
  text-decoration: none;
  color: #000;
}

.simple-dropdown li a:hover {
  background-color: #f0f0f0;
}

.simple-dropdown ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  padding: 0;
  min-width: 200px;
  z-index: 1000;
  list-style: none;
}

.simple-dropdown ul ul {
  top: 0;
  left: 100%;
}

.simple-dropdown ul li {
  display: block;
  width: 100%;
  margin: 0;
  border-bottom: none;
}

.simple-dropdown ul li:hover {
  border-bottom: none;
}

.simple-dropdown ul li a {
  padding: 8px 15px;
  white-space: nowrap;
}

.simple-dropdown li.has-children > a {
  padding-right: 2.5em;
  position: relative;
}

.simple-dropdown li.has-children > a:after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1em;
  margin-top: -3px;
  height: 0;
  width: 0;
  border: 5px solid transparent;
  border-top-color: rgba(204, 204, 204, 0.5);
}

.simple-dropdown > li.has-children:hover > a:after {
  border-top-color: #ccc;
}

.simple-dropdown li li.has-children > a:after {
  margin-top: -5px;
  margin-right: -3px;
  border-color: transparent;
  border-left-color: rgba(204, 204, 204, 0.5);
}

.simple-dropdown li li.has-children:hover > a:after {
  border-left-color: #ccc;
}
