@import '../../../../lib/style/themes/default';
@import '../../../../lib/style/mixins/index';
@import '../../../../lib/trigger/style/mixin';

@pro-attachment-prefix-cls: ~'@{c7n-pro-prefix}-attachment';

.@{pro-attachment-prefix-cls} {
  &-list-wrapper {
    display: flex;
    flex: 1;
    flex-direction: column;
    max-width: 100%;

    .@{c7n-pro-prefix}-select-wrapper {
      margin: @attachment-sort-select-margin;
      border: @attachment-sort-selcet-border;
    }

    .@{pro-attachment-prefix-cls}-list-no-card {
      .@{c7n-pro-prefix}-picture {
        // Picture 模式
        margin: @attachment-picture-margin;
        // Text 模式
        &.@{pro-attachment-prefix-cls}-list-item-icon {
          margin: @attachment-text-picture-icon-margin;
        }
      }
    }
  }

  &-header {
    display: flex;
    align-items: center;

    &-divider {
      width: .01rem;
      height: @attachment-header-divider-height;
      margin: 0 .07rem;
      background-color: @border-color-base;
    }

    &-buttons {
      flex: 1;
      white-space: nowrap;

      .@{c7n-pro-prefix}-btn {
        height: @btn-height-sm;
      }
    }
  }

  &-list {
    flex: 1;
    padding: .01rem 0;
    overflow: auto;

    &-item {
      margin: @attachment-list-item-margin;
      padding: @attachment-list-item-padding;
      background-color: @attachment-list-item-bg;
      border: @attachment-list-item-border;

      &-container {
        position: relative;
        padding: @attachment-list-item-container-padding;
      }

      &-content,
      &-title,
      &-error-content {
        display: flex;
        align-items: center;
      }

      &-title,
      &-error-message {
        flex: 1;
        padding: 0 .1rem;
        overflow: hidden;
        white-space: nowrap;
      }

      & &-icon {
        width: .14rem;
        height: .14rem;

        .@{iconfont-css-prefix} {
          display: block;
          font-size: .14rem;
          line-height: 1;
        }
      }

      &-name {
        flex-basis: auto;
        flex-grow: 0;
        flex-shrink: 1;
      }

      &-link {
        display: flex;
        overflow: hidden;
        color: inherit;
        white-space: nowrap;

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

      &-name,
      &-error-message {
        overflow: hidden;
        text-overflow: ellipsis;
      }

      &-size {
        margin-left: .02rem;
        color: @text-color-secondary;
      }

      &-buttons {
        display: flex;
        opacity: 0;
        transition: opacity @animation-duration-slow;

        .@{c7n-pro-prefix}-btn {
          width: .18rem;
          height: .18rem;
          line-height: .18rem;

          .@{iconfont-css-prefix} {
            display: block;
            font-size: .14rem;
            line-height: 1;
          }
        }

        .@{c7n-prefix}-progress-loading {
          display: block;
        }
      }

      &-progress {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        display: block;
        width: auto;

        .@{c7n-prefix}-progress {
          &-outer,
          &-inner {
            display: block;
          }

          &-inner {
            background-color: #d8d8d8;
          }

          &-bg {
            background-image: linear-gradient(90deg, #f3f3f3 2%, @primary-color 100%);
          }
        }
      }

      &-placeholder {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: @text-color-dark;
        font-size: .32rem;
        background-color: rgba(0, 0, 0, .65);
      }

      &-drag-icon {
        margin-right: .08rem;
        color: rgba(0, 0, 0, .45);
        cursor: move;
      }

      &-buttons-visible,
      &:hover &-buttons {
        opacity: 1;
      }
    }

    &-card {
      display: flex;
      flex-wrap: wrap;
      margin-top: .15rem;
    }

    &-card &-item {
      display: inline-block;
      margin-top: 0;
      margin-right: .08rem;
      margin-bottom: .08rem;
      padding: 0;
      text-align: center;
      background-color: transparent;

      &-container {
        padding: 0;
        overflow: hidden;
        background-color: #f8f8f8;
        border-radius: @border-radius-base;
      }

      &-title {
        justify-content: center;
      }

      &-buttons {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1;
        display: flex;
        align-items: center;
        background-color: rgba(0, 0, 0, .65);
        border-radius: @border-radius-base;

        .@{c7n-pro-prefix}-btn {
          flex: 1;
          height: .3rem;
          color: @text-color-dark;

          .@{iconfont-css-prefix} {
            font-size: .14rem;
            line-height: .3rem;
          }

          & + .@{c7n-pro-prefix}-btn {
            margin-left: 0;
            border-left: @border-width-base @border-style-base rgba(255, 255, 255, .65);
            border-radius: 0;
          }
        }

        .@{c7n-prefix}-progress-loading circle {
          stroke: @text-color-dark;
        }
      }

      &-error-content {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        padding: .1rem .05rem;
      }
    }

    &-no-card &-item-error &-item-name,
    &-no-card &-item-error &-item-ext,
    &-no-card &-item-error &-item-size,
    &-item-error-content {
      color: @error-color;
    }
  }

  &-list &-card-button {
    line-height: @attachment-card-button-line-height;
    background-color: @attachment-card-button-bg;
    border: @attachment-card-button-border;
    border-radius: @border-radius-base;

    .@{iconfont-css-prefix} {
      margin: @attachment-card-button-icon-margin;
      font-size: @attachment-card-button-icon-size;
    }

    &.@{c7n-pro-prefix}-btn-disabled,
    .@{iconfont-css-prefix} {
      color: rgba(0, 0, 0, .25);
    }
  }

  &-order {
    &-icon {
      &::before {
        display: block;
        width: .16rem;
        height: .16rem;
        background-image: linear-gradient(90deg, @text-color 0, @text-color 100%),
        linear-gradient(90deg, @text-color 0, @text-color 100%),
        linear-gradient(90deg, @text-color 0, @text-color 100%),
        linear-gradient(to bottom right, transparent 50%, @primary-color 50%),
        linear-gradient(to bottom left, transparent 50%, @primary-color 50%),
        linear-gradient(0deg, @primary-color 0, @primary-color 100%);
        background-repeat: no-repeat;
        background-position: .01rem .05rem, .01rem .08rem, .01rem .11rem, .08rem .04rem, .11rem .04rem, .1rem .08rem;
        background-size: .05rem .02rem, .06rem .02rem, .07rem .02rem, .04rem .04rem, .04rem .04rem, .03rem .05rem;
        content: '';
      }

      &.desc::before {
        background-image: linear-gradient(90deg, @text-color 0, @text-color 100%),
        linear-gradient(90deg, @text-color 0, @text-color 100%),
        linear-gradient(90deg, @text-color 0, @text-color 100%),
        linear-gradient(to top right, transparent 50%, @primary-color 50%),
        linear-gradient(to top left, transparent 50%, @primary-color 50%),
        linear-gradient(0deg, @primary-color 0, @primary-color 100%);
        background-position: .01rem .05rem, .01rem .08rem, .01rem .11rem, .08rem .09rem, .11rem .09rem, .1rem .05rem;
      }
    }
  }

  &-validation-message {
    padding: .04rem 0;
  }

  &-empty {
    padding: .04rem 0;
    text-align: center;
  }

  &-required::after {
    display: inline-block;
    width: 0.08rem;
    margin-left: 0.04rem;
    color: @label-required-color;
    font-family: @font-family-required-symbol;
    line-height: 1;
    vertical-align: middle;
    content: '*';
  }

  &.@{c7n-pro-prefix}-field {
    width: auto;
  }

  .@{c7n-pro-prefix}-field-help {
    margin-top: .04rem;
  }

  .@{c7n-pro-prefix}-form-horizontal &-list-wrapper {
    *:first-child.@{c7n-pro-prefix}-field-help {
      line-height: @label-line-height;
    }

    *:first-child.@{pro-attachment-prefix-cls}-list-card {
      margin-top: 0.08rem;
    }
  }

  .trigger;

  &-popup-inner {
    display: flex;
  }

  &-popup-inner &-header {
    padding: 0 .15rem;
    border-bottom: @border-width-base @border-style-base @border-color-base;

    &-label {
      padding: .1rem 0;
    }
  }

  &-popup &-list-card {
    padding-left: .08rem;
  }

  &-popup &-list-item {
    background-color: transparent;
  }

  &-popup &-group,
  &-popup-inner {
    min-width: 3rem;
    max-width: @dropdown-menu-max-width;
    max-height: @dropdown-menu-max-height;
  }

  &-popup &-group {
    overflow: auto;
  }

  &-group &-header-label {
    color: @text-color-secondary;
  }

  &-popup &-group &-header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: .05rem .1rem 0 .1rem;
    background-color: @component-background;
  }

  &-drag {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    background: #FFF;
    border: @border-width-base dashed @border-color-base;
    border-radius: @border-radius-base;
    cursor: pointer;
    transition: border-color @animation-duration-slow;

    &-hover:not(.@{pro-attachment-prefix-cls}-disabled) {
      border: 0.01rem dashed @primary-8;
    }

    &-disabled {
      cursor: not-allowed;
    }

    .@{pro-attachment-prefix-cls}-btn {
      height: 100%;
    }

    .@{pro-attachment-prefix-cls}-drag-container {
      display: table-cell;
      width: 5rem;
      height: 2rem;
      vertical-align: middle;
    }

    &:not(.@{pro-attachment-prefix-cls}-disabled):not(.@{pro-attachment-prefix-cls}-drag-disabled):hover {
      border-color: @primary-5;
    }

    &-box {
      padding: 0.16rem 0;

      &-icon {
        .@{iconfont-css-prefix} {
          color: @primary-5;
          font-size: 0.18rem;
        }

        margin-bottom: 0.09rem;
      }

      &-text {
        margin: @attachment-drag-box-text-margin;
        color: @heading-color;
        font-weight: 400;
        font-size: @font-size-sm;
        line-height: 0.2rem;
      }

      &-hint {
        margin: @attachment-drag-box-hint-margin;
        color: @text-color-secondary;
        font-size: @font-size-sm;
      }
    }
  }

  &-drag-hover {
    background-color: @background-color-light;
  }
}
