/*
 * Copyright (c) 2016-2023 VMware, Inc. All Rights Reserved.
 * This software is released under MIT license.
 * The full license information can be found in LICENSE in the root directory of this project.
 */

@mixin generate-dropdown-menu() {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;

  //Dimensions
  min-width: $clr_baselineRem_5;
  max-width: $clr_baselineRem_15;

  //Other
  @include css-var(background, clr-dropdown-bg-color, $clr-dropdown-bg-color, $clr-use-custom-properties);
  @include css-var(border-width, clr-global-borderwidth, $clr-global-borderwidth, $clr-use-custom-properties);
  border-style: solid;
  @include css-var(border-color, clr-dropdown-border-color, $clr-dropdown-border-color, $clr-use-custom-properties);
  @include css-var(border-radius, clr-global-borderradius, $clr-global-borderradius, $clr-use-custom-properties);
  // OldIE/Edge
  box-shadow: 0 $clr-global-borderwidth $clr_baselineRem_0_125 $clr-dropdown-box-shadow;
  @if $clr-use-custom-properties == true {
    box-shadow: 0
      $clr-global-borderwidth
      $clr_baselineRem_0_125
      var(--clr-dropdown-box-shadow, $clr-dropdown-box-shadow);
  }
  margin-top: $clr_baselineRem_2px;
  padding: $clr_baselineRem_0_5 0;
  visibility: hidden;
  z-index: map-get($clr-layers, dropdown-menu);
}

@mixin generate-dropdown-item() {
  @include css-var(color, clr-dropdown-item-color, $clr-dropdown-item-color, $clr-use-custom-properties);
  font-size: $clr-dropdown-item-font-size;
  @include css-var(
    font-weight,
    clr-dropdown-item-font-weight,
    $clr-dropdown-item-font-weight,
    $clr-use-custom-properties
  );
  letter-spacing: $clr-dropdown-item-letter-spacing;

  background: transparent;
  border: 0;
  cursor: pointer;
  display: block;
  height: auto;
  line-height: inherit;
  margin: 0;
  width: 100%;
  text-transform: none;

  &:hover {
    @include css-var(
      background-color,
      clr-dropdown-bg-hover-color,
      $clr-dropdown-bg-hover-color,
      $clr-use-custom-properties
    );
    @include css-var(color, clr-dropdown-item-color, $clr-dropdown-item-color, $clr-use-custom-properties);
    text-decoration: none;
  }

  &.active {
    @include css-var(
      background,
      clr-dropdown-selection-color,
      $clr-dropdown-selection-color,
      $clr-use-custom-properties
    );
    @include css-var(
      color,
      clr-dropdown-active-text-color,
      $clr-dropdown-active-text-color,
      $clr-use-custom-properties
    );
  }

  &:active {
    box-shadow: none;
  }

  &:focus {
    z-index: inherit;
  }

  &.disabled,
  &:disabled {
    pointer-events: none;
    opacity: 0.4;
    user-select: none;

    &:hover {
      background: none;
    }

    &:active {
      background: none;
      box-shadow: none;
    }
  }
}

@mixin generate-dropdown-item-height() {
  padding: $clr_baselineRem_0_125 $clr_baselineRem_1;

  @media screen and (max-width: map-get($clr-grid-breakpoints, sm)) {
    padding: $clr_baselineRem_0_25 $clr_baselineRem_1;
  }
}
