.wrapper {
  position: relative;
  overflow: visible;
  border-radius: 8px;
}

.resizing {
  user-select: none;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  background: transparent;
}

.cornerHandle {
  position: absolute;
  width: 24px;
  height: 24px;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s ease;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;

  &::before,
  &::after {
    content: "";
    position: absolute;
    border-radius: 1px;
    background-color: light-dark(
      var(--mantine-color-blue-4),
      var(--mantine-color-blue-5)
    );
    transition: background-color 0.15s ease;
  }

  &::before {
    width: 20px;
    height: 3px;
  }

  &::after {
    width: 3px;
    height: 20px;
  }

  &:hover::before,
  &:hover::after {
    background-color: light-dark(
      var(--mantine-color-blue-6),
      var(--mantine-color-blue-4)
    );
  }
}

.cornerHandleTL {
  top: -2px;
  left: -2px;
  cursor: nwse-resize;

  &::before {
    top: 0;
    left: 0;
  }

  &::after {
    top: 0;
    left: 0;
  }
}

.cornerHandleTR {
  top: -2px;
  right: -2px;
  cursor: nesw-resize;

  &::before {
    top: 0;
    right: 0;
  }

  &::after {
    top: 0;
    right: 0;
  }
}

.cornerHandleBL {
  bottom: -2px;
  left: -2px;
  cursor: nesw-resize;

  &::before {
    bottom: 0;
    left: 0;
  }

  &::after {
    bottom: 0;
    left: 0;
  }
}

.cornerHandleBR {
  bottom: -2px;
  right: -2px;
  cursor: nwse-resize;

  &::before {
    bottom: 0;
    right: 0;
  }

  &::after {
    bottom: 0;
    right: 0;
  }
}

.resizeHandleBottom {
  position: absolute;
  bottom: -4px;
  left: 20px;
  right: 20px;
  height: 12px;
  cursor: ns-resize;
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.resizeBar {
  width: 50px;
  height: 3px;
  border-radius: 2px;
  transition: background-color 0.15s ease;
  background-color: light-dark(
    var(--mantine-color-blue-4),
    var(--mantine-color-blue-5)
  );
}

.resizeHandleBottom:hover .resizeBar {
  background-color: light-dark(
    var(--mantine-color-blue-6),
    var(--mantine-color-blue-4)
  );
}

.wrapper:hover .cornerHandle,
.wrapper:hover .resizeHandleBottom,
.wrapper:global(.ProseMirror-selectednode) .cornerHandle,
.wrapper:global(.ProseMirror-selectednode) .resizeHandleBottom,
.resizing .cornerHandle,
.resizing .resizeHandleBottom {
  opacity: 1;
}

.resizing .cornerHandle::before,
.resizing .cornerHandle::after {
  background-color: light-dark(
    var(--mantine-color-blue-6),
    var(--mantine-color-blue-4)
  );
}

.resizing .resizeBar {
  background-color: light-dark(
    var(--mantine-color-blue-6),
    var(--mantine-color-blue-4)
  );
}

@media print {
  .cornerHandle,
  .resizeHandleBottom {
    display: none !important;
  }
}
