@import '../style/theme/color';
@import '../style/core/_font';
@import '../style/theme/corner';
@import '../style/core/animation';

@mixin tag-item() {
  d-tag > .devui-tag-item {
    display: block !important;

    .devui-category-search-multi-tag > span,
    & > span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: inline-block;
      vertical-align: middle;
      margin: 0 4px;
    }
  }
}

:host:not(.devui-glow-style) .devui-category-search-container.container-hover:hover {
  border: 1px solid $devui-form-control-line-hover;
}

.devui-category-search-container {
  position: relative;
  border-radius: $devui-border-radius;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  display: flex;
  align-items: flex-start;
  background: transparent;
  transition: border $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;
  background-color: $devui-base-bg;
  border: 1px solid $devui-line;

  &.container-hover {
    & > .devui-category-search-icon svg g path {
      fill: $devui-icon-fill-hover;
    }
  }

  &:focus-within,
  &.container-active {
    border-color: $devui-brand;
  }

  &.devui-gray-style {
    background-color: $devui-gray-form-control-bg;
    border-color: transparent;
    transition: all $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;

    &:hover {
      background-color: $devui-gray-form-control-hover-bg;
    }

    &:focus-within {
      background-color: $devui-base-bg;
      border-color: $devui-brand;
    }

    .devui-category-search-input input.devui-category-search-toggle {
      background-color: transparent !important;
    }
  }

  &.disabled {
    cursor: not-allowed;
    background-color: $devui-disabled-bg;
    border-color: $devui-disabled-line;
    color: $devui-disabled-text;

    .devui-category-search-icon,
    .devui-category-search-line-container {
      pointer-events: none;
    }

    .devui-category-search-icon svg g path {
      fill: $devui-disabled-text;
    }
  }

  .devui-category-search-toggle {
    color: $devui-text;
  }

  .devui-category-search-line-container {
    width: 100%;
    height: 32px;
    overflow: hidden;

    &:hover {
      overflow-x: auto;
      overflow-x: overlay;
    }

    .devui-category-search-line {
      display: flex;
      flex-flow: row nowrap;
      justify-content: flex-start;
      align-items: flex-start;
      width: 100%;
      height: 32px;
      position: relative;
      top: -1px;

      & > li {
        display: flex;
        align-items: center;
        flex-grow: 0;
        white-space: nowrap;
        height: 100%;
      }

      .devui-category-search-input {
        display: flex;
        justify-content: flex-start;
        flex-grow: 1;
        align-items: center;
        min-width: 160px;
        padding-right: 20px;

        input {
          min-width: 240px;
          width: 100%;
          height: 32px;
          font-size: $devui-font-size-sm;
        }

        .devui-category-search-toggle {
          padding-left: 0;
        }

        .devui-category-search-keyword-in-category {
          overflow: visible;
        }
      }
    }
  }

  input {
    border: none;
    background: transparent;
  }

  .devui-input-container {
    display: flex;
    flex: 1;

    .devui-input-box {
      width: 100%;
    }
  }

  .devui-category-search-extended-container {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    width: fit-content;
    height: 16px;
    margin: 8px 0 8px;
    border-left: solid 1px $devui-line;
    padding-left: 8px;

    &:empty {
      border: none;
      padding-left: 0;
    }
  }
}

.devui-tag-item {
  display: inline-block;
  margin-right: 4px;

  &:first-child {
    margin-left: 4px;
  }

  &:focus {
    outline: none;
  }

  .devui-color-block-split-line {
    color: $devui-aide-text;
  }

  .devui-color-block-sm {
    width: 8px;
    height: 8px;
    border-radius: $devui-border-radius;
    margin-right: 4px;
    display: inline-block;
    position: relative;
    top: -1px;
    vertical-align: middle;
  }
}

span:focus {
  outline: none;
}

.devui-category-search-icon {
  display: flex;
  align-items: center;
  height: 100%;
  padding-right: 4px;
  cursor: pointer;

  &:last-child {
    padding-right: 0;
  }

  svg g path {
    outline: none;
    fill: $devui-icon-fill;
    transition: all $devui-animation-ease-in-out-smooth $devui-animation-duration-slow;
  }

  &.disabled {
    cursor: not-allowed;

    svg g path {
      fill: $devui-disabled-text;
    }
  }

  &:not(.disabled):hover svg g path {
    fill: $devui-icon-fill-hover;
  }
}

input,
input:focus {
  outline: none !important;
}

a:focus,
a:hover {
  color: $devui-list-item-hover-text;
}

d-tag {
  cursor: pointer;
}

.devui-category-search-toggle {
  height: 30px;
}

.devui-date-picker-operation-area {
  border-top: 1px solid $devui-dividing-line;
  margin: 16px 0;
  padding: 16px 16px 0;
  display: flex;
  justify-content: flex-end;

  d-button:not(:first-child) {
    margin-left: 16px;
  }
}

.devui-dropdown-operation-area {
  border-top: 1px solid $devui-dividing-line;
  padding-top: 8px;
  margin: 8px 0;
  display: flex;
  justify-content: center;

  d-button:first-child {
    margin-right: 8px;
  }
}

.devui-input-number-operation-area {
  padding: 16px 16px 8px;
  display: flex;
  justify-content: space-evenly;
}

