@import './../mixins/reset.scss';

$amos-dropdown: amos-dropdown;
$contextMenuCls: amos-context-menu;
$ctx-box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
$ctx-border: 1px solid #f8f8f8;

.#{$amos-dropdown} {
  display: inline-block;
  vertical-align: middle;

  [class^='amosicon-'],
  [class*=' amosicon-'] {
    vertical-align: middle;
    transform: scale(0.8) rotate(0deg);
  }

  &-disabled,
  &-disabled a,
  &-disabled a:hover {
    color: #a3a6a9;
    cursor: not-allowed;
  }

  &-menu-warpper {
    position: absolute;
    z-index: 1010;
    padding: 0;
    margin: 0;
    text-align: left;
    list-style-type: none;
    background-color: white;
    border-radius: 4px;
    outline: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
    background-clip: padding-box;

    .amos-menu {
      border-radius: 4px;

      &-item {
        padding: 5px 12px;
        font-size: 14px;
        line-height: 22px;

        &:first-child {
          border-radius: 4px 4px 0 0;
        }

        &:last-child {
          border-radius: 0 0 4px 4px;
        }

        &:not(.disabled):hover {
          background: #f1f1f1;
        }

        &.active::after {
          display: none;
        }
      }
    }
  }
}

.#{$amos-dropdown}-toggle {
  display: inline-block;
  vertical-align: middle;
}

%ctx-theme-dark {
  color: #ccc;
  background: #2b2d2f;
  border: 1px solid #4c5055;
}

%ctx-theme-light {
  color: #333;
  background: white;
}

// context menu
.#{$contextMenuCls} {
  @include reset-component2;

  position: relative;
  z-index: 9;
  width: auto;
  line-height: 20px;
  word-break: keep-all;
  border: $ctx-border;
  border-radius: 2px;
  box-shadow: $ctx-box-shadow;

  .#{$contextMenuCls}-item {
    position: relative;
    min-height: 2.5em;
    cursor: pointer;

    &-icon {
      display: inline-block;
      width: 2em;
      vertical-align: middle;
    }

    &-content {
      padding: 5px 10px;
    }

    &-name {
      display: inline-block;
      font-size: 12px;
      word-break: keep-all;
      white-space: nowrap;
    }

    &-subicon {
      position: absolute;
      right: 0.5em;

      i {
        font-size: 10px;
      }
    }

    > .#{$contextMenuCls}-list {
      position: absolute;
      top: 0;
      left: 100%;
      display: none;
      width: auto;
      border: $ctx-border;
      border-radius: 2px;
      box-shadow: $ctx-box-shadow;
    }

    &:hover {
      > .#{$contextMenuCls}-list {
        display: block;
      }
    }

    &-divider {
      display: block;
      padding: 5px;
      border-top-style: solid;
      border-top-width: 1px;
    }
  }

  &-dark {
    @extend %ctx-theme-dark;

    .#{$contextMenuCls}-item {
      &:hover {
        color: white;
        background: rgba(0, 0, 0, 0.45);
      }

      > .#{$contextMenuCls}-list {
        @extend %ctx-theme-dark;
      }

      &-divider {
        border-top-color: rgba(#cacaca, 0.15);
      }
    }

    .#{$contextMenuCls}-left-item {
      &:hover {
        color: white;
        background: rgba(0, 0, 0, 0.45);
      }

      > .#{$contextMenuCls}-left-list {
        @extend %ctx-theme-dark;
      }
    }
  }

  &-light {
    @extend %ctx-theme-light;

    .#{$contextMenuCls}-item {
      &:hover {
        background: #e6f7ff;
      }

      > .#{$contextMenuCls}-list {
        @extend %ctx-theme-light;
      }

      &-divider {
        border-top-color: rgba(#10161a, 0.15);
      }
    }

    .#{$contextMenuCls}-left-item {
      &:hover {
        background: #e6f7ff;
      }

      > .#{$contextMenuCls}-left-list {
        @extend %ctx-theme-light;
      }
    }
  }
}

// left

.#{$contextMenuCls}-left {
  &-item {
    position: relative;
    min-height: 2.5em;
    cursor: pointer;

    &-arrow-icon {
      position: absolute;
      left: 0.5em;

      i {
        font-size: 10px;
      }
    }

    &-content {
      padding: 5px 10px;
    }

    &-name {
      position: absolute;
      left: 32px;
      font-size: 12px;
      word-break: keep-all;
      white-space: nowrap;
    }

    > .#{$contextMenuCls}-left-list {
      position: absolute;
      top: 0;
      right: 100%;
      display: none;
      width: auto;
      border: $ctx-border;
      border-radius: 2px;
      box-shadow: $ctx-box-shadow;
    }

    &:hover {
      > .#{$contextMenuCls}-left-list {
        display: block;
      }
    }
  }
}

// outer
.#{$amos-dropdown}-outer {

}

.#{$amos-dropdown}-popover {
  &.amos-popover-up {
    padding-bottom: 3px;
    margin-top: -3px;
  }

  &.amos-popover-down {
    padding-top: 3px;
  }

  &::after {
    display: none;
  }

  .amos-popover-content {
    padding: 0;
  }
}
