@import '../../style/themes/index.less';

.lm_filter_wrapper {
  .lm_filter_container {
    .lm_filter {
      display: flex;
      flex-wrap: wrap;
      gap: @gap-base;
      align-items: center;
      font-size: @font-size-base;

      // 自定义筛选
      .lm_filter_custom {
        display: inline-flex;
        gap: @gap-base;

        .lm_filter_custom_select {
          display: inline-flex;
          align-items: center;
          justify-content: space-between;
          min-width: 100px;
          max-width: 180px;
          height: @height-base;
          padding: 0 @padding-xs;
          color: @text-color-secondary-deep;
          line-height: 1;
          border: @border-width-base @border-style-base @border-color-base;
          border-radius: @border-radius-base;
          cursor: pointer;
          transition: 0.3s;

          &.small {
            height: @height-sm;
          }

          .lm_filter_custom_select_label {
            span {
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
            }
          }

          .lm_filter_custom_select_icon {
            color: @text-color-secondary;
            font-size: @font-size-base;
            transition: 0.3s;
          }

          &:hover {
            border-color: @primary-color-hover;
          }

          &.expand {
            color: @text-color-secondary;
            border-color: @primary-color-hover;

            .lm_filter_custom_select_icon {
              transform: rotateX(180deg);
            }
          }
        }

        .lm_filter_custom_line {
          width: @border-width-base;
          height: @height-base;
          background-color: @border-color-split;
        }
      }

      .lm_filter_search {
        width: 140px;
        max-width: 140px;
      }

      .lm_filter_complex {
        display: inline-flex;
        &:hover {
          .addon_before {
            color: @text-color-new;
          }
        }
      }

      &.lm_filter_small {
        .lm_filter_custom_line {
          height: @height-sm;
        }
      }
    }
  }
}

