@import './var.less';
@import '../dropdown-item/var.less';

:root {
  --glm-dropdown-menu-height: @dropdown-menu-height;
  --glm-dropdown-menu-background-color: @dropdown-menu-background-color;
  --glm-dropdown-menu-box-shadow: @dropdown-menu-box-shadow;
  --glm-dropdown-menu-title-font-size: @dropdown-menu-title-font-size;
  --glm-dropdown-menu-title-text-color: @dropdown-menu-title-text-color;
  --glm-dropdown-menu-title-active-text-color: @dropdown-menu-title-active-text-color;
  --glm-dropdown-menu-title-disabled-text-color: @dropdown-menu-title-disabled-text-color;
  --glm-dropdown-menu-title-padding: @dropdown-menu-title-padding;
  --glm-dropdown-menu-title-line-height: @dropdown-menu-title-line-height;
  --glm-dropdown-menu-option-active-color: @dropdown-menu-option-active-color;
  --glm-dropdown-menu-content-max-height: @dropdown-menu-content-max-height;
}

.glm-dropdown-menu {
  user-select: none;

  &__bar {
    position: relative;
    display: flex;
    height: var(--glm-dropdown-menu-height);
    background: var(--glm-dropdown-menu-background-color);
    box-shadow: var(--glm-dropdown-menu-box-shadow);

    &--opened {
      z-index: calc(var(--glm-dropdown-item-z-index) + 1);
    }
  }

  &__item {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-width: 0; // hack for flex ellipsis

    &--disabled {
      .glm-dropdown-menu__title {
        color: var(--glm-dropdown-menu-title-disabled-text-color);
      }
    }
  }

  &__title {
    position: relative;
    box-sizing: border-box;
    max-width: 100%;
    padding: var(--glm-dropdown-menu-title-padding);
    color: var(--glm-dropdown-menu-title-text-color);
    font-size: var(--glm-dropdown-menu-title-font-size);
    line-height: var(--glm-dropdown-menu-title-line-height);

    &::after {
      position: absolute;
      top: 50%;
      right: -4px;
      margin-top: -5px;
      border: 3px solid;
      border-color: transparent transparent var(--glm-gray-4) var(--glm-gray-4);
      transform: rotate(-45deg);
      opacity: 0.8;
      content: '';
    }

    &--active {
      color: var(--glm-dropdown-menu-title-active-text-color);

      &::after {
        border-color: transparent transparent currentColor currentColor;
      }
    }

    &--down {
      &::after {
        margin-top: -1px;
        transform: rotate(135deg);
      }
    }
  }
}
