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

@image-prefix-cls: ~'@{ant-prefix}-image';
@image-preview-prefix-cls: ~'@{image-prefix-cls}-preview';

.@{image-prefix-cls} {
  position: relative;
  display: inline-block;

  &-img {
    width: 100%;
    height: auto;
    vertical-align: middle;

    &-placeholder {
      background-color: @image-bg;
      background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=');
      background-repeat: no-repeat;
      background-position: center center;
      background-size: 30%;
    }
  }

  &-mask {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: @text-color-inverse;
    background: fade(@black, 20%);
    cursor: pointer;
    opacity: 0;
    transition: opacity @animation-duration-slow;

    &-info {
      padding: 0 @padding-xss;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    &:hover {
      opacity: 1;
    }

    &-operation-icon {
      font-size: 28px;
    }
  }

  &-placeholder {
    .box();
  }

  &-preview {
    .modal-mask();

    height: 100%;
    text-align: center;

    &-close {
      position: absolute;
      top: 0;
      right: 0;
      width: 40px;
      height: 40px;
      border-radius: 0 0 0 40px;
      background-color: @image-preview-close-bg;
      cursor: pointer;
      pointer-events: auto;

      &-icon {
        position: absolute;
        color: @white !important;
        top: 8px;
        right: 8px;
      }
    }

    &-body {
      .box();
      overflow: hidden;
    }

    &-img {
      max-width: 90%;
      max-height: 90%;
      vertical-align: middle;
      transform: scale3d(1, 1, 1);
      cursor: grab;
      transition: transform 0.3s @ease-out 0s;
      user-select: none;
      pointer-events: auto;

      &-wrapper {
        .box();
        transition: transform 0.3s @ease-out 0s;

        &::before {
          display: inline-block;
          width: 1px;
          height: 50%;
          margin-right: -1px;
          content: '';
        }
      }
    }

    &-moving {
      .@{image-prefix-cls}-preview-img {
        cursor: grabbing;

        &-wrapper {
          transition-duration: 0s;
        }
      }
    }

    &-wrap {
      z-index: @zindex-image;
    }

    &-operations {
      z-index: 1;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      border-radius: 3px;
      height: 40px;
      bottom: 0;
      padding: 0 20px;
      background: @image-preview-operation-background;
      color: @image-preview-operation-color;
      transition: color .3s cubic-bezier(0.4, 0, 0.2, 1);
      display: flex;
      align-items: center;
      pointer-events: auto;

      &-icon {
        height: 1em;
        width: 1em;
        line-height: 1em;
        text-align: center;
        display: inline-block;
        position: relative;
        fill: currentColor;
        transform: translateZ(0);
        cursor: pointer;
        font-size: @image-preview-operation-size;

        &:hover {
          color: @image-preview-operation-hover-color;
        }
      }

      &-group-count {
        user-select: none;
      }

      &-select {
        width: 80px;

        &.@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input) .@{ant-prefix}-select-selector {
          height: 26px;
          background-color: @image-preview-operation-background;
          border-color: @image-preview-operation-background;
          color: @image-preview-operation-color;

          .@{ant-prefix}-select-selection-search-input {
            height: 24px;
          }

          .@{ant-prefix}-select-selection-item {
            line-height: 24px;
          }
        }

        .@{ant-prefix}-select-dropdown {
          background-color: @image-preview-operation-select-dropdown-bg;
        }

        .@{ant-prefix}-select-arrow {
          color: @image-preview-operation-color;
        }

        .@{ant-prefix}-select-item {
          color: @image-preview-operation-color;
        }

        .@{ant-prefix}-select-item-option-active {
          background-color: @image-preview-operation-selected-bg;
        }

        .@{ant-prefix}-select-item-option-selected {
          color: @image-preview-operation-selected-color;
          background-color: @image-preview-operation-selected-bg;
        }
      }

      &-mr {
        margin-right: 10px;
      }

      &-margin {
        margin: 0 20px;
      }

      &-selection {
        z-index: auto;
        outline: none;
        width: 100%;
        position: relative;
      }

      &-divide {
        width: 1px;
        height: 30px;
        background: #666666;
        margin: 0 20px;
      }

      &-button, &-button:hover, &-button:focus {
        margin-left: 20px;
        width: 52px;
        height: 26px;
        font-size: 14px;
        padding: 0;
        background: rgba(0, 0, 0, 0);
        color: @white;

        &[disabled], &[disabled]:hover, &[disabled]:focus, &[disabled]:active {
          color: @E3;
          border-color: @E2;
          background: rgba(0, 0, 0, 0);
        }
      }
    }
  }
}
