@import 'src/components/icon/icon';

@keyframes openDropmenu {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown {
  position: relative;
  font-size: 15px;

  .label-badge {
    position: relative;

    &:after {
      top: -5px;
      right: -18px;
    }
  }

  &.active {
    .dropdown-menu {
      display: block;
      opacity: 1;
    }

    .dropdown-button .icon-arrow-down {
      transform: rotate(180deg);
    }
  }

  .dropdown-button {
    font-weight: bold;
    line-height: 18px;
    color: #fff;
    cursor: pointer;
    margin-left: 20px;
    display: flex;

    .icon {
      width: 16px;
      height: 16px;
      vertical-align: middle;
      margin-left: 6px;
      transition: 150ms transform;
      will-change: transform;
    }

    & > .label-badge {
      &.badge-icon {
        margin-right: 13px;
      }
    }
  }
}

.dropdown-menu {
  display: block;
  opacity: 1;
  position: absolute;
  background-color: #333333;
  box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 8px 0;
  z-index: 5;
  animation: openDropmenu 100ms ease-out forwards;
  max-height: 220px;
  overflow-y: auto;
  font-size: 15px;
  text-align: left;
  font-weight: normal;

  &.top {
    margin-bottom: 10px;
    bottom: 100%;
  }
  &.bottom {
    margin-top: 10px;
    top: 100%;
  }
  &.right {
    left: 0;
  }
  &.left {
    right: 0;
  }
  &.stick-bottom {
    bottom: -95px;
    margin: 5px 0;
  }

  .dropdown-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 12px;
    margin: 4px;
    white-space: nowrap;
    min-height: 30px;
    cursor: pointer;
    border-radius: 4px;

    &:hover {
      background-color: $tone-5-color;
      color: #fff;
    }

    &:focus {
      color: #fff;
    }

    &.active {
      .menu-icon-container {
        opacity: 1;
      }
    }
    .icon-check-active {
      display: inline-block;
      margin-left: 16px;
      vertical-align: middle;
      width: 24px;
      height: 24px;
    }

    .menu-icon-container {
      opacity: 0;
    }

    & > .label-badge {
      &.badge-icon {
        margin-right: 5px;
      }
    }

    &[disabled] {
      color: #888;
    }
  }
}

.smart-container {
  & > div:last-child {
    .dropdown-menu {
      &.stick-bottom {
        bottom: -55px !important;
      }
    }
  }
}

[data-captions-menu] .dropdown-menu-item:has(span[aria-label="__separator__"]) {
  all: unset;
  display: block;
  width: 100%;
  height: 1px;
  background: var(--Tone-4, #666);
  margin: 8px 0;
  padding: 0;
  pointer-events: none;
  cursor: default;
}

[data-captions-menu] span[aria-label="__separator__"] {
  display: none !important;
}
