@import "../../style/themes/default";
@import "../../style/mixins/index";
@import "../../input/style/mixin";
@import "../../button/style/mixin";

@timepicker-prefix-cls: ~"@{dt-prefix}-time-picker";
@timepicker-item-height: 20px;

.selection__clear() {
  display: inline-block;
  font-style: normal;
  vertical-align: baseline;
  text-align: center;
  text-transform: none;
  text-rendering: auto;
  opacity: 0;
  position: absolute;
  right: @control-padding-horizontal - 1px;
  z-index: 1;
  background: @component-background;
  top: 50%;
  font-size: @font-size-sm;
  color: @disabled-color;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  line-height: 12px;
  cursor: pointer;
  transition: color 0.3s ease, opacity 0.15s ease;
  &:before {
    display: block;
    .iconfont-font(@icon-close-circle);
  }
  &:hover {
    color: @text-color-secondary;
  }
}

.@{timepicker-prefix-cls}-panel {
  .reset-component;
  z-index: @zindex-picker;
  position: absolute;
  max-width: 150px;

  &-inner {
    position: relative;
    outline: none;
    list-style: none;
    font-size: @font-size-base;
    text-align: left;
    background-color: @component-background;
    border-radius: @border-radius-base;
    box-shadow: @box-shadow-base;
    background-clip: padding-box;
    overflow: hidden;
    // left: -2px;
  }

  &-input {
    position: absolute;
    top: 4px;
    // right: 0;
    margin: 0;
    padding: 0;
    border: 0;
    width: 80%;
    cursor: auto;
    outline: 0;

    .placeholder;

    &-wrap {
      box-sizing: border-box;
      position: relative;
      padding: 7px 2px 7px @control-padding-horizontal;
      border: @border-width-base @border-style-base @border-color-split;
      height: 32px;
    }

    &-invalid {
      border-color: red;
    }
  }

  &-clear-btn {
    position: absolute;
    right: 8px;
    cursor: pointer;
    overflow: hidden;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    top: 5px;
    margin: 0;
  }

  &-clear-btn:after {
    font-size: @font-size-base - 2px;
    color: @disabled-color;
    display: inline-block;
    line-height: 1;
    width: 20px;
    transition: color 0.3s ease;
    .iconfont-font(@icon-close-circle);
  }

  &-clear-btn:hover:after {
    color: @text-color-secondary;
  }

  &-narrow &-input-wrap {
    max-width: @time-picker-panel-column-width * 2;
  }

  &-select {
    float: left;
    font-size: @font-size-base;
    border-left: @border-width-base @border-style-base @border-color-split;
    box-sizing: border-box;
    width: @time-picker-panel-column-width;
    overflow: hidden;
    position: relative; // Fix chrome weird render bug
    max-height: @timepicker-item-height * 6;

    &:hover {
      overflow-y: auto;
    }

    &:first-child {
      border-left: 0;
      margin-left: 0;
    }

    &:last-child {
      border-right: 0;
    }

    &:only-child {
      width: 100%;
    }

    ul {
      list-style: none;
      box-sizing: border-box;
      margin: 0;
      padding: 0 0 @timepicker-item-height * 5;
      width: 100%;
    }

    li {
      list-style: none;
      box-sizing: content-box;
      margin: 0;
      padding: 0 0 0 @control-padding-horizontal;
      width: 100%;
      height: @timepicker-item-height;
      line-height: @timepicker-item-height;
      text-align: left;
      cursor: pointer;
      user-select: none;
      transition: background 0.3s;
    }

    li:hover {
      background: @item-hover-bg;
    }

    li&-option-selected {
      background: @time-picker-selected-bg;
      font-weight: bold;
      &:hover {
        background: @time-picker-selected-bg;
      }
    }

    li&-option-disabled {
      color: @btn-disable-color;
      &:hover {
        background: transparent;
        cursor: not-allowed;
      }
    }
  }

  &-combobox {
    .clearfix;
    height: 120px;
    margin-top: 4px;
    overflow: hidden;
  }

  &-addon {
    padding: 8px;
    border-top: @border-width-base @border-style-base @border-color-split;
  }

  &.slide-up-enter.slide-up-enter-active&-placement-topLeft,
  &.slide-up-enter.slide-up-enter-active&-placement-topRight,
  &.slide-up-appear.slide-up-appear-active&-placement-topLeft,
  &.slide-up-appear.slide-up-appear-active&-placement-topRight {
    animation-name: antSlideDownIn;
  }

  &.slide-up-enter.slide-up-enter-active&-placement-bottomLeft,
  &.slide-up-enter.slide-up-enter-active&-placement-bottomRight,
  &.slide-up-appear.slide-up-appear-active&-placement-bottomLeft,
  &.slide-up-appear.slide-up-appear-active&-placement-bottomRight {
    animation-name: antSlideUpIn;
  }

  &.slide-up-leave.slide-up-leave-active&-placement-topLeft,
  &.slide-up-leave.slide-up-leave-active&-placement-topRight {
    animation-name: antSlideDownOut;
  }

  &.slide-up-leave.slide-up-leave-active&-placement-bottomLeft,
  &.slide-up-leave.slide-up-leave-active&-placement-bottomRight {
    animation-name: antSlideUpOut;
  }
}

.@{timepicker-prefix-cls} {
  .reset-component;
  position: relative;
  display: inline-block;
  outline: none;
  transition: opacity .3s;

  &-input {
    .input;
    width: 150px;
    &[disabled] {
      .disabled;
    }
  }

  &-open {
    opacity: 0;
  }

  &-icon {
    position: absolute;
    user-select: none;
    transition: all .3s @ease-in-out;
    width: 14px;
    height: 14px;
    line-height: 14px;
    right: 10px;
    color: @disabled-color;
    top: 50%;
    margin-top: -7px;
    &:after {
      content: @icon-clock-circle-o;
      font-family: "icon";
      color: @disabled-color;
      display: block;
      line-height: 1;
    }
  }

  &-large &-input {
    .input-lg;
  }

  &-small &-input {
    .input-sm;
  }

  &-small &-icon {
    right: @control-padding-horizontal-sm - 1px;
  }

  &-selection {
    outline: none;
    user-select: none;

    box-sizing: border-box;
    display: block;

    background-color: @component-background;
    border-radius: @border-radius-base;
    border: @border-width-base @border-style-base @border-color-base;
    // strange align fix for chrome but works
    // https://gw.alipayobjects.com/zos/rmsportal/VFTfKXJuogBAXcvfAUWJ.gif
    border-top-width: @border-width-base + 0.02px;
    transition: all .3s @ease-in-out;

    &:hover {
      .hover;
    }

    .@{timepicker-prefix-cls}-focused &,
    &:focus,
    &:active {
      .active;
    }

    &__clear {
      .selection__clear();
    }

    &:hover &__clear {
      opacity: 1;
    }

    &-selected-value {
      float: left;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 100%;
      padding-right: 20px;
    }
  }

  &-selection--multiple {
    min-height: @input-height-base;
    cursor: text;
    padding-bottom: 3px;
    .clearfix;

    .@{timepicker-prefix-cls}-search--inline {
      float: left;
      position: static;
      width: auto;
      padding: 0;
      max-width: 100%;
      .@{timepicker-prefix-cls}-search__field {
        max-width: 100%;
        width: 0.75em;
      }
    }

    .@{timepicker-prefix-cls}-selection__rendered {
      margin-left: 5px;
      margin-bottom: -3px;
      height: auto;
    }

    .@{timepicker-prefix-cls}-selection__placeholder {
      margin-left: 6px;
    }

    > ul > li,
    .@{timepicker-prefix-cls}-selection__rendered > ul > li { // for tree-select
      margin-top: 3px;
      height: @input-height-base - 8px;
      line-height: @input-height-base - 8px - 2px;
    }

    .@{timepicker-prefix-cls}-selection__choice {
      color: @tag-default-color;
      background-color: @tag-default-bg;
      border: 1px solid @border-color-split;
      border-radius: @border-radius-sm;
      cursor: default;
      float: left;
      margin-right: 4px;
      max-width: 99%;
      position: relative;
      overflow: hidden;
      transition: padding .3s @ease-in-out;
      padding: 0 20px 0 10px;
      &__disabled {
        padding: 0 10px;
      }
    }

    .@{timepicker-prefix-cls}-selection__choice__content {
      display: inline-block;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 100%;
      transition: margin .3s @ease-in-out;
    }

    .@{timepicker-prefix-cls}-selection__choice__remove {
      .iconfont-mixin();
      color: @text-color-secondary;
      line-height: inherit;
      cursor: pointer;
      display: inline-block;
      font-weight: bold;
      transition: all .3s;
      font-size: @font-size-sm;
      .iconfont-size-under-12px(10px);
      position: absolute;
      right: 4px;
      &:hover {
        color: #404040;
      }
      &:before {
        content: @icon-close;
      }
    }

    .@{timepicker-prefix-cls}-selection__clear {
      top: @input-height-base / 2;
    }
  }

  &-selection__placeholder {
    position: absolute;
    top: 50%;
    left: 0;
    right: 9px;
    color: @input-placeholder-color;
    line-height: 20px;
    height: 20px;
    max-width: 100%;
    margin-top: -10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
  }

  &-selection__rendered {
    display: block;
    margin-left: @control-padding-horizontal - 1px;
    margin-right: @control-padding-horizontal - 1px;
    position: relative;
    line-height: @input-height-base - 2px;
    // https://github.com/dt-design/dt-design/issues/3481#issuecomment-254721026
    &:after {
      content: '.';
      visibility: hidden;
      pointer-events: none;
      display: inline-block;
      width: 0;
    }
  }

  &-default-ok {
    text-align: right;
    padding: 5px;
    border-top: @border-width-base @border-style-base @border-color-split;
  }
}

.@{timepicker-prefix-cls}-large {
  font-size: @font-size-lg;
  .@{timepicker-prefix-cls}-selection__rendered {
    line-height: @input-height-lg - 2px;
  }
  .@{timepicker-prefix-cls}-selection--multiple {
    min-height: @input-height-lg;
    .@{timepicker-prefix-cls}-selection__rendered {
      li {
        height: @input-height-lg - 8px;
        line-height: @input-height-lg - 8px;
      }
    }
    .@{timepicker-prefix-cls}-selection__clear {
      top: @input-height-lg / 2;
    }
  }
}

.@{timepicker-prefix-cls}-small {

  .@{timepicker-prefix-cls}-selection__rendered {
    line-height: @input-height-sm - 2px;
    margin: 0 @control-padding-horizontal-sm - 1px;
  }
  .@{timepicker-prefix-cls}-selection--multiple {
    min-height: @input-height-sm;
    .@{timepicker-prefix-cls}-selection__rendered {
      li {
        height: @input-height-sm - 8px;
        line-height: @input-height-sm - 10px;
      }
    }
    .@{timepicker-prefix-cls}-selection__clear {
      top: @input-height-sm / 2;
    }
  }
  .@{timepicker-prefix-cls}-selection__clear,
  .@{timepicker-prefix-cls}-arrow {
    right: @control-padding-horizontal-sm;
  }
}

.@{timepicker-prefix-cls}-multiple {
  width: 100%;
}