.lm_filter_basic_item {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: @height-base;
  padding: 0 8px;
  font-size: @font-size-base;
  line-height: 1;
  vertical-align: middle;
  border-radius: @border-radius-base;
  cursor: pointer;
  transition: 0.3s;

  &.small {
    height: @height-sm;
  }

  // 悬浮/展开/选中都展示背景色
  &:hover,
  &.expand,
  &.active {
    background-color: @background-color-base;
  }

  .filter_item_label {
    flex: 0 0 auto;
  }

  .filter_item_value {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    max-width: 552px;
    overflow: hidden;
    color: @text-color-secondary-deep;
    transition: 0.3s;

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

  .filter_item_icon {
    color: @text-color-secondary;
    font-size: @font-size-base;
    transition: 0.3s;

    &.addon_before {
      color: @text-color-secondary-deep;
    }

    .icon_clear {
      display: none;
    }
  }

  &.expand {
    .filter_item_icon.addon_after {
      transform: rotateX(180deg);
    }
  }

  &.active {
    .filter_item_value {
      color: @primary-color;
    }

    // 选中时不转动清除图标
    .filter_item_icon.addon_after {
      transform: rotateX(180deg);
    }

    // 高级筛选选中
    &.lm_filter_complex_item {
      .filter_item_icon,
      .filter_item_label {
        color: @primary-color;
      }
    }

    // 存在选中项时，hover展示
    &:hover {
      .icon_down {
        display: none;
      }
      .icon_clear {
        display: inline-block;
      }
    }
  }
}

// 下拉样式
.ant-dropdown {
  // 解决级联选择的偏移不同问题
  &.filter_dropdown_container_cascader > div {
    transform: translateY(-4px);
  }

  &.filter_dropdown_container_date .ant-picker {
    transform: translateY(-36px);
    visibility: hidden;
  }
}

// 单选、多选、级联选择下拉菜单样式
.filter_dropdown {
  display: flex;
  flex-flow: column;
  background-color: #fff;
  box-shadow: 0 2px 6px @shadow-color;
  /** last add */
  position: relative;
  margin: 0;
  padding: @dropdown-edge-child-vertical-padding;
  text-align: left;
  list-style-type: none;
  background-color: @dropdown-menu-bg;
  background-clip: padding-box;
  border-radius: @border-radius-middle;
  outline: none;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.15);
  overflow: hidden;

  .filter_header {
    min-height: 40px;
    padding: @padding-xs 0;

    .filter_header_operate {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .filter_header_operate_checked {
        display: inline-flex;
        align-items: center;
      }

      .filter_reset {
        color: @primary-color;
        font-size: @font-size-base;
        cursor: pointer;
      }

      .filter_tip {
        color: @text-color-secondary;
        font-size: @font-size-base;
      }
    }

    .ant-input-group {
      line-height: 1;
    }

    input {
      font-size: @font-size-base;
    }

    .ant-input-search + .filter_header_operate,
    .ant-input-affix-wrapper + .filter_header_operate,
    & > :nth-child(2).filter_header_operate {
      margin-top: @margin-xs;
    }
  }

  .filter_body {
    width: 100%;

    .virtual_list {
      min-width: 168px;
      max-height: 224px;
      overflow: auto;
      &.filter_list {
        .filter_item {
          clear: both;
          margin: 0;
          padding: 5px 12px;
          color: @text-color;
          font-weight: normal;
          font-size: @dropdown-font-size;
          line-height: @dropdown-line-height;
          cursor: pointer;
          transition: all @animation-duration-slow;
          border-radius: @border-radius-base;
          margin-bottom: 4px;
        }
      }
    }

    .filter_item {
      display: flex;
      gap: @gap-base;
      align-items: center;
      justify-content: space-between;
      min-width: 120px;
      height: @height-base;
      padding: 0 @padding-xs;
      font-size: @font-size-base;
      white-space: nowrap;
      cursor: pointer;
      transition: 0.3s;

      &.last_item {
        position: relative;
        border-radius: @border-radius-base;
        &::before {
          content: '';
          width: 100%;
          position: absolute;
          height: @border-width-base;
          background-color: @border-color-base;
          top: -6px;
          left: 0;
        }
        // border-top: @border-width-base @border-style-base @border-color-base;
        margin-top: @padding-xs;
      }

      .filter_item_content {
        flex: auto;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;

        &.lm-checkbox > span:last-child {
          max-width: none;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }

      .filter_item_operate {
        display: inline-flex;
        gap: 4px;
        align-items: center;

        .icon_hover {
          font-size: @font-size-lg;
          opacity: 0;
          transition: 0.3s;

          &:hover {
            color: @primary-color;
          }
        }
      }

      &[disabled] {
        display: none;
      }

      &.checked {
        color: @text-color-new;
        background-color: @primary-1;
      }

      &:hover {
        background-color: @text-color-bg;

        .filter_item_operate .icon_hover {
          opacity: 1;
        }
      }
    }
  }

  & > :nth-child(2).filter_body {
    border-top: @border-width-base @border-style-base @border-color-base;
    padding-top: 4px;
  }

  .filter_footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: @height-base;
    padding: 6px @padding-xs 0 @padding-xs;
    font-size: @font-size-base;
    letter-spacing: 1px;
    border-top: @border-width-base @border-style-base @border-color-base;
    margin-top: 4px;

    button {
      padding: 0 @padding-xs;
      font-size: @font-size-base;
    }

    .footer_save {
      color: @primary-color;
      cursor: pointer;
      transition: 0.3s;
    }

    .footer_clear {
      color: @text-color-secondary;
      cursor: pointer;
      transition: 0.3s;

      &:hover {
        color: @text-color-new;
      }
    }
  }

  .filter_empty {
    display: flex;
    flex-flow: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin: auto;
    padding: @padding-md @padding-xs;
    color: @text-color-secondary-new;
    font-size: @font-size-base;

    .filter_empty_text {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 20px;
      color: @text-color-new;
    }
  }

  // 组件的样式重置
  .ant-checkbox-wrapper {
    flex: 1;
    align-items: center;
    font-size: @font-size-base;

    .ant-checkbox {
      top: initial;
    }
  }

  .ant-cascader-menu {
    padding: 0;
  }
}

