/*! rtl:begin:ignore */

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

@upload-prefix-cls: ~'@{kd-prefix}-upload';
@upload-prefix-text-list-cls: ~'@{upload-prefix-cls}-text-list';
@upload-prefix-picture-list-cls: ~'@{upload-prefix-cls}-picture-list';

.@{upload-prefix-cls} {
  .reset-component;

  &-select {
    position: relative;
    display: inline-block;
    cursor: pointer;
  }

  &-drag {
    .reset-component;
    position: relative;
    cursor: pointer;
    display: flex;
    height: 80px;
    text-align: center;
    align-items: center;
    justify-content: center;
    color: @upload-text-color;
    border: 1px dashed @upload-border-color;
    background-color: @upload-background-color;
    transition: border-color @upload-transition-duration, background-color @upload-transition-duration;

    &.hover,
    &:hover,
    &:active {
      border-color: @upload-border-color-active;
      background-color: @upload-background-color-ongoing;
    }
  }

  &-input {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    opacity: 0;
    overflow: hidden;

    input[type='file'] {
      position: absolute;
      top: -20%;
      left: 0;
      width: 100%;
      height: 120%;
      font-size: 0;
      cursor: pointer;
    }
  }

  .@{upload-prefix-text-list-cls} {
    .reset-component;
    margin-top: @upload-text-list-margin-top;
    font-size: @upload-font-size;
    border-top: 1px dashed @upload-border-color-strong;

    &-item {
      position: relative;
      padding: 0 @upload-text-list-item-padding-horizontal;
      height: @upload-list-item-height;
      overflow: hidden;
      white-space: nowrap;
      display: flex;
      align-items: center;
      transition: background-color @upload-transition-duration;

      &:hover {
        background-color: @upload-background-color-hover;

        .@{upload-prefix-text-list-cls}-item-action {
          opacity: 1;
          visibility: visible;
          transform: translateX(0);
        }
      }

      &.error {
        i,
        .@{upload-prefix-text-list-cls}-item-name {
          color: @upload-text-error-color;
        }
      }

      &-icon > i {
        font-size: @upload-font-size;
      }

      &-name,
      &-icon {
        cursor: pointer;
      }

      &-name {
        display: inline-block;
        margin: 0 @upload-text-list-item-name-padding-right 0 @upload-text-list-item-name-padding-left;
        .ellipsis;
        color: @upload-panel-color;
      }

      &-size {
        color: @upload-text-color;
      }

      &-action {
        position: absolute;
        top: 0;
        right: 0;
        padding: 0 @upload-text-list-item-padding-horizontal;
        height: @upload-list-item-height;
        line-height: @upload-list-item-height;
        background: transparent;
        opacity: 0;
        visibility: hidden;
        transform: translateX(5px);
        transition: transform @upload-transition-duration;

        a {
          display: inline-block;
          vertical-align: middle;
          color: @upload-panel-button-color;

          &:not(:first-child) {
            margin-left: 20px;
          }
        }
      }
    }
  }

  .@{upload-prefix-picture-list-cls} {
    .reset-component;

    &-item {
      position: relative;
      width: 100px;
      height: 100px;
      display: inline-block;
      margin: 0 28px 28px 0;
      vertical-align: middle;
      overflow: hidden;
      border-radius: @upload-border-radius;
      border: 1px solid @upload-border-color;
      background-color: @upload-background-color;

      .@{upload-prefix-cls}-select {
        display: flex;
        position: absolute;
        top: -1px;
        right: -1px;
        bottom: -1px;
        left: -1px;
        color: @upload-text-color;
        align-items: center;
        justify-content: center;
        border: 1px dashed @upload-border-color;
        transition: all @upload-transition-duration;

        &:hover,
        &:active {
          border-color: @upload-border-color-active;
          background-color: @upload-background-color-ongoing;
        }

        .@{upload-prefix-cls}-handle {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          display: flex;
          text-align: center;
          align-items: center;
          justify-content: center;
        }
      }

      img {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        margin: auto;
        max-width: 100%;
        max-height: 100%;
      }

      &.error {
        border-color: @upload-border-error-color;
        background-color: @upload-background-error-color;
      }

      &-loading {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        > * {
          width: 80%;
        }
      }

      &-error {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        &-text {
          margin-bottom: 4px;
          color: @upload-text-error-color;
        }

        a {
          display: inline-block;
          &:not(:first-child) {
            margin-left: 10px;
          }
        }
      }

      &-action > a {
        color: @upload-panel-button-color;
        font-size: @upload-picture-action-font-size;
      }
    }
  }
}
.@{upload-prefix-cls}-rtl {
  direction: rtl;
  &.@{upload-prefix-cls} {
    .@{upload-prefix-text-list-cls} {
      &-item {
        &-name {
          margin: 0 @upload-text-list-item-name-padding-left 0 @upload-text-list-item-name-padding-right;
        }
        &-action {
          left: 0;
          right: auto;
          transform: translateX(-5px);
          a {
            &:not(:first-child) {
              margin-right: 20px;
              margin-left: 0;
            }
          }
        }
      }
    }
    .@{upload-prefix-picture-list-cls} {
      &-item {
        margin: 0 0 28px 28px;
        &-error {
          a {
            &:not(:first-child) {
              margin-right: 10px;
              margin-left: auto;
            }
          }
        }
      }
    }
  }
}
/*! rtl:end:ignore */
