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

//  居中
.flex_center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.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_wrapper {
          display: inline-flex;
          border-collapse: separate;
          border-spacing: 0;

          .lm_filter_custom_select {
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
            margin-right: -1px;
          }
          .lm_filter_custom_addon {
            border-top-left-radius: 0;
            border-bottom-left-radius: 0;

            &.addon_highlight {
              color: @primary-color;
            }
          }
        }

        .lm_filter_custom_select {
          position: relative;
          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;
          gap: 4px;

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

          .lm_filter_custom_select_label {
            overflow: hidden;
            text-overflow: ellipsis;

            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 {
            z-index: 1;
            border-color: @primary-color-hover;
          }

          &.expand {
            z-index: 1;
            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 @padding-xs;
  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-lg;
    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;
  }
  & > .ant-picker {
    transform: translateY(-36px);
    visibility: hidden;
  }

  &.filter_dropdown_container_numberRange {
    .filter_body_range {
      display: flex;
      align-items: center;
      gap: @gap-base;

      .number_range {
        display: flex;
        min-width: 128px;
        align-items: center;
        border: @border-width-base @border-style-base @input-border-color;
        border-radius: @control-border-radius;
        .ant-input-number-input {
          text-align: center;
        }
      }

      .ant-input-number-handler-wrap {
        display: none;
      }
    }

    .filter_body_footer {
      padding-top: @dropdown-edge-child-vertical-padding;
      text-align: right;
    }
  }
}

// 单选、多选、级联选择下拉菜单样式
.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-10;
      }

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

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

    .filter_body_footer {
      padding-top: @dropdown-edge-child-vertical-padding;
      text-align: right;
    }
  }

  & > :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;
}

// 下拉菜单共用样式
.common_dropdown {
  position: relative;
  text-align: left;
  list-style-type: none;
  border-radius: @border-radius-middle;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.15);
  background-color: @dropdown-menu-bg;
  background-clip: padding-box;
  overflow: hidden;
  outline: none;
}

.filter_dropdown_complex {
  .common_dropdown();
  display: flex;
  flex-flow: column;
  padding: @padding-sm @padding-lg 0;
  min-width: 552px;
}

.complex_container {
  .complex_header {
    .flex_center();
    justify-content: space-between;
    gap: @gap-base;
    padding-bottom: @padding-sm;

    .header_title {
      font-size: @font-size-lg;
      font-weight: bold;
      color: @text-color;
    }

    .header_condition_group {
      .flex_center();
      gap: @gap-base;
      .condition_select {
        width: 80px;
      }
      & > span {
        color: @text-color-secondary-deep;
      }
    }
  }

  .complex_body {
    .complex_list {
      display: flex;
      flex-flow: column;
      gap: @gap-base;
      margin-bottom: @margin-xs;
      max-height: 600px;
      overflow-y: auto;

      .complex_list_item {
        .flex_center();
        gap: @gap-base;
        overflow: hidden;
        & > :nth-child(1) {
          width: 140px;
        }
        & > :nth-child(2) {
          width: 140px;
        }
        & > :nth-child(3) {
          flex: 1 1 0;
        }
      }
    }
  }

  .complex_footer {
    .flex_center();
    justify-content: flex-end;
    gap: @gap-base;
    padding: @padding-sm 0;

    .anticon {
      font-size: @font-size-lg;
    }
  }
}

.ant-modal-wrap {
  &.custom_save_confirm {
    .ant-modal-body {
      .custom_save_modal_title {
        font-size: @font-size-lg;
        font-weight: bold;
        line-height: @line-height-base;
        color: @text-color;
      }

      .custom_save_modal_content {
        font-size: @font-size-sm;
        color: @text-color-secondary-deep;
        margin-top: 10px;
      }
    }

    .ant-modal-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 @padding-lg @padding-lg;

      .footer_link_text {
        font-size: @font-size-base;
        color: @primary-color;
        cursor: pointer;
      }
    }
  }
  &.custom_save_modal {
    .ant-modal-body {
      padding: 0 @padding-lg;
      .ant-form-item-label {
        font-size: @font-size-base;
        font-weight: 500;
      }
      .form_label {
        font-size: @font-size-base;
        font-weight: 500;
        padding-bottom: @padding-xs;
      }
    }
  }
}
