/* Extracted megamenu styles from header.blade.php */
.mega-horizontal {
  display: flex;
  flex-direction: row; /* ensure left/right are inline */
  gap: 20px;
  padding: 12px;
  max-width: 1000px;
  align-items: flex-start;
  /* limit overall megamenu height so it doesn't cover the entire screen */
  max-height: 48.8vh;
  /* allow horizontal overflow so right panels can scroll without pushing left away */
  overflow-x: visible;
  overflow-y: hidden;
  position: relative;
}

/* --- Overlay behavior: make megamenu sit on top of page content like a dropdown --- */
.megamenu.cat-megamenu {
  /* hide from the document flow so it doesn't push header content */
  position: absolute;
  /* place directly under the navbar (no gap) to avoid hover flicker */
  top: 76px;
  /* center and constrain the overlay so it doesn't span the whole viewport */
  left: 8% !important;
  transform: translateX(-50%);
  display: none; /* default hidden */
  background: #fff;
  z-index: 1200;
  padding: 6px;
  width: 100%;
  max-width: 1100px; /* keeps the megamenu readable */
  box-sizing: border-box;
  -moz-border-radius: 24px;
  -webkit-border-radius: 24px;
  border-radius: 24px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.16);
}

.mega-left {
  width: 240px;
  padding: 8px;
  -moz-border-radius: 18px;
  -webkit-border-radius: 18px;
  border-radius: 18px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.16);

  /* make the left column vertically scrollable so it fits within the megamenu */
  flex: 0 0 240px;
  min-width: 240px;
  max-height: calc(50vh - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 30;
  background: transparent;
}

.mega-left ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mega-left li {
  margin: 6px 0;
}
.mega-left a {
  display: block;
  padding: 8px 16px;
  color: #192237;
  text-decoration: none;
  -moz-border-radius: 24px;
  -webkit-border-radius: 24px;
  border-radius: 24px;
  font-size: 14px;
  line-height: 24px;
}
.mega-left a.active,
.mega-left a:hover {
  background: rgba(206, 8, 86, 0.05);
  color: #192237;
  -moz-border-radius: 24px;
  -webkit-border-radius: 24px;
  border-radius: 24px;
}

.mega-right {
  flex: 1 1 auto;
  display: flex;
  min-width: 0; /* allow flex child to shrink properly */
  position: relative;
  z-index: 10;
  align-items: flex-start; /* keep panels aligned to top */
  overflow: visible; /* frozen visually; left column handles scrolling */
  padding: 12px 12px 0 12px;
}

.mega-panel {
  display: none;
  align-items: flex-start;
  overflow: visible;
}

/* wrap on the right side: constrain height and allow horizontal scrolling only inside this wArapper */
.mega-scroll-wrap {
  max-height: calc(50vh - 24px);
  overflow-x: auto;
  overflow-y: hidden;
}

/* active panel shows columns horizontally; do not add vertical scroll to the panels themselves */
.mega-panel.active {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  min-width: 0; /* prevent content from forcing layout */
}

.mega-panel.scrollable {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
}

/* inner wrapper inside each panel that actually scrolls horizontally */
.mega-panel-inner {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  min-width: 0;
  max-height: calc(50vh - 24px);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.mega-panel-inner::-webkit-scrollbar {
  height: 10px;
}
.mega-panel-inner::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 6px;
}

.mobile-panel-back {
  display: none;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
  background: #fff;
  cursor: pointer;
}

/* scroll indicator buttons */
.mega-scroll-wrap {
  position: relative;
}
.mega-scroll-indicator {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 36px;
  border: 0;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  cursor: pointer;
  z-index: 60;
}
.mega-scroll-left {
  left: -12px;
}
.mega-scroll-right {
  right: -12px;
}

/* each column fixed width so horizontal scroll is predictable */
.mega-col {
  width: 220px;
  flex: 0 0 220px;
}
.mega-col h6 {
  margin-top: 0;
  font-size: 14px;
  font-weight: 600;
}
.mega-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mega-col li {
  margin: 6px 0;
}
.mega-col a {
  color: #333;
  text-decoration: none;
}

/* visible horizontal scrollbar styling (WebKit) */
.mega-panel.scrollable::-webkit-scrollbar {
  height: 10px;
}
.mega-panel.scrollable::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 6px;
}
.mega-panel.scrollable::-webkit-scrollbar-track {
  background: transparent;
}

/* when the parent menu item is hovered on desktop, show the overlay */
@media (min-width: 992px) {
  /* show overlay as flex on desktop so .mega-left and .mega-right stay side-by-side */
  .has-megamenu:hover > .megamenu.cat-megamenu {
    display: flex;
    flex-direction: row;
  }
  /* anchor the overlay to the header navbar container so centering works */
  .create-navbar {
    position: relative;
  }
}

/* small negative offset to overlap the navbar slightly and remove the gap that causes flicker */
@media (min-width: 992px) {
  .has-megamenu:hover > .megamenu.cat-megamenu,
  .has-megamenu.open > .megamenu.cat-megamenu {
    margin-top: -2px;
  }
}

/* when using JS (mobile/touch), an explicit .open class will show the overlay */
.has-megamenu.open > .megamenu.cat-megamenu {
  display: flex;
  flex-direction: row;
}

/* Small screens should still use a full-width stacked layout */
@media (max-width: 991px) {
  .megamenu.cat-megamenu {
    left: 0;
    transform: none;
    width: 100%;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
    padding: 8px 12px;
  }
  /* mobile/touch: opened state is stacked (block) */
  .has-megamenu.open > .megamenu.cat-megamenu {
    display: block;
  }
}

@media (max-width: 991px) {
  .mega-horizontal {
    display: block;
  }
  .mega-left {
    width: auto;
    border-right: none;
    padding-right: 0;
    max-height: none;
  }
  .mega-panel.active {
    display: block;
  }
  .mega-col {
    width: 100%;
    flex: 0 0 auto;
  }
  .mega-panel.scrollable {
    overflow-x: visible;
  }
  .mobile-panel-back {
    display: inline-block;
  }
  .mega-scroll-indicator {
    display: none !important;
  }
  /* keep the back button visible while panels scroll */
  .mega-panel .mobile-panel-back {
    position: sticky;
    top: 8px;
    z-index: 40;
  }
}