// 抽屉组件样式
.ant-drawer {
  .ant-drawer-header {
    .ant-drawer-title {
      font-size: @font-size-base;
    }
  }

  &.lm_filter_drawer {
    // 自定义筛选抽屉样式
    .filter_drawer_group {
      font-size: @font-size-base;
      line-height: 1;

      .ant-form-item {
        margin-bottom: @margin-md;
      }

      .ant-form-item-label {
        padding-bottom: 0;

        label {
          font-size: @font-size-base;
        }
      }

      input {
        font-size: @font-size-base;
      }

      // 单选按钮
      .ant-radio-wrapper {
        display: inline-flex;
        align-items: center;
        font-size: @font-size-base;

        .ant-radio {
          top: 0;
        }
      }
    }

    .filter_drawer_group_add {
      padding: 0 0 @padding-xs;

      .ant-btn {
        max-width: initial;
        font-size: @font-size-base;
      }
    }

    .filter_drawer_group_list {
      .filter_drawer_group_item {
        margin-bottom: @margin-xs;

        .item_box {
          padding: @padding-md;
          line-height: 1;
          background: @background-color-base;
          border: @border-width-base @border-style-base transparent;
          border-radius: @border-radius-base;
          cursor: pointer;
          transition: 0.3s;

          .item_header {
            display: flex;
            align-items: center;
            justify-content: space-between;

            .item_header_title {
              font-weight: 500;
              font-size: @font-size-base;
            }

            .item_header_icon {
              color: @text-color-secondary-deep;
              font-size: @font-size-lg;
              transition: 0.3s;

              &.icon_plus {
                color: @text-color-new;
              }

              &:hover {
                color: @text-color-new;
              }
            }
          }

          .item_tags {
            display: flex;
            flex-flow: wrap;
            gap: @gap-base;
            padding-top: @font-size-base;

            .ant-tag {
              margin: 0;
              color: @text-color-new;
              background-color: @background-color-base;

              &.add_tags {
                background: transparent;
                border-style: dashed;
                cursor: pointer;
                &:hover {
                  color: @primary-color;
                  border-color: @primary-color;
                }
              }
            }

            .tag-input {
              width: 78px;
              margin-right: @margin-xs;
              vertical-align: top;
            }
          }
        }
      }
    }

    // 高级筛选抽屉样式
    .complex_filter_body {
      .checked_group {
        margin-bottom: @margin-lg;
      }

      .list_group {
        .list_group_title {
          font-weight: 500;
          font-size: @font-size-base;
          line-height: 1.25;
        }

        .list_group_search {
          margin: @margin-md 0;
        }
      }
    }
  }

  // 高级筛选二层抽屉
  &.lm_det_drawer {
    .checkbox_tag {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      height: @height-sm;
      padding: 0 @padding-xs;
      color: @text-color-new;
      font-size: @font-size-base;
      background-color: @background-color-base;
      border-radius: @border-radius-base;
      cursor: pointer;
      transition: 0.3s;

      &:hover,
      &.active {
        color: @btn-primary-color;
        background-color: @btn-primary-bg;
      }
    }

    .ant-form-item {
      margin-bottom: @margin-md;

      .ant-form-item-label > label {
        font-weight: 500;
      }
    }

    .auto_height {
      max-height: 418px;
      overflow-y: auto;
    }

    // 单选按钮
    .ant-radio-wrapper {
      display: inline-flex;
      align-items: center;
      font-size: @font-size-base;

      .ant-radio {
        top: 0;
      }
    }

    .ant-select {
      width: 100%;
      font-size: @font-size-base;
    }

    // 自定义表单样式
    .custom_form {
      display: flex;
      flex-flow: column;
      gap: 24px;
      height: 100%;

      .custom_label {
        margin-bottom: @margin-md;
        color: @text-color-new;
        font-weight: 500;
        font-size: @font-size-base;
      }

      // 自适应高度
      .custom_full {
        display: flex;
        flex: 1;
        flex-flow: column;
      }
    }
  }
}

// 日期区间下拉框
.lm_filter_dropdown_picker {
  padding: 0 !important; // 解决下拉菜单偏移问题

  .filter_picker_box {
    display: flex;

    .filter_picker_aside {
      padding: 6px 0;
      font-size: @font-size-base;
      border-right: @border-width-base @border-style-base @border-color-split;

      .filter_picker_aside_item {
        display: flex;
        align-items: center;
        height: @height-base;
        padding: 0 @padding-xs;
        cursor: pointer;
        transition: 0.3s;

        &:hover,
        &.active {
          background-color: @primary-color-hover;
        }
      }
    }

    .filter_picker_main {
      .filter_picker_header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 40px;
        padding: 0 @padding-md;
        line-height: 1;
        border-bottom: @border-width-base @border-style-base @border-color-split;

        .ant-radio-button-wrapper {
          color: @text-color-secondary-new;
          font-size: @font-size-base;

          &:hover,
          &.ant-radio-button-wrapper-checked {
            color: @primary-color;
          }
        }
      }
    }
  }

  .ant-picker-range-arrow {
    display: none;
  }
}

// 级联选择弹窗
.ant-select-dropdown.ant-cascader-dropdown {
  padding: 0;
}