.devui-save-panel {
  width: 400px;
  height: auto;
  margin-top: 4px;

  .devui-save-panel-title {
    display: flex;
    justify-content: space-between;
    height: 48px;
    line-height: 48px;
    border-bottom: 1px solid $devui-dividing-line;
    padding: 0 20px;
    font-size: 14px;
    font-weight: bold;
    color: $devui-font-size-page-title;
  }

  .devui-save-filter-name {
    padding: 16px 20px;

    & > form {
      position: relative;

      input {
        padding-right: 28px;
      }

      svg {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        cursor: pointer;

        path {
          fill: $devui-shape-icon-fill;
        }

        &:hover {
          svg g path {
            fill: $devui-shape-icon-fill-hover;
          }
        }
      }
    }

    & > span {
      padding-bottom: 8px;
      display: block;
      line-height: 1em;
    }

    & > input {
      width: 100%;
      height: 32px;
      margin: 4px auto;
      line-height: 20px;
      border: 1px solid $devui-form-control-line;
    }
  }

  .devui-save-panel-operation-area {
    padding-bottom: 12px;
    display: flex;
    justify-content: center;

    d-button:not(:first-child) {
      margin-left: 16px;
    }
  }
}

.devui-category-search-select-all {
  margin: 8px 4px -8px 4px;
  padding: 0 8px;
  height: 28px;
  line-height: 28px;

  &:hover {
    background-color: $devui-list-item-hover-bg;
  }
}

.devui-dropdown-menu-template {
  max-width: 300px;
  max-height: 352px;
  overflow: auto;

  &:empty {
    display: none;
  }

  .devui-category-search-group {
    font-size: $devui-font-size;

    &.devui-dropdown-item:hover {
      background-color: transparent;
      color: $devui-text;
      cursor: default;
    }
  }
}

.devui-selected-tags-list {
  ul {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    justify-content: flex-start;
    max-height: 390px;
    overflow: auto;

    li {
      display: flex;
      flex-grow: 0;
      flex-flow: row wrap;
      margin: 2px 4px 2px 0;

      &:last-child {
        margin-right: 0;
      }
    }
  }
}

:host ::ng-deep {
  .devui-tag-container {
    line-height: 1;
    @include tag-item;
  }

  .devui-category-search-container.disabled d-tag .devui-tag-item {
    background-color: $devui-disabled-bg;
    border: solid 1px $devui-disabled-line;
    color: $devui-disabled-text;
  }

  .devui-checkbox-column-margin {
    height: 32px !important;
    line-height: 32px !important;
  }
}

::ng-deep {
  .cdk-overlay-container {
    d-datepicker[id='devui-category-search-date-picker'] .devui-month-view {
      box-shadow: none !important;

      tfoot {
        display: none;
      }
    }

    .devui-selected-tags-list ul li .remove-button {
      right: 8px;
    }

    .devui-tag-container {
      @include tag-item;
    }
  }

  .devui-dropdown-top,
  .devui-dropdown-bottom,
  .devui-dropdown-open {
    .devui-dropdown-menu-fix {
      margin-bottom: 0;
    }
  }

  .devui-dropdown-menu-fix {
    min-width: 200px;
    margin-left: 0;
    overflow-y: auto;
    white-space: nowrap;

    &.max-height {
      max-height: 405px;
    }

    .devui-checkbox-group {
      padding: 8px 12px 0;

      .devui-color-block {
        width: 12px;
        height: 12px;
        margin-right: 8px;
        border-radius: $devui-border-radius;
        top: -1px;
        position: relative;
        vertical-align: middle;
        display: inline-block;
      }
    }

    .devui-category-search-type-text-input {
      margin: 16px 8px 8px;
      width: calc(100% - 16px);
    }

    .devui-select-list {
      display: flex;
      flex-wrap: wrap;
      max-width: 300px;
      padding: 8px 8px 0 8px;

      span {
        margin-right: 8px;
      }
    }

    .devui-search-container d-search {
      width: 100%;

      .devui-search .devui-input.devui-clear-exit:not(.devui-icon-left) {
        padding-right: 28px;
      }
    }

    .devui-category-search-tree-container {
      overflow-y: auto;
      max-height: 264px;
      padding: 12px;
    }

    .devui-no-data-tip {
      padding: 12px;
    }

    .devui-yearOption,
    .devui-monthOption {
      white-space: normal;
    }
  }

  .devui-dropdown-menu-fix d-datepicker-calendar {
    display: block;
  }

  .devui-dropdown-menu-template .devui-checkbox-group {
    ul {
      max-height: 310px;
    }

    d-checkbox {
      .devui-checkbox {
        margin: 0 -8px 0 -8px;
        padding: 0 8px;

        &:hover {
          background-color: $devui-list-item-hover-bg;

          label {
            color: $devui-list-item-hover-text;
          }
        }

        &:active {
          background-color: $devui-list-item-active-bg;

          label {
            color: $devui-list-item-active-text;
          }
        }

        label {
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          width: 100%;
        }
      }
    }
  }

  .devui-dropdown-menu-fix d-input-number {
    width: 70px;
  }

  .devui-dropdown-menu-template .devui-checkbox-group {
    ul {
      max-height: 310px;
    }

    d-checkbox {
      .devui-checkbox {
        transition: background-color $devui-animation-duration-fast $devui-animation-ease-in-out-smooth;

        label {
          transition: color $devui-animation-duration-fast $devui-animation-ease-in-out-smooth;
        }
      }
    }
  }
}

.devui-dropdown-menu-tip {
  cursor: text;
  padding: 12px 12px 0;
  pointer-events: none;
  color: $devui-aide-text;
}

.devui-dividing-line {
  height: 1px;
  width: 100%;
  background-color: $devui-dividing-line;
  margin-top: 4px;
}

.devui-dropdown-menu {
  margin-top: 4px;
  padding-bottom: 0;

  .devui-dropdown-item .icon-search {
    margin-right: 4px;
  }
}

.devui-no-data-text {
  padding: 8px 0;
  text-align: center;
}

.devui-datepicker-footer {
  text-align: center;
}
