@import '../../../../es/style/themes/default';
@import '../../../../es/style/mixins/index';
@import '../../trigger-field/style/mixin';

@date-picker-prefix: ~'@{c7n-pro-prefix}-calendar';

.@{date-picker-prefix} {
  &-picker {
    .trigger-field;

    &-popup {
      width: @date-picker-width;
      line-height: 1.5;
      background-clip: padding-box;

      &-editor {
        width: 100%;
        padding: .02rem;
        border-bottom: @border-width-base @border-style-base @border-color-base;
      }
    }

    &-suffix {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      padding: 0.05rem 0.03rem;
      cursor: pointer;

      .@{iconfont-css-prefix} {
        display: block;
      }
    }

    &-popup-datetime {
      width: @date-time-picker-width;
    }

    &-popup-hover-value .@{c7n-pro-prefix}-input,
    &-popup-hover-value-start &-range-start,
    &-popup-hover-value-end &-range-end {
      color: @gray-6;
    }
  }

  &-datetime-wrapper {
    display: flex;
    align-items: center;

    .@{date-picker-prefix}-time {
      width: 40%;
      border-left: @date-picker-datetime-time-border-left;
      
      .@{date-picker-prefix}-view-select {
        padding: 0;
      }
    }
  }
  

  &-body {
    padding: 0.08rem @date-picker-horizontal-padding;
    overflow: hidden;

    table {
      width: 100%;
      font-size: @date-picker-body-table-font-size;
    }

    th {
      width: 0.33rem;
      padding: 0.06rem 0;
      color: @date-picker-th-color;
      font-weight: normal;
      line-height: 0.18rem;
      text-align: center;
    }
  }

  &-cell {
    height: 0.3rem;
    padding: 0.03rem 0;
    text-align: center;

    &-inner {
      display: block;
      height: @date-picker-cell-inner-height;
      margin: 0 auto;
      padding: 0;
      line-height: calc(@date-picker-cell-inner-height - 2 * @border-width-base);
      text-align: center;
      background-color: transparent;
      border: @border-width-base @border-style-base transparent;
      border-radius: @date-picker-cell-inner-border-radius;
      cursor: pointer;
      transition: background @animation-duration-slow ease;

      &:hover {
        background-color: @item-hover-bg;
      }

      &:active {
        color: @date-picker-active-color;
        background-color: @primary-5;
      }
    }
  }

  &-footer &-now-selected{
    color: @text-color;
    &:hover {
      color: @date-link-hover-color;
    }
  
    &:active {
      color: @date-link-active-color;
    }
  }

  &-old &-cell-inner,
  &-new &-cell-inner {
    color: @disabled-color;
  }

  &-today &-cell-inner {
    color: @date-primary-color;
    font-weight: @date-picker-today-font-weight;
    border-color: @date-primary-color;
  }

  &-cell&-selected &-cell-inner {
    color: #fff;
    background: @date-primary-color;
    border: @border-width-base @border-style-base transparent;

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

  &-disabled &-cell-inner {
    width: auto;
    color: @disabled-color;
    background: @disabled-bg;
    border: @border-width-base @border-style-base transparent;
    border-radius: @date-picker-cell-disabled-inner-border-radius;
    cursor: not-allowed;

    &:hover {
      background: @disabled-bg;
    }
  }

  &-disabled&-today &-cell-inner {
    position: relative;

    &::before {
      position: absolute;
      top: 0.01rem;
      left: 0.01rem;
      width: 0.2rem;
      height: 0.2rem;
      border: @border-width-base @border-style-base #bcbcbc;
      border-radius: @border-radius-base;
      content: ' ';
    }
  }

  /* Time 模式 cell 层级样式控制
     用于 css vars 方案下 控制 time 部分的高亮区块 
     其中，datetime 的 time 部分的变量添加了 -datetime 字符片段
     其余直接用 -time 拼接的变量则是同时控制 datetime 的 time 部分及 TimePikcer 部分 */
  &-time {
    .@{date-picker-prefix}-body {
      padding: @date-picker-datetime-time-padding;
    }

    .@{date-picker-prefix}-cell {
      &:hover {
        background: @date-picker-time-cell-hover-bg;
      }

      &:active {
        background: @date-picker-time-cell-active-bg;
      }

      .@{date-picker-prefix}-cell-inner {
        &:hover {
          background: @date-picker-time-cell-inner-hover-bg;
        }

        &:active {
          color: @date-picker-time-cell-inner-active-color;
          background: @date-picker-time-cell-inner-active-bg;
        }
      }

      &.@{date-picker-prefix}-disabled {
        background: @date-picker-time-cell-disabled-bg;
        .@{date-picker-prefix}-cell-inner {
          color: @disabled-color;
          background: @date-picker-time-disabled-cell-inner-bg;
        }
      }

      &.@{date-picker-prefix}-selected {
        background: @date-picker-time-selected-bg;
        .@{date-picker-prefix}-cell-inner {
          color: @date-picker-time-selected-cell-inner-color;
          background: @date-picker-time-selected-cell-inner-bg;
        }
      }
    }
  }

  &-day-panel &-cell-inner {
    width: @date-picker-cell-inner-height;
  }

  &-month-panel &-cell,
  &-year-panel &-cell {
    padding: 0.2rem 0;
  }

  &-month-panel &-cell-inner,
  &-year-panel &-cell-inner {
    display: @date-picker-month-year-cell-inner-display;
    padding: 0 0.06rem;
  }

  &-time-panel &-cell-inner {
    width: .4rem;
    height: calc(@date-time-list-item-height - 0.06rem);
    line-height: calc(@date-time-list-item-height - 0.07rem);
  }

  &-header {
    height: @date-picker-header-height;
    padding: @date-picker-header-padding;
    line-height: calc(@date-picker-header-height - 2 * @border-width-base);
    text-align: center;
    border-bottom: @border-width-base @border-style-base @border-color-split;
    user-select: none;

    a:hover {
      color: @date-primary-hover-color;
    }
  }

  &-prev-year,
  &-prev-month,
  &-next-year,
  &-next-month {
    padding: 0 0.05rem;
    color: @text-color-secondary;
    font-size: 0.14rem;
    font-family: Arial, 'Hiragino Sans GB', 'Microsoft Yahei', 'Microsoft Sans Serif', sans-serif;
  }

  &-prev-year,
  &-prev-month {
    float: left;
  }

  &-next-year,
  &-next-month {
    float: right;
  }

  &-view-select {
    padding: 0 0.02rem;
    color: @text-color;
    font-weight: @date-picker-view-select-font-weight;
    line-height: 0.34rem;
  }

  &-footer-extra,
  &-footer {
    position: relative;
    height: @date-picker-footer-height;
    line-height: @date-picker-footer-height;
    text-align: center;
    border-top: @border-width-base @border-style-base @border-color-split;

    button {
      transition: all @animation-duration-slow ease-out, visibility 0s;
    }

    a {
      color: @date-primary-color;
    }
  }

  a&-now-disabled {
    color: #bcbcbc;
    cursor: not-allowed;

    &:hover {
      color: #bcbcbc;
    }
  }

  &-footer-now-btn {
    position: absolute;
    left: 0.12rem;
  }

  &-footer {
    & > &-view-select {
      position: absolute;
      top: 0.04rem;
      right: 0.12rem;
      display: inline-block;
      height: @btn-height-base;
      padding: @btn-padding-base;
      color: @btn-primary-color;
      line-height: @btn-height-base;
      text-align: center;
      vertical-align: middle;
      background-color: @btn-primary-bg;
      background-image: none;
      border: none;
      border-radius: @border-radius-base;
      outline: none;
      box-shadow: @btn-box-shadow;
      cursor: pointer;
      transition: all @animation-duration-slow ease-out;
      user-select: none;
      touch-action: manipulation;
  
      &:hover {
        color: @btn-primary-hover-color;
        background-color: @date-primary-hover-color;
      }
    }
  }

  &-week-panel {
    tbody tr {
      &:hover {
        .@{date-picker-prefix}-cell-inner {
          background-color: @item-hover-bg;
        }
      }

      &:active {
        .@{date-picker-prefix}-cell-inner {
          color: @date-picker-active-color;
          background-color: @primary-5;
        }
      }

      .@{date-picker-prefix}-selected .@{date-picker-prefix}-cell-inner {
        color: #fff;
        background-color: @date-primary-color;
      }
    }

    .@{date-picker-prefix}-cell {
      &-inner {
        border-radius: 0;
      }

      &:first-child .@{date-picker-prefix}-cell-inner {
        border-top-left-radius: @date-picker-week-edge-cell-inner-border-radius;
        border-bottom-left-radius: @date-picker-week-edge-cell-inner-border-radius;
      }

      &:last-child .@{date-picker-prefix}-cell-inner {
        border-top-right-radius: @date-picker-week-edge-cell-inner-border-radius;
        border-bottom-right-radius: @date-picker-week-edge-cell-inner-border-radius;
      }
    }
  }

  &-week-cell &-cell-inner {
    color: @disabled-color;
  }

  &-time-panel {
    height: @date-picker-time-panel-height;

    &-inner {
      position: relative;
      height: @date-time-list-item-height;
    }
  }

  &-time-list {
    position: relative;
    float: left;
    height: 100%;

    &:first-child .@{date-picker-prefix}-time-focus {
      border-right: 0;
      border-top-left-radius: @border-radius-base;
      border-bottom-left-radius: @border-radius-base;
    }

    &:nth-child(3) .@{date-picker-prefix}-time-focus {
      border-left: 0;
      border-top-right-radius: @border-radius-base;
      border-bottom-right-radius: @border-radius-base;
    }

    ul {
      position: absolute;
      top: 50%;
      z-index: 2;
      width: 100%;
      margin: 0;
      padding: 0;
      list-style: none;
      transition: top @animation-duration-slow ease;
    }

    li {
      height: @date-time-list-item-height;
      list-style: none;
    }
  }

  &-time-focus,
  &-time-focus-active {
    position: absolute;
    top: 350%;
    display: @date-picker-time-focus-active-display;
    border: @border-width-base @border-style-base @input-border-color;
  }

  &-time-focus {
    width: 100%;
    height: 100%;

    &-active {
      height: 100%;
      .active(@date-primary-color);
      border-radius: @border-radius-base;
      transition: left @animation-duration-slow ease;
    }
  }

  &-picker-popup-decade &-body {
    padding: 0.08rem;
  }
}
