/* ── Main categories dropdown ── */

#pgpc-categories-menu {
  width: 260px !important;
  max-height: 80vh;
  overflow-y: auto;
  transform: none !important;
}

/* ── Nested dropend containers ── */

.dropdown-menu .dropend {
  position: relative;
}

/*
  Hide nested dropdowns by default.
  position:fixed escapes parent overflow clipping, but ONLY if
  no ancestor has a CSS transform (which creates a new containing block).
  transform:none !important prevents styles.css transitions from breaking this.
*/

.dropdown-menu .dropend > .dropdown-menu {
  display: none !important;
  position: fixed !important;
  transform: none !important;
  margin: 0 !important;
  min-width: 240px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 1055;
}

/* Show nested dropdown when it has the 'show' class */

.dropdown-menu .dropend > .dropdown-menu.show {
  display: block !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* For mobile/smaller screens, show nested dropdowns inline */

@media (max-width: 991.98px) {
  #pgpc-categories-menu {
    width: 100% !important;
  }

  .dropdown-menu .dropend > .dropdown-menu {
    position: static !important;
    margin-left: 1rem !important;
    width: 100%;
    max-height: none;
    overflow-y: visible;
    background-color: rgba(0, 0, 0, 0.5);
    border: none;
  }
}

/* Dropdown toggle arrow on the right */

.dropdown-menu .dropdown-toggle::after {
  margin-left: auto;
  float: right;
  border-top: 0.3em solid transparent;
  border-right: 0;
  border-bottom: 0.3em solid transparent;
  border-left: 0.3em solid;
}

/* Make the nested dropdown item clickable */

.dropdown-menu .dropend > .dropdown-toggle {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
