/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
@import "~@itwin/core-react/lib/cjs/core-react/z-index";
@import "../widgetopacity";
@import "variables";

.nz-widget-floatingWidget {
  position: absolute;
  border: 1px solid $buic-background-5;
  border-radius: var(--iui-border-radius-1);
  min-width: 200px;
  min-height: 120px;
  transition: opacity var(--iui-duration-2) ease;

  &.nz-floating-toolSettings {
    min-height: 60px;
  }

  @include uicore-z-index(dragged-widget);
  @include nz-widget-opacity;

  &.nz-minimized {
    flex-grow: 0;

    > .nz-content {
      width: 0;
    }
  }

  &.nz-hidden {
    opacity: 0;
    pointer-events: none;
  }

  &.nz-dragged {
    pointer-events: none;
    opacity: $nz-dragged-widget-opacity;

    @include uicore-z-index(drag-preview);
  }

  &.nz-minimized {
    min-height: 30px;

    .nz-widget-floatingWidget_handle {
      visibility: hidden;
    }
  }

  &.preview-enableMaximizedFloatingWidget-maximized {
    transform: unset !important;
    height: unset !important;
    width: unset !important;
    max-height: unset !important;
    max-width: unset !important;
    opacity: 1 !important;
    border-radius: unset !important;
    inset: 0;

    .nz-widget-floatingWidget_handle {
      visibility: hidden;
    }
  }
}

.nz-widget-floatingWidget_handle {
  $size: 0.5em;
  $cornerSize: 1em;

  position: absolute;
  user-select: none;

  &.nz-left,
  &.nz-right {
    height: 100%;
    width: $size;
    cursor: ew-resize;
  }

  &.nz-top,
  &.nz-bottom {
    width: 100%;
    height: $size;
    cursor: ns-resize;
  }

  &.nz-left {
    left: -$size * 0.5;
    top: 0;
  }

  &.nz-right {
    right: -$size * 0.5;
    top: 0;
  }

  &.nz-top {
    left: 0;
    top: -$size * 0.5;
  }

  &.nz-bottom {
    left: 0;
    bottom: -$size * 0.5;
  }

  &.nz-topLeft,
  &.nz-topRight,
  &.nz-bottomLeft,
  &.nz-bottomRight {
    height: $cornerSize;
    width: $cornerSize;
  }

  &.nz-topLeft {
    left: -$cornerSize * 0.3333;
    top: -$cornerSize * 0.3333;
    cursor: nwse-resize;
  }

  &.nz-topRight {
    right: -$cornerSize * 0.3333;
    top: -$cornerSize * 0.3333;
    cursor: nesw-resize;
  }

  &.nz-bottomLeft {
    left: -$cornerSize * 0.3333;
    bottom: -$cornerSize * 0.3333;
    cursor: nesw-resize;
  }

  &.nz-bottomRight {
    right: -$cornerSize * 0.3333;
    bottom: -$cornerSize * 0.3333;
    cursor: nwse-resize;
  }
}
