@keyframes disappear {
  to {
    opacity: 0;
  }
}

@keyframes appear {
  from {
    opacity: 0;
  }
}

.#{$ns}ImageGallery {
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  border-radius: 0;

  //Aug
  // max-width: 1010px !important;
  width: 100% !important;
  overflow: hidden;

  &-close {
    position: absolute;
    // right: 0;
    // top: 0;
    // color: rgba(255, 255, 255, 0.8);
    cursor: pointer;

    // Aug
    height: 50px;
    width: 50px;
    background-color: #4f4f4f;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 12px;
    right: 12px;
    z-index: 10;

    &:hover {
      color: #fff;
    }

    >svg {
      // Aug 16 -> 24
      width: px2rem(24px);
      height: px2rem(24px);
    }
  }

  @media screen and (max-width: 768px) {
    &-close {
      height: 24px;
      width: 24px;

      svg {
        width: 1rem;
        height: 1rem;
      }
    }
  }

  &-title {
    height: px2rem(30px);
    vertical-align: top;
    line-height: px2rem(30px);
    font-size: px2rem(12px);
    color: var(--white);
    text-align: center;
  }

  &-main {
    // background: #000; //Aug
    flex-basis: 0;
    flex-grow: 1;
    height: 0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;

    >img {
      display: block;
      max-width: 100%;
      max-height: 100%;
    }
  }

  &-prevBtn,
  &-nextBtn {
    >svg {
      width: px2rem(48px);
      height: px2rem(48px);
    }

    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    text-shadow: rgba(0, 0, 0, 0.3) 0px 0px 4px;

    &:hover {
      color: #fff;
      text-shadow: rgba(0, 0, 0, 0.5) 0px 0px 4px;
    }

    animation-name: disappear;
    animation-delay: var(--animation-duration);
    animation-duration: var(--animation-duration);
    animation-fill-mode: both;

    &.is-disabled {
      pointer-events: none;
    }
  }

  &-main:hover &-prevBtn,
  &-main:hover &-nextBtn {
    animation-name: appear;
    animation-delay: 0s;
    animation-duration: var(--animation-duration);
  }

  &-prevBtn {
    left: var(--gap-md);
  }

  &-nextBtn {
    right: var(--gap-md);
  }

  &-footer {
    height: px2rem(74px);
    background: #222;
    display: flex;
    flex-direction: row;
    user-select: none;

    position: relative; // Aug
  }

  &-prevList,
  &-nextList {
    width: var(--gap-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    background: rgba(0, 0, 0, 0.3);
    color: #fff;

    &.is-disabled {
      background: rgba(0, 0, 0, 0.3);
      color: rgba(255, 255, 255, 0.1);
      pointer-events: none;
    }

    &:hover {
      background: rgba(0, 0, 0, 1);
      color: #fff;
    }
  }

  &-itemsWrap {
    flex-grow: 1;
    flex-basis: 0;
    width: 0;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    display: flex;
  }

  &-items {
    display: inline-block;
    white-space: nowrap;
  }

  &-item {
    margin: 10px 5px;
    width: 54px;
    height: 54px;
    display: inline-flex;
    position: relative;
    border: 1px solid #666;
    justify-content: center;
    align-items: center;
    cursor: pointer;

    >img {
      display: block;
      max-width: 100%;
      max-height: 100%;
    }

    @supports (object-fit: cover) {
      >img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }

    &:after {
      position: absolute;
      content: '';
      display: block;
      background: rgba(0, 0, 0, 0.5);
      z-index: 1;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
    }

    &:hover {
      border: 1px solid #e5e5e5;

      &:after {
        display: none;
      }
    }

    &.is-active {
      border: 1px solid var(--primary);

      &:after {
        display: none;
      }
    }
  }

  // Aug
  .absoluteCenterWrapper {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 0;
    overflow: hidden;
  }
}


