@import url(../var.less);
@import "progress.less";
@import url(../mixins/mixins.less);
@import url(../mixins/utils.less);

@upload-prefix: ~"@{prefix}upload";
@upload-prefix-dragger: ~"@{prefix}upload-dragger";
@upload-prefix-list: ~"@{prefix}upload-list";
@upload-prefix-cover: ~"@{prefix}upload-cover";

.@{upload-prefix}{

  display: inline-block;
  text-align: center;
  cursor: pointer;
  outline: none;
  &__input{
    display: none;
  }
  &__tip{
    font-size: 12px;
    color: @upload-font-color;
    margin-top: 7px;
  }
  iframe {
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    opacity: 0;
    filter: alpha(opacity=0);
  }



  /* 照片墙模式 */
  &--picture-card{
    background-color: #F4F4F5;
    border: 1px dashed #DDDFE8;
    border-radius: 6px;
    box-sizing: border-box;
    width: 110px;
    height: 110px;
    cursor: pointer;
    line-height: 108px;
    vertical-align: top;

    i {
      font-size: 24px;
      color: #000;
    }



    &:hover {
      border-color: @upload-primary-color;
      color: @upload-primary-color;
    }
  }

  &:focus {
    border-color: @upload-primary-color;
    color: @upload-primary-color;

    .w-upload-dragger {
      border-color: @upload-primary-color;
    }
  }
}

