// 组件允许单个组件打包，因此默认引入公共基础样式

@import "../../base.less";

@import "./_var.less";

@import "./_mixin.less";

.@{prefix}-image-viewer__img-error {
  height: 440px;
  width: 440px;
  background-color: @image-viewer__image--background-color__error;
  border-radius: 4px;
  color: @image-viewer__image-text--error;
  cursor: inherit;
  position: absolute;

  .@{prefix}-image-viewer__img-error-content {
    position: absolute;
    height: 100%;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    align-content: center;
    font: @image-viewer-error-font;

    .@{prefix}-image-viewer__img-error-text {
      margin-top: @comp-margin-s;
    }
  }
}

@keyframes modal-image-show {
  0% {
    transform: scale(0);
  }

  to {
    transform: scale(1);
  }
}

@keyframes modal-image-hide {
  0% {
    transform: scale(1);
  }

  to {
    transform: scale(0);
  }
}

@keyframes modal-mask-show {
  0% {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modal-mask-hide {
  0% {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.@{prefix}-image-viewer-preview-image {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: @z-index-image-viewer;
  overflow: hidden;
  animation: @anim-duration-base @anim-time-fn-ease-in modal-mask-show;

  &.@{prefix}-is-hide {
    animation: @anim-duration-base @anim-time-fn-ease-out modal-mask-hide;

    .@{prefix}-image-viewer__modal-pic .@{prefix}-image-viewer__modal-box {
      animation: @anim-duration-base @anim-time-fn-ease-out modal-image-hide;
    }
  }

  .@{prefix}-image-viewer__modal-index {
    text-align: center;
    font-size: @font-size-base;
    color: @text-color-anti;
    position: absolute;
    top: 92px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 40%);
    border-radius: @border-radius-default;
    padding: @image-viewer-modal-padding;
    z-index: 1;
  }

  .@{prefix}-image-viewer__modal-mask {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: @mask-active;
    height: 100%;
    width: 100%;
    transition: all @anim-duration-base ease;
    opacity: 1;
  }

  .@{prefix}-image-viewer__modal-pic {
    height: 0;
    width: 0;
    position: absolute;
    top: 50%;
    left: 50%;

    .@{prefix}-image-viewer__modal-box {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      animation: @anim-duration-base @anim-time-fn-easing modal-image-show;

      .@{prefix}-image-viewer__modal-image {
        display: block;
        max-width: min(90vw, 1000px);
        max-height: min(90vh, 800px);
        transition: all @anim-duration-base @anim-time-fn-easing;
        transform: rotate(0deg);
        object-fit: contain;
      }
    }
  }

  .@{prefix}-image-viewer__modal-header {
    width: 100%;
    position: absolute;
    top: 0;
    z-index: 1;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: @bg-color-container;
    padding: @image-viewer-header-hide-padding;

    &.@{prefix}-is-show {
      padding: @image-viewer-header-padding;
    }

    @keyframes preview-icon-range {
      0% {
        transform: translate(-50%, 50%) rotateZ(0);
      }

      to {
        transform: translate(-50%, 50%) rotateZ(-180deg);
      }
    }

    @keyframes preview-icon-unrange {
      0% {
        transform: translate(-50%, 50%) rotateZ(-180deg);
      }

      to {
        transform: translate(-50%, 50%) rotateZ(0);
      }
    }

    .@{prefix}-image-viewer__header-pre-bt {
      width: @comp-size-xxs;
      height: @comp-size-xxs;
      display: inline-flex;
      justify-content: center;
      align-items: center;
      position: absolute;
      left: 50%;
      bottom: 0;
      transform: translate(-50%, 50%);
      background-color: @bg-color-container;
      color: @text-color-primary;
      border-radius: 50%;
      box-shadow: @shadow-inset;
      animation: @anim-duration-base @anim-time-fn-easing 0s 1 normal forwards running preview-icon-unrange;

      .@{prefix}-icon {
        font-size: @font-size-l;
      }

      &:hover {
        background-color: inherit;
      }
    }

    @keyframes preview-image-show {
      0% {
        height: 0;
      }

      to {
        height: @image-viewer-header-box-height;
      }
    }

    @keyframes preview-image-hide {
      0% {
        height: @image-viewer-header-box-height;
      }

      to {
        height: 0;
      }
    }

    &.@{prefix}-is-show {
      .@{prefix}-image-viewer__header-prev {
        animation: @anim-duration-base @anim-time-fn-easing 0s 1 normal forwards running preview-image-show;
      }

      .@{prefix}-image-viewer__header-pre-bt {
        animation: @anim-duration-base @anim-time-fn-easing 0s 1 normal forwards running preview-icon-range;
      }
    }

    .@{prefix}-image-viewer__header-prev {
      width: @image-viewer-header-all-box-width;
      animation: @anim-duration-base @anim-time-fn-easing 0s 1 normal forwards running preview-image-hide;
      display: flex;
      position: relative;
      overflow: hidden;

      &::before,
      &::after {
        content: "";
        position: absolute;
        height: 100%;
        z-index: 1;
        width: @image-viewer-header-box-width;
        pointer-events: none;
      }

      &::before {
        left: 0;
        background-image: linear-gradient(to right, @bg-color-container, rgba(255, 255, 255, 0%));
      }

      &::after {
        right: 0;
        background-image: linear-gradient(to right, rgba(255, 255, 255, 0%), @bg-color-container);
      }

      .@{prefix}-image-viewer__header-trans {
        height: 100%;
        transition: transform @anim-duration-base;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: @spacer-s;
        margin-left: @image-viewer-header-box-width-margin-left;

        .@{prefix}-image-viewer__header-box {
          box-sizing: border-box;
          width: @image-viewer-header-box-width;
          height: @image-viewer-header-box-height;
          transition: @anim-duration-base;
          overflow: hidden;
          border-radius: @border-radius-default;
          display: flex;
          align-items: center;
          justify-content: center;
          border: 1px solid transparent;
          background-color: @bg-color-secondarycontainer;

          .@{prefix}-image-viewer__header-img {
            width: auto;
            height: 100%;
          }

          &:hover, &.@{prefix}-is-active {
            border-color: @brand-color;
          }
        }
      }
    }
  }

  .@{prefix}-image-viewer__modal-icon {
    cursor: pointer;
    color: @text-color-primary;
    border-radius: @border-radius-default;
    transition: @anim-duration-base;

    &.@{prefix}-image-viewer__modal-close-bt {
      top: 100px;
      right: 40px;
    }

    &.@{prefix}-image-viewer__modal-next-bt,
    &.@{prefix}-image-viewer__modal-prev-bt {
      top: 50%;
      transform: translateY(-50%);
    }

    &.@{prefix}-image-viewer__modal-prev-bt {
      left: 40px;
    }

    &.@{prefix}-image-viewer__modal-next-bt {
      right: 40px;
    }

    &.@{prefix}-image-viewer__modal-close-bt , &.@{prefix}-image-viewer__modal-prev-bt, &.@{prefix}-image-viewer__modal-next-bt {
      position: fixed;
      z-index: 10;
      color: @text-color-anti;
      background-color: rgba(0, 0, 0, 40%);
      border-radius: 50%;
      width: @image-viewer-modal-button-size;
      height: @image-viewer-modal-button-size;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .@{prefix}-image-viewer__modal-icon-label {
      margin-left: 2px;
    }

    &.@{prefix}-is-disabled {
      color: rgba(255, 255, 255, 22%);
    }

    &.@{prefix}-is-disabled:hover {
      background-color: rgba(0, 0, 0, 40%);
    }

    &:hover {
      background-color: rgba(0, 0, 0, 20%);
    }
  }
}

.@{prefix}-image-viewer__mask {
  width: 100vh;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 99;
  position: fixed;
  background-color: transparent;
}

.@{prefix}-image-viewer__utils {
  width: 100%;
  position: absolute;
  bottom: 32px;
  z-index: 1;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: @text-color-primary;
  user-select: none;

  .@{prefix}-image-viewer__utils-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    line-height: 100%;
    background: @bg-color-container;
    border-radius: @border-radius-medium;
    padding: @image-viewer-utils-content-padding;

    .@{prefix}-image-viewer__modal-icon {
      margin: @image-viewer-utils-modal-icon-margin;
      width: @image-viewer-utils-modal-icon-size;
      height: @image-viewer-utils-modal-icon-size;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: @border-radius-default;
      transition: @anim-duration-base;

      &:hover {
        background-color: @bg-color-container-hover;
      }
    }

    .@{prefix}-image-viewer__utils-scale {
      width: @image-viewer-utils-modal-utils-scale-width;
      text-align: center;
      cursor: inherit;

      &:hover {
        background-color: @bg-color-container;
      }
    }
  }
}

.@{prefix}-image-viewer-mini__footer {
  .@{prefix}-image-viewer__utils {
    position: inherit;
  }
}

.@{prefix}-image-viewer-mini__content {
  max-width: min(90vw, 1000px);
  max-height: min(90vh, 800px);

  .@{prefix}-image-viewer__modal-pic {

    @keyframes modal-image-show {
      0% {
        transform: scale(0);
      }

      to {
        transform: scale(1);
      }
    }

    .@{prefix}-image-viewer__modal-box {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;

      .@{prefix}-image-viewer__modal-image {
        display: block;
        max-width: min(80vw, 800px);
        max-height: min(80vh, 600px);
        transition: all @anim-duration-base ease;
        transform: rotate(0deg);
        object-fit: contain;
      }
    }
  }
}

.@{prefix}-image-viewer__dialog {
  &.@{prefix}-dialog__ctx--fixed {
    z-index: @z-index-image-viewer;
  }

  .@{prefix}-dialog__header {
    padding: 0 @comp-paddingLR-s;
    // 兼容dialog表头限制无法拖拽
    pointer-events: none;
    .@{prefix}-image-viewer__dialog-title {
      pointer-events: all;
    }

    .@{prefix}-dialog__close {
      pointer-events: auto;
    }
  }

  .@{prefix}-dialog {
    border-color: @component-border;
    overflow: hidden;
    padding: 0;
    box-shadow: @shadow-3;

    &__header {
      height: 40px;
      width: 100%;
      font-size: @font-size-base;
      background-color: @bg-color-secondarycontainer;

      &-content {
        margin-left: @spacer-4;
        justify-content: center;
      }
    }

    &__close:hover {
      background-color: @bg-color-secondarycontainer-hover;
    }
  }
}
