$color-dropdown-hover: rgba(0, 0, 0, .05);
$color-bookmarker--hover: #AAA;
$color-bookmarker: #DDD;

.dropdown {
  position: relative;
  .co-m-resource-icon {
    margin-left: 2px;
  }
}

.dropdown--full-width {
  & > .btn-dropdown,
  & > .dropdown-menu {
    width: 100%;
  }
}

.dropdown__disabled {
  color: $dropdown-link-disabled-color;
  cursor: not-allowed;
}

.dropdown-menu__divider {
  height: 1px;
  margin: 9px 0;
  overflow: hidden;
  flex-grow: 1;
  background-color: $color-pf-black-200;
}

.dropdown-menu__header {
  color: $color-pf-black-600;
  flex-grow: 1;
  font-size: ($font-size-base - 1);
  padding: 3px 10px;
  text-transform: uppercase;
}

.dropdown-menu__filter {
  padding: 5px 10px 10px;
}

.dropdown-menu--right {
  left: auto;
  right: 0;
}

.dropdown-menu--text-wrap {
  max-width: 100%;
  li a {
    min-width: 0;
    overflow-wrap: break-word;
    white-space: normal;
    word-wrap: break-word;
  }
}

.dropdown--text-filter {
  float: none !important;
}

.favorite {
  color: gold;
}

.dropdown-menu {
  &--block {
    display: block;
  }

  ul {
    padding: 0;
    margin: 0;
    list-style: none;
  }

  li {
    padding: 0;
    display: flex;
    &:focus {
      outline: none;
    }
    a {
      cursor: pointer;
      flex-grow: 1;
      width: 100%;
      &.next-to-bookmark {
        padding-left: 5px
      }
      &.hover {
        background-color: $dropdown-link-hover-bg;
        border-top: 1px solid #bee1f4;
        border-bottom: 1px solid #bee1f4;
        color: $dropdown-link-hover-color;
        position: relative;
        &:after,
        &:before {
          height: 1px;
        }
      }
      &.focus {
        color: white;
      }
    }
  }
}

.dropdown--dark {
  $dark: rgba(33, 33, 33, 1);
  background-color: $dark;
  border: solid 1px $dark;

  li {
    .dropdown-menu__divider {
      background-color: $color-pf-black-900;
    }

    > a {
    color: white;

    &:hover {
      background-color: rgba(255, 255, 255, 0.15);
      color: white;
    }
  }
}
}

.co-add-actions-selector__icon {
  margin: 0 5px 0 0;
}

.co-namespace-bar {
  border-bottom: 1px solid $color-grey-background-border;
  padding: 0 15px;
  white-space: nowrap;

  @media (min-width: $grid-float-breakpoint) {
    padding-left: 30px;
    padding-right: 30px;
  }

  &__dropdowns {
    display: flex;
    justify-content: space-between;

    .btn-link {
      color: inherit;
      padding: 4px 0 2px !important;

      @media(min-width: $grid-float-breakpoint) {
        padding-bottom: 10px !important;
        padding-top: 11px !important;
      }

      &:hover,
      &:focus {
        text-decoration: none;
      }
    }
  }
}

.co-namespace-selector {
  max-width: 75%;

  .btn-link {
    font-size: ($font-size-base + 1);
    padding: 2px 0 !important;

    @media (min-width: $grid-float-breakpoint) {
      font-size: ($font-size-base + 2);
      padding-bottom: 9px !important;
      padding-top: 9px !important;
    }

    &__titlePrefix {
      margin-right: 6px;
    }
  }
}

.co-namespace-selector__menu.dropdown-menu {
  max-height: 60vh;
  max-width: 100%;
  min-width: 210px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  @media (min-width: $grid-float-breakpoint) {
    min-width: 250px;
  }

  a {
    white-space: nowrap;
    width: auto;
  }

  .dropdown__selected {
    background-color: inherit;
    color: inherit;
  }
  // Mimic PatternFly dropdown-menu visual states.
  // Since namespace selector has multiple <a> tags within each list item,
  // target the <li> except the one containing the list divider.
  li {
    &:not(.co-namespace-selector__divider) {
      &:after,
      &:before {
        content: '';
        background-color: $dropdown-link-hover-border-color;
        left: 0;
        position: absolute;
        width: 100%;
      }
      &:after {
        top: 0;
      }
      &:before {
        bottom: 0;
      }
      &:hover {
        background-color: $dropdown-link-hover-bg;
        color: $dropdown-link-hover-color;
        position: relative;
        &:after,
        &:before {
          height: 1px;
        }
      }
      &.active:hover:after,
      &.active:hover:before {
        height: 0;
      }
    }
    > a {
      padding: 6px;
      text-decoration: none;
      &.active {
        border-color: transparent;
      }
      &:active {
        background-color: transparent;
        color: inherit !important;
      }
      &.bookmarker {
        display: inline-block;
        padding-right: 5px;
        padding-left: 12px;
        color: $color-bookmarker;
        flex-grow: 0;
        &:hover {
          background-color: transparent;
          color: $color-bookmarker--hover;
        }
        &:focus {
          background-color: transparent;
          border-color: transparent;
        }
      }
      &.next-to-bookmark {
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
}

.btn-dropdown {
  max-width: 100%;
  .caret {
    flex: 0 0 auto;
    margin-left: 5px;
  }
}

.btn-dropdown__item {
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  .co-resource-item__resource-name {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.btn-dropdown__item--placeholder {
  color: $color-pf-black-500;
  font-style: italic;
}

.btn-dropdown__content-wrap {
  align-items: baseline;
  display: flex;
  flex: 1 1 auto;
  justify-content: space-between;
  min-width: 0;
}

.btn--actions {
  margin-top: -1px;
}
