@import "../../base.less";

@import "./_var.less";

@import "../../mixins/_index.less";

/** dropdwon-menu */
.@{prefix}-dropdown-menu {
  &__bar {
    position: relative;
    display: flex;
    height: 48px;
    background: @dropdown-menu-color-block;

    &::after {
      .hairline-bottom();
    }
  }

  &__item {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding-left: 16px;
    padding-right: 16px;
    overflow: hidden;
    white-space: nowrap;
    color: @dropdown-menu-level-1-color;

    &.@{prefix}-is-active {
      color: @dropdown-menu-primary-color;

      .@{prefix}-dropdown-menu__arrow {
        transform: rotate(180deg);
      }
    }

    &.@{prefix}-is-disabled {
      color: @dropdown-menu-disabled-color;
    }
  }

  &__title {
    box-sizing: border-box;
    font-size: @font-size-l;
    flex-shrink: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  &__arrow {
    margin-left: 4px;
    flex-shrink: 0;
    transition: transform 220ms ease;
  }
}

/** dropdown-item */
.@{prefix}-dropdown-item {
  position: fixed;
  right: 0;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1000;
  overflow: hidden;

  &.@{prefix}-is-expanded &__content {
    transform: translate(0, 0);
  }

  &__content {
    position: absolute;
    max-height: @dropdown-item-height;
    left: 0;
    top: 0;
    width: 100%;
    bottom: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    z-index: 1600;
    transform: translate(0, -100%);
  }

  &__cell {
    position: relative;
    width: 100%;
    padding: @cell-vertical-padding @cell-horizontal-padding;
    line-height: 24px;
    font-size: 16px;
    text-align: left;

    .@{prefix}-icon {
      float: left;
    }
  }

  &__content.@{prefix}-is-single &__cell::after {
    .hairline-bottom(@cell-border-color);

    left: @cell-horizontal-padding;
  }

  &__bd {
    flex: 1;
    background: @dropdown-menu-color-block;
    overflow: auto;
  }

  &__ft {
    background: @dropdown-menu-color-block;
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 56px;

    &::before {
      z-index: 1;
      .hairline-top();
    }

    .@{prefix}-button {
      flex: 1;
      height: 100%;
      border-radius: 0;
      border: 0 none;

      &::after {
        display: none;
      }

      &--text {
        color: @dropdown-menu-level-1-color;
      }
    }
  }

  .@{prefix}-mask {
    position: absolute;
  }

  // 重写 checkbox 样式
  .@{prefix}-checkbox {
    padding: 8px;

    &__icon-left {
      margin-right: 4px;
    }

    &.@{prefix}-is-checked .@{prefix}-checkbox__label {
      color: @dropdown-menu-primary-color;
    }

    &__label {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    &-group {
      padding: 0 8px;
      display: grid;
    }
  }

  .@{prefix}-dropdown-item__tree-group {
    height: 100%;
    overflow-y: scroll;
    flex: 1;

    .@{prefix}-checkbox {
      padding: 16px;
    }

    .@{prefix}-radio {
      &.@{prefix}-is-checked .@{prefix}-radio__content-title {
        color: @brand-color;
      }
    }
  }

  // 重写 radio 样式
  .@{prefix}-radio__content-wrap {
    margin-left: 0;
    align-items: center;
  }

  .@{prefix}-radio__content-inner {
    margin-top: 0;
  }

  .@{prefix}-radio__icon-wrap {
    flex-shrink: 0;
  }

  /** 树形结构 */
  .@{prefix}-is-tree {
    max-height: @dropdown-item-height;

    .@{prefix}-dropdown-item__bd {
      display: flex;
      align-items: flex-start;
      overflow: hidden;

      .@{prefix}-dropdown-item__tree-group {
        flex: 1;
        margin: 0;
      }
    }

    .@{prefix}-checkbox-group {
      .@{prefix}-dropdown-item__cell:not(:last-child)::after {
        display: none;
      }
    }

    .@{prefix}-checkbox__content-wrap {
      overflow: hidden;
      align-items: center;
    }

    .@{prefix}-dropdown-item__cell {
      background: none;

      &::after {
        display: none;
      }
    }

    // 两列样式
    &.@{prefix}-is-col2 .@{prefix}-dropdown-item__tree-group,
    &.@{prefix}-is-col3 .@{prefix}-dropdown-item__tree-group {
      width: 33.33%;

      &:nth-child(1) {
        background: @dropdown-menu-tree-col1-color;

        .@{prefix}-checkbox__icon-left,
        .@{prefix}-radio__default-shape {
          display: none;
        }
      }
    }

    // 三列样式
    &.@{prefix}-is-col3 .@{prefix}-dropdown-item__tree-group {
      width: 33.33%;

      &:nth-child(2) {
        background: @dropdown-menu-tree-col2-color;

        .@{prefix}-checkbox__icon-left {
          display: none;
        }
      }
    }
  }

  /** multi 多选多列情况 */
  .@{prefix}-is-multi {

    .@{prefix}-dropdown-item__bd {
      padding-top: @spacer;
      padding-bottom: @spacer;
      overflow-y: auto;
    }

    .@{prefix}-dropdown-item__cell {
      padding-top: @spacer;
      padding-bottom: @spacer;

      &:not(:last-child)::after {
        display: none;
      }
    }

    // 复选框样式重写
    .@{prefix}-checkbox {
      .@{prefix}-checkbox__icon-left {
        display: none;
      }

      .@{prefix}-checkbox__label {
        font-size: @font-size-base;
      }

      .@{prefix}-checkbox__content-wrap {
        background-color: @dropdown-menu-tree-col1-color;
        border-radius: @dropdown-item-border-radius;
        // padding-left: @spacer;
        // padding-right: @spacer;
        text-align: center;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0 @spacer;
        box-sizing: border-box;
        height: 38px;
        line-height: 38px;
      }

      // 重置选中态背景色
      &.@{prefix}-is-checked .@{prefix}-checkbox__content-wrap {
        background-color: @dropdown-menu-primary-color-1;
      }
    }

    .@{prefix}-check-group {
      display: flex;
      flex-wrap: wrap;
    }

    // 两列样式
    &.@{prefix}-is-col2 .@{prefix}-checkbox-group {
      grid-template-columns: repeat(2, 1fr);
    }

    // 三列样式
    &.@{prefix}-is-col3 .@{prefix}-checkbox-group {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  /** dropRadio */
  &__radio {

    // 未知样式？
    .@{prefix}-radio__default-shape {
      display: none;
    }

    // 单选的选中态效果重写
    &.@{prefix}-is-checked {

      .@{prefix}-radio {
        &__label {
          color: @dropdown-menu-primary-color;
        }

        &__content-inner {
          font-size: 24px;
        }
      }
    }
  }
}