.preview-modal {
  bottom: 10px;

  .ant-modal-content {
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 12px 32px 0 rgba(0, 0, 0, 0.24);
    /* 阴影效果 */
    border-radius: 4px;

    .ant-modal-header {
      background-color: var(--image-gallery-modal-bg) !important;
      border-bottom: 1px solid var(--saas-border-color);

      .dialog-title {
        padding: 6px 16px !important;

        .disabled-move-title {
          font-size: 14px !important;
        }
      }
    }

    .preview-close {
      font-size: 26px;
      padding: 14px;
      background-color: #4f4f4f;
      color: white;
    }

    .ant-modal-body {
      display: flex;
      justify-content: center;
      position: relative;
      padding: 0 !important;

      .preview-body {
        position: relative;
        display: flex;
        width: 100%;
        height: 100%;
        flex-direction: column;
        overflow: hidden;



        .arrow-icon {
          position: absolute;
          z-index: 1;
          top: 40%;
          font-size: 40px;
          cursor: pointer;
          color: #ccc;
          transition: all .2s ease;

          &:hover {
            color: #fff;
            background-color: rgba(0, 0, 0, 0.3);
          }

          &.disabled {
            color: #ccc;
            cursor: not-allowed;

            .icon {
              cursor: not-allowed;
            }

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

          &.hiddel {
            display: none;
          }

          &.l {
            left: -8px;
          }

          &.r {
            right: -8px;
          }
        }

        // 表格体
        .preview-pdf-container {
          display: flex;
          align-items: center;
          justify-content: center;
          height: 100%;
          background-color: #f7f8fa;

          .ant-spin-nested-loading>div>.ant-spin {
            max-height: unset;
          }

          // overflow-y: scroll;
          &.is-pdf {
            display: block;
            // overflow-y: scroll;
            // flex-direction: column;

            .pdf-render-container {
              display: flex;
              flex: 1;
              width: 100%;

              .preview-pdf {
                width: 100%;
                flex: 1;

                // :global {
                .react-pdf__message--error {
                  width: 100%;
                  margin: 0 auto;

                  .error-txt {
                    text-align: center;
                  }
                }

                // }
              }

              .pdf-side-content {
                display: block;
                position: sticky;
                top: 0;
                // display: flex;
                // flex-direction: column;
                width: 160px;
                min-width: 160px;
                overflow-y: auto;
                border-right: 1px solid #f1f1f1;
                z-index: 1;

                .title {
                  position: sticky;
                  top: 0;
                  background-color: #f7f8fa;
                  padding-left: 10px;
                  z-index: 2;
                }

                .aside-item-container {
                  flex-direction: column;
                  padding: 10px 0;
                  // gap: 15px;
                  width: 100%;
                  box-shadow: none;

                  .aside-preview-item {
                    position: relative;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    margin-bottom: 10px;

                    &:hover,
                    &.active {
                      cursor: pointer;

                      // .preview-pdf-index
                      .preview-pdf-page {
                        background-color: rgba(0, 0, 0, 0.1);
                      }
                    }

                    .preview-pdf-index {
                      position: absolute;
                      left: 20px;
                      top: 0;
                      // background-color: #fff;
                    }
                  }

                  .preview-pdf-page {
                    display: flex;
                    justify-content: center;
                    // margin-bottom: 10px;
                    align-items: center;
                    padding: 0 10px;
                    // padding-bottom: 0;
                    width: 120px;
                    height: 90px;
                    background-color: #fff;
                    border-radius: 5px;
                    overflow: hidden;

                    .react-pdf__Page__textContent,
                    .react-pdf__Page__annotations.annotationLayer {
                      display: none;
                    }

                    .react-pdf__Page {
                      transform: scale(0.8);
                    }
                  }

                  .preview-pdf-index {
                    // margin-top: -10px;
                    // margin-bottom: 10px;
                    // width: 120px;
                    // background-color: #fff;
                    // border-radius: 0 0 5px 5px;
                    // text-align: center;
                    z-index: 1;

                  }
                }
              }

              .pdf-main-content {
                flex: 1;
                // display: flex;
                display: block;
                // flex-direction: column;
                overflow-y: auto;



                .main-item-container {
                  display: flex;
                  flex-direction: column;
                  align-items: flex-start;
                  gap: 10px;

                  >div {
                    margin: 0 auto;
                  }

                  .react-pdf__message--error {
                    display: flex;
                    align-items: center;

                    .error-txt {
                      display: flex;
                      align-items: center;
                      color: #000;
                      font-size: 18px;
                    }
                  }
                }
              }
            }

            .pdf-main-content {

              .preview-pdf-page {
                height: 100%;
                overflow: hidden;

                .react-pdf__Page {
                  .react-pdf__Page__textContent {
                    user-select: none;
                  }

                  .react-pdf__Page__annotations.annotationLayer {
                    display: none;
                  }

                  .react-pdf__Page__canvas,
                  .react-pdf__Page__svg {
                    // image-rendering: crisp-edges;
                    // image-rendering: pixelated;
                    transition: all .3s ease;
                  }
                }
              }
            }
          }

          .pdf-render-container {
            .pdf-side-content {
              display: none;
            }

            .pdf-main-content {
              display: flex;
              align-items: center;
              justify-content: center;

              .preview-pdf-page {
                height: 100%;
                overflow-x: hidden;

              }
            }
          }

          .preview-pdf,
          .preview-image {
            // box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.07);
            /* 阴影效果 */
            display: flex;
            align-items: center;
            overflow: auto;
            box-shadow: none;

            &::-webkit-scrollbar {
              display: none;
            }
          }

          .preview-pdf-page {
            height: 100%;
            overflow: auto;

            &::-webkit-scrollbar {
              display: none;
            }
          }
        }

        .preview-box-fileName {
          position: sticky;
          bottom: 40px;
          text-align: center;
          height: 20px;
          line-height: 20px;
          // background: rgba(0, 0, 0, 0.8);
          // color: #fff;
          background: var(--image-gallery-modal-bg);
          color: var(--text-color);

          &.showList {
            bottom: 104px;
          }
        }

        .preview-tools {
          box-sizing: border-box;
          position: sticky;
          bottom: 0;
          background-color: var(--image-gallery-modal-bg);
          z-index: 1;
          display: flex;
          justify-content: center;
          align-items: center;
          width: 100%;
          height: 40px;
          min-height: 40px;
          border-top: 1px solid var(--saas-border-color);

          &-item {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 0;
            margin-right: 32px;
            width: 20px;
            height: 20px;
            background: transparent !important;

            .icon {
              width: 20px;
              height: 20px;
              color: var(--saas-Title-Text);

              &.icon-download {
                height: 15px;
              }
            }

            &-index {
              position: relative;
              padding-top: 1px;
              display: block;
              margin-right: 20px;
              // min-width: 65px;
              width: auto;
              line-height: 1.5;
              font-weight: 500;
              font-size: 16px;
              color: var(--saas-Title-Text);
            }

            &.checked {
              .icon {
                color: #2a87eb;
              }
            }

            &.disabled {
              .icon {
                color: #dbdbdb;
                cursor: not-allowed;
              }
            }
          }
        }

        .preview-scroll-container {
          // width: 100%;
          // height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          // overflow: hidden;

          .file-preview-handler {
            cursor: move;
            transition: all .1s ease;
            user-select: none;
            .ant-image-error {
              // 图片破裂的时候，不配置高度
              height: auto !important;
            }
          }
        }

        .ant-image-img {
          object-fit: contain;
          width: auto;
          max-width: 100%;
          max-height: 100%;
        }

        .mediaShowList {
          position: sticky;
          bottom: 40px;
          height: initial;
          // min-height: 88px;
          min-height: 64px;
          // background-color: rgba(0, 0, 0, 0.8);
          background-color: var(--image-gallery-modal-bg);
          border-top: 1px solid #f1f1f1;

          .imgList-arrow {
            color: #666;
          }
        }


      }

      .frame-container {
        // overflow: hidden;

        // iframe {
        //   margin-top: -20px;
        // }
        &::after {
          content: '加载中...';
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          z-index: 0;
        }
        iframe {
          position: sticky;
          z-index: 1;
        }
        body {
          .button-area {
            display: none;
          }
        }
      }
    }
  }
}

.mb-images-preview {
  z-index: 9999;
}

.mb-pdf-preview {
  height: 100vh;
  width: 100vw;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: white;

  .react-transform-wrapper {
    flex: 1;
  }

  &-header {
    background-color: white;
    color: black;
    width: 100%;
  }

  &-doc {
    overflow: hidden;
    flex: 1;
  }

  &-page {
    margin-top: 8px;

    &:first-child {
      margin-top: 0;
    }
  }
}