@import './theme/default';
@import './theme/font';

@mixin ellipsis {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

@mixin trigger-disabled {
  cursor: not-allowed;
}

@mixin image-item {
  border-radius: 2px;
  width: 80px;
  height: 80px;
  box-sizing: border-box;
  cursor: pointer;
}

// normal file upload
.zent-file-upload {
  @include theme-color(border-color, stroke, 5);
  border-width: 1px;
  border-style: solid;
  border-radius: 2px;
  width: 320px;

  &-tips {
    @include theme-color(color, stroke, 3);
    @include font-small;
    margin-top: 8px;
    text-align: center;
  }

  &-trigger {
    cursor: pointer;
    display: flex;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    text-decoration: none;

    &-wrapper {
      padding: 16px;
    }

    &-text {
      margin-left: 4px;

      &-count {
        @include theme-color(color, stroke, 3);
        margin-left: 4px;
      }
    }

    &-icon {
      @include theme-color(color, primary, 4);
      font-size: 18px;
    }

    &__disabled {
      @include trigger-disabled;

      .zent-file-upload-trigger-icon {
        @include theme-color(color, stroke, 4);
      }
    }
  }

  &-list {
    margin-bottom: 10px;

    &-wrapper {
      padding: 16px 16px 0;
      border-bottom-width: 1px;
      border-bottom-style: solid;
      @include theme-color(border-bottom-color, stroke, 5);
    }

    &-pagination {
      margin-bottom: 16px;

      .zent-pagination-page-list--mini {
        margin: 0;
        margin-right: -16px;
      }
    }
  }

  &-item {
    margin-bottom: 18px;

    &:last-child {
      margin-bottom: 0;
    }

    &-info {
      display: flex;
      justify-content: flex-start;
      align-items: center;
    }

    &-icon {
      width: 20px;
      height: 20px;
      font-size: 18px;
      display: flex;
      justify-content: center;
      align-items: center;

      &__type {
        @include theme-color(color, primary, 4);
      }
    }

    &-name {
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;

      &-line {
        display: inline-flex;
        width: 100%;
      }

      &-wrapper {
        flex: 1;
        margin-left: 4px;
        overflow: hidden;
      }
    }

    &-actions {
      @include theme-color(color, primary, 4);
      margin-left: 4px;

      a {
        cursor: pointer;
      }
    }

    &-progress {
      margin-top: 8px;
    }

    &-retry {
      @include theme-color(border-right-color, stroke, 5);
      border-right-width: 1px;
      border-right-style: solid;
      padding-right: 4px;
      margin-right: 4px;
    }

    &__failed {
      @include theme-color(color, error, 2);
    }

    &__uploading {
      margin-bottom: 8px;
    }
  }
}

// image upload
.zent-image-upload {
  &-tips {
    @include theme-color(color, stroke, 3);
    @include font-small;
    margin-top: 4px;
  }

  &-trigger {
    @include image-item;
    @include theme-color(background-color, stroke, 8);
    @include theme-color(color, stroke, 2);
    @include theme-color(border-color, stroke, 5);
    display: flex;
    justify-content: center;
    align-items: center;
    border-style: dashed;
    border-width: 1px;
    margin-bottom: 12px;

    &__disabled {
      @include trigger-disabled;
    }

    &-add-icon {
      font-size: 24px;
    }
  }

  &-list {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-bottom: -12px;
  }

  &-item {
    @include image-item;
    position: relative;
    margin-right: 12px;
    margin-bottom: 12px;

    &-backdrop {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;

      &__white {
        @include theme-color(background-color, stroke, 9, 0.8);
      }

      &__black {
        background-color: rgba($color-black, 0.6);
      }

      &__failed {
        @include theme-color(color, error, 2);
      }

      &__retry {
        @include theme-color(color, primary, 4);
      }

      &-text {
        margin-top: 4px;
        @include font-small;
      }
    }

    &-icon {
      font-size: 24px;
    }

    &-thumb {
      width: 100%;
      height: 100%;
      object-fit: contain;
      border-radius: 2px;
    }

    &-delete {
      @include theme-color(color, stroke, 3);
      position: absolute;
      font-size: 20px;
      right: -10px;
      top: -10px;
      display: none;

      &-bg {
        @include theme-color(background-color, stroke, 9);
        position: absolute;
        width: 10px;
        height: 10px;
        right: -5px;
        top: -5px;
        display: none;
      }
    }

    &__hover {
      .zent-image-upload-item-delete {
        display: inline-block;

        &-bg {
          display: inline-block;
        }
      }
    }
  }
}

// single upload
.zent-single-upload {
  &-tips {
    @include theme-color(color, stroke, 3);
    @include font-small;
    margin-top: 10px;
  }

  &-trigger {
    display: inline-block;
    cursor: pointer;

    &__disabled {
      @include trigger-disabled;

      .zent-file-upload-trigger-text {
        @include theme-color(color, stroke, 3);
      }
    }
  }

  &-item {
    &-info {
      display: flex;
      justify-content: flex-start;
      align-items: center;
    }

    &-icon {
      margin-right: 4px;
    }

    &-actions {
      @include theme-color(color, primary, 4);
      margin-left: 16px;

      a {
        cursor: pointer;
      }
    }

    &-retry {
      @include theme-color(border-right-color, stroke, 5);
      border-right-width: 1px;
      border-right-style: solid;
      padding-right: 4px;
      margin-right: 4px;
    }

    &__failed {
      @include theme-color(color, error, 2);
    }
  }
}

// form adaptation
.has-error {
  .zent-file-upload {
    @include theme-color(border-color, error, 4);
  }

  .zent-image-upload-trigger {
    @include theme-color(border-color, error, 4);
  }
}
