@import '../../style/themes/index';
@import '../../style/mixins/index';
@import '../../input/style/mixin';

@yee-timepicker-prefix-cls: ~'@{yee-prefix}-time-picker';
@yee-timepicker-item-height: 32px;

.@{yee-timepicker-prefix-cls}-panel {
  .yee-reset-component;

  position: absolute;
  z-index: @yee-zindex-picker;
  font-family: @yee-font-family;

  &-inner {
    position: relative;
    left: -2px;
    font-size: @yee-font-size-base;
    text-align: left;
    list-style: none;
    background-color: @yee-component-background;
    background-clip: padding-box;
    border-radius: @yee-border-radius-base;
    outline: none;
    box-shadow: @yee-box-shadow-base;
  }

  &-input {
    width: 100%;
    max-width: @yee-time-picker-panel-column-width * 3 - @yee-control-padding-horizontal - 2px;
    margin: 0;
    padding: 0;
    line-height: normal;
    border: 0;
    outline: 0;
    cursor: auto;

    .yee-placeholder;

    &-wrap {
      position: relative;
      padding: 7px 2px 7px @yee-control-padding-horizontal;
      border-bottom: @yee-border-width-base @yee-border-style-base @yee-border-color-split;
    }

    &-invalid {
      border-color: @yee-error-color;
    }
  }

  &-narrow &-input-wrap {
    max-width: @yee-time-picker-panel-column-width * 2;
  }

  &-select {
    position: relative; // Fix chrome weird render bug
    float: left;
    width: @yee-time-picker-panel-column-width;
    max-height: @yee-timepicker-item-height * 6;
    overflow: hidden;
    font-size: @yee-font-size-base;
    border-left: @yee-border-width-base @yee-border-style-base @yee-border-color-split;

    &:hover {
      overflow-y: auto;
    }

    &:first-child {
      margin-left: 0;
      border-left: 0;
    }

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

    &:only-child {
      width: 100%;
    }

    ul {
      // use fixed width instead of 100%
      // to fix strange render bug in safari: https://github.com/ant-design/ant-design/issues/17842
      width: @yee-time-picker-panel-column-width;
      margin: 0;
      padding: 0 0 @yee-timepicker-item-height * 5;
      list-style: none;
    }

    li {
      width: 100%;
      height: @yee-timepicker-item-height;
      margin: 0;
      padding: 0 0 0 @yee-control-padding-horizontal;
      line-height: @yee-timepicker-item-height;
      text-align: left;
      list-style: none;
      cursor: pointer;
      transition: all 0.3s;
      user-select: none;

      &:focus {
        color: @yee-primary-color;
        font-weight: 600;
        outline: none;
      }
    }

    li:hover {
      background: @yee-item-hover-bg;
    }

    li&-option-selected {
      font-weight: 600;
      background: @yee-time-picker-selected-bg;
      &:hover {
        background: @yee-time-picker-selected-bg;
      }
    }

    li&-option-disabled {
      color: @yee-btn-disable-color;
      &:hover {
        background: transparent;
        cursor: not-allowed;
      }
      &:focus {
        color: @yee-btn-disable-color;
        font-weight: inherit;
      }
    }
  }

  &-combobox {
    .yee-clearfix;
  }

  &-addon {
    padding: 8px;
    border-top: @yee-border-width-base @yee-border-style-base @yee-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;
  }
}

.@{yee-timepicker-prefix-cls} {
  .yee-reset-component;

  position: relative;
  display: inline-block;
  width: 128px;
  outline: none;
  cursor: text;
  transition: opacity 0.3s;

  &-input {
    .yee-input;
    &[disabled] {
      .yee-disabled;
    }
  }

  &-open {
    opacity: 0;
  }

  &-icon,
  &-clear {
    position: absolute;
    top: 50%;
    right: @yee-control-padding-horizontal - 1px;
    z-index: 1;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    color: @yee-disabled-color;
    line-height: 14px;
    transition: all 0.3s @yee-ease-in-out;
    user-select: none;
    .@{yee-timepicker-prefix-cls}-clock-icon {
      display: block;
      color: @yee-disabled-color;
      line-height: 1;
    }
  }

  &-clear {
    z-index: 2;
    background: @yee-input-bg;
    opacity: 0;
    pointer-events: none;
    &:hover {
      color: @yee-text-color-secondary;
    }
  }
  &:hover &-clear {
    opacity: 1;
    pointer-events: auto;
  }

  &-large &-input {
    .yee-input-lg;
  }

  &-small &-input {
    .yee-input-sm;
  }

  &-small &-icon,
  &-small &-clear {
    right: @yee-control-padding-horizontal-sm - 1px;
  }
}

// Fix cursor height in safari
// https://stackoverflow.com/q/3843408/3040605
// https://browserstrangeness.github.io/css_hacks.html#safari
@media not all and (min-resolution: 0.001dpcm) {
  @supports (-webkit-appearance: none) and (stroke-color: transparent) {
    .@{yee-prefix}-input {
      line-height: @yee-line-height-base;
    }
  }
}