.@{upload-prefix-dragger}{
  background-color: #F4F4F5;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  box-sizing: border-box;
  width: 720px;
  height: 235px;
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;

  .w-icon-upload-line {
    font-size: 67px;
    color: @primary-color;
    margin: 60px 0 16px;
    line-height: 50px;
  }

  + .w-upload__tip {
    text-align: center;
  }

  ~ .w-upload__files {
    border-top: @upload-border-base;
    margin-top: 7px;
    padding-top: 5px;
  }

  .w-upload__text {
    color: @upload-font-color;
    font-size: 16px;
    margin-bottom: 12px;
    text-align: center;

    em {
      color: @upload-primary-color;
      font-style: normal;
    }
  }
  .w-upload-hint{
    color: #00000073;
    font-size: 14px;
  }

  &:hover {
    border-color: @upload-primary-color;
  }
  &.is-dragover{
    background-color: rgba(32, 159, 255, .06);
    border: 2px dashed @upload-primary-color;
  }

}
.@{upload-prefix-list}{
  margin: 0;
  padding: 0;
  list-style: none;

  &__default{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    span{
      line-height: 1;
      margin-top: 15px;
      font-size: 14px;
      color: @primary-text-color;
    }
  }

  &__item{
    transition: all .5s cubic-bezier(.55,0,.1,1);
    font-size: 14px;
    color: @upload-font-color;
    line-height: 32px;
    margin-top: 5px;
    position: relative;
    box-sizing: border-box;
    border-radius: 4px;
    width: 100%;

    .w-progress {
      position: absolute;
      top: 20px;
      width: 100%;
    }

    .w-progress__text {
      position: absolute;
      right: 0;
      top: -13px;
    }

    .w-progress-bar {
      margin-right: 0;
      padding-right: 0;
    }

    &:first-child {
      margin-top: 10px;
    }

    & .w-icon-upload-success {
      color: @upload-success-color;
    }

    .w-icon-close {
      display: none;
      position: absolute;
      //top: 10px;
      top: 50%;
      margin-top: -7px;
      right: 5px;
      cursor: pointer;
      opacity: .75;
      color: @upload-font-color;
      //transform: scale(.7);

      &:hover {
        opacity: 1;
      }
    }

    & .w-icon-close-tip {
      display: none;
      position: absolute;
      top: 10px;
      right: 5px;
      font-size: 12px;
      cursor: pointer;
      opacity: 1;
      color: @upload-primary-color;
    }
    
    &:hover {
      background-color: @upload-background-color-base;

      .w-icon-close {
        display: inline-block;
        &:before{
          content: "\e634";
        }

      }

      .w-progress__text {
        display: none;
      }
    }

    &.is-success{
      .e-upload-list__item-status-label {
        display: block;
      }

      .w-upload-list__item-name:hover, .w-upload-list__item-name:focus {
        color: @upload-primary-color;
        cursor: pointer;
      }

      &:focus:not(:hover) {  /* 键盘focus */
        .w-icon-close-tip {
          display: inline-block;
        }
      }

      &:not(.focusing):focus, &:active { /* click时 */
        outline-width: 0;
        .w-icon-close-tip {
          display: none;
        }
      }

      &:hover, &:focus {
        .w-upload-list__item-status-label {
          display: none;
        }
      }
    }
    &.is-ready{
      .w-upload-list__item-name{
        color: @info-color;
        [class^="w-icon"] {
          color: @info-color;
        }
      }
      .e-upload-list__item-status-label {
        display: block;
      }

      .w-upload-list__item-name:hover, .w-upload-list__item-name:focus {
        color: @info-color;
        cursor: pointer;
      }

      &:focus:not(:hover) {  /* 键盘focus */
        .w-icon-close-tip {
          display: inline-block;
        }
      }

      &:not(.focusing):focus, &:active { /* click时 */
        outline-width: 0;
        .w-icon-close-tip {
          display: none;
        }
      }

      &:hover, &:focus {
        .w-upload-list__item-status-label {
          display: none;
        }
      }
    }
    
    &.is-fail{
      .w-upload-list__item-name{
        color: @danger-color;
        [class^="w-icon"] {
          color: @danger-color;
        }
      }
      .w-icon-close{
        color: @danger-color;
      }
      .e-upload-list__item-status-label {
        display: block;
      }

      .w-upload-list__item-name:hover, .w-upload-list__item-name:focus {
        color: @danger-color;
        cursor: pointer;
      }

      &:focus:not(:hover) {  /* 键盘focus */
        .w-icon-close-tip {
          display: inline-block;
        }
      }

      &:not(.focusing):focus, &:active { /* click时 */
        outline-width: 0;
        .w-icon-close-tip {
          display: none;
        }
      }

      &:hover, &:focus {
        .w-upload-list__item-status-label {
          display: none;
        }
      }
    }
    
  }


  &.is-disabled{
    .w-upload-list__item:hover .w-upload-list__item-status-label {
      display: block;
    }
  }

  &__item-name{
    color: @primary-color;
    display: block;
    margin-right: 40px;
    overflow: hidden;
    padding-left: 4px;
    text-overflow: ellipsis;
    transition: color .3s;
    white-space: nowrap;

    [class^="w-icon"] {
      height: 100%;
      margin-right: 7px;
      color: @primary-text-color;
      line-height: inherit;
    }
    .w-icon-close {
      color: @primary-color;
    }
  }

  &__item-status-label{
    position: absolute;
    right: 5px;
    top: 0;
    line-height: inherit;
    display: none;
  }
  &__item-delete{
    position: absolute;
    right: 10px;
    top: 0;
    font-size: 12px;
    color: @upload-font-color;
    display: none;

    &:hover {
      color: @upload-primary-color;
    }
  }
  &--picture-card{
    margin: 0;
    display: inline;
    vertical-align: top;

    .w-upload-list__item {
      overflow: hidden;
      background-color: #fff;
      border: 1px solid #DDDFE8;
      border-radius: 6px;
      box-sizing: border-box;
      width: 148px;
      height: 148px;
      margin: 0 8px 8px 0;
      display: inline-block;

      border-radius: 2px;
      padding: 10px;
      width: 110px;
      height: 110px;
      background: #F4F4F5;
      border: 1px solid #DDDFE8;

      .w-icon-check,
      .w-icon-circle-check {
        color: @color-white;
      }

      .w-icon-close {
        display: none;
      }
      &:hover {
        .w-upload-list__item-status-label {
          display: none;
        }
        .w-progress__text {
          display: block;
        }
      }
    }
    //新增
    .is-fail{
      border-color: @danger-color;
      .w-upload-list__item-thumbnail{
        display: none;
      }
      .w-upload-list__item-name-fail{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        height: 100%;
        i{
          margin-bottom: 8px;
          font-size: 32px;
          color: @danger-color;
        }
        span{
          color: @danger-color;
          font-size: 13px;
        }
      }
    }

    .w-upload-list__item-name {
      display: none;
    }

    .w-upload-list__item-thumbnail {
      width: 100%;
      height: 100%;
    }

    .w-upload-list__item-status-label {
      position: absolute;
      right: -15px;
      top: -6px;
      width: 40px;
      height: 24px;
      background: #13ce66;
      text-align: center;
      transform: rotate(45deg);
      box-shadow: 0 0 1pc 1px rgba(0,0,0,0.2);

      i {
        font-size: 12px;
        margin-top: 11px;
        transform: rotate(-45deg);
      }
    }

    .w-upload-list__item-actions {
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      cursor: default;
      text-align: center;
      color: #fff;
      opacity: 0;
      font-size: 20px;
      background-color: rgba(0, 0, 0, .5);
      transition: opacity .3s;
      &::after {
        display: inline-block;
        content: "";
        height: 100%;
        vertical-align: middle
      }

      span {
        display: none;
        cursor: pointer;
      }

      span + span {
        margin-left: 15px;
      }

      .w-upload-list__item-delete {
        position: static;
        font-size: inherit;
        color: inherit;
      }

      &:hover {
        opacity: 1;
        span {
          display: inline-block;
        }
      }
    }

    .w-progress {
      top: 60%;
      left: 50%;
      transform: translate(-50%, -50%);
      bottom: auto;
      width: 84px;
      .w-progress-outer{
        padding-right: 0;
        margin-right: 0;
      }
      .w-progress-text{
        position: absolute;
        top: 0px;
        left: 0;
        top: -10px;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 45px;
        padding-left: 0;
        margin-left: 0;
        color: @primary-text-color;
      }


    }
  }


  &--picture{
    .w-icon-close{
      font-size: 16px;
      right: 15px;
    }
    .w-upload-list__item {
      overflow: hidden;
      z-index: 0;
      background-color: #fff;
      border: 1px solid #DDDFE8;
      border-radius: 2px;
      box-sizing: border-box;
      margin-top: 10px;
      padding: 6px 6px 6px 74px;
      height: 68px;

      .w-icon-check,
      .w-icon-circle-check {
        color: @color-white;
      }

      &:hover {
        .w-upload-list__item-status-label {
          background: transparent;
          box-shadow: none;
          top: -2px;
          right: -12px;
        }

        .w-progress__text {
          display: block;
        }
      }

      &.is-success {
        .w-upload-list__item-name {
          line-height: 54px;
          margin-top: 0;
          i {
            display: none;
          }
        }
      }
      &.is-ready{
        .w-upload-list__item-name {
          height: 54px;
          line-height: 54px;
          i{
            display: none;
          }
        }
      }
      &.is-fail{
        border-color: @danger-color;
        .w-upload-list__item-thumbnail{
          display: none;
        }
        .w-upload-list__item-name{
          line-height: 54px;
          
          color: @danger-color;
          [class^="w-icon"] {
            color: @danger-color;
          }
          i{
            font-size: 32px;
            position: absolute;
            display: inline-block;
            height: 0;
            margin-right: 0;
            left: 20px;
          }
        }
        .w-icon-close{
          color: @danger-color;
        }
        .e-upload-list__item-status-label {
          display: block;
        }
  
        .w-upload-list__item-name:hover, .w-upload-list__item-name:focus {
          color: @danger-color;
          cursor: pointer;
        }
  
        &:focus:not(:hover) {  /* 键盘focus */
          .w-icon-close-tip {
            display: inline-block;
          }
        }
  
        &:not(.focusing):focus, &:active { /* click时 */
          outline-width: 0;
          .w-icon-close-tip {
            display: none;
          }
        }
  
        &:hover, &:focus {

          .w-upload-list__item-status-label {
            display: none;
          }
        }
      }
      &.is-uploading{
        .w-upload-list__item-name{
          line-height: 54px;
          i{
            font-size: 32px;
            position: absolute;
            display: inline-block;
            height: 0;
            margin-right: 0;
            left: 20px;
          }
        }
      }
    }

    .w-upload-list__item-thumbnail {
      vertical-align: middle;
      display: inline-block;
      width: 54px;
      height: 54px;
      float: left;
      position: relative;
      z-index: 1;
      margin-left: -68px;
      background-color: @color-white
    }

    .w-upload-list__item-status-label {
      position: absolute;
      right: -17px;
      top: -7px;
      width: 46px;
      height: 26px;
      background: #13ce66;
      text-align: center;
      transform: rotate(45deg);
      box-shadow: 0 1px 1px #ccc;

      i {
        font-size: 12px;
        margin-top: 12px;
        transform: rotate(-45deg);
      }
    }

    .w-progress {
      position: relative;
      top: -32px;
    }
  }

}
.@{upload-prefix-cover}{
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 10;
  cursor: default;
  .utils-vertical-center();

  img {
    display: block;
    width: 100%;
    height: 100%;
  }
  &__label{
    position: absolute;
    right: -15px;
    top: -6px;
    width: 40px;
    height: 24px;
    background: #13ce66;
    text-align: center;
    transform: rotate(45deg);
    box-shadow: 0 0 1pc 1px rgba(0,0,0,0.2);

    i {
      font-size: 12px;
      margin-top: 11px;
      transform: rotate(-45deg);
      color: #fff;
    }
  }
 
  &__progress{
    display: inline-block;
    vertical-align: middle;
    position: static;
    width: 243px;

    + .w-upload__inner {
      opacity: 0;
    }
  }
  
  &__content{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
  &__interact{
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(#000, .72);
    text-align: center;

    .btn {
      display: inline-block;
      color: @color-white;
      font-size: 14px;
      cursor: pointer;
      vertical-align: middle;
      transition: @upload-md-fade-transition;
      margin-top: 60px;

      i {
        margin-top: 0;
      }

      span {
        opacity: 0;
        transition: opacity .15s linear;
      }

      &:not(:first-child) {
        margin-left: 35px;
      }

      &:hover {
        transform: translateY(-13px);

        span {
          opacity: 1;
        }
      }

      i {
        color: @color-white;
        display: block;
        font-size: 24px;
        line-height: inherit;
        margin: 0 auto 5px;
      }
    }
  }

  &__title{
    position: absolute;
    bottom: 0;
    left: 0;
    background-color: @color-white;
    height: 36px;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: normal;
    text-align: left;
    padding: 0 10px;
    margin: 0;
    line-height: 36px;
    font-size: 14px;
    color: @upload-primary-text-color;
  }


  + .w-upload__inner {
    opacity: 0;
    position: relative;
    z-index: 1;
  }
}