
@import "../../mixins/_reset-text.less";
@import "../../mixins/_shadows-helper.less";

/**
 * Popovers - Popover overlay component
 *
 * Note: Uses @popover-* variables for most dimensions and @size-* tokens for positioning.
 *
 * Intentionally hardcoded values:
 * - Component-specific dimensions (140px, 341px): Popover specific positioning and widths
 * - Typography size (16px): Title font size
 * - Border widths (1px): Standard borders
 * - Percentages (50%, 100%): Layout and centering
 * - Z-index values: Stacking order
 * - Calc expressions: Complex computed values with @popover-* variables
 */

.popover {
  position: absolute;
  top: 0;
  left: 0;
  z-index: @zindex-popover;
  display: none;
  padding: 1px; // Our parent element can be arbitrary since popovers are by default inserted as a sibling of their target element.
  max-width: @popover-max-width;
  border: 1px solid @popover-border-color;
  border-radius: @popover-border-radius;
  background-color: @popover-background-default;
  background-clip: padding-box;
  color: @popover-color-default;
  font-size: @font-size-base; // To reset our font and text properties and avoid inheriting weird values.
  .reset-text();

  &.high-popover {
    z-index: @zindex-popover + 2;
  }

  &.top {
    margin-bottom: @popover-arrow-width;
    .boxShadowHelper(md, top);
  }

  &.right {
    margin-left: @popover-arrow-width;
    .boxShadowHelper(md, right);
  }

  &.bottom {
    margin-top: @popover-arrow-width;
    .boxShadowHelper(md);
  }

  &.left {
    margin-right: @popover-arrow-width;
    .boxShadowHelper(md, left);
  }
}

.popover-title {
  margin: 0; // reset heading margin
  padding: @popover-padding @popover-padding 0;
  border-radius: calc(@popover-border-radius - 1px) calc(@popover-border-radius - 1px) 0 0;
  background-color: @popover-background-default; //color: @gray-50; //border-bottom: 1px solid darken(@popover-background-default, 5%);
  font-weight: 500;
  font-size: 16px;
}

.popover-content {
  padding: @popover-padding;
  word-break: break-word;
  overflow-wrap: break-word;
  &:has(.popover-footer) {
    padding-bottom: 0;
  }
}

.popover-footer {
  padding: @popover-padding 0;
}

.popover-title + .popover-content {
  padding-top: calc(@popover-padding / 2);
}

// Arrows
// .arrow is outer, .arrow:after is inner
.popover > .arrow {
  &,
  &:after {
    position: absolute;
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-color: transparent;
  }
}

.popover > .arrow {
  border-width: @popover-arrow-outer-width;
}

.popover > .arrow:after {
  border-width: @popover-arrow-width;
  content: '';
}

.popover {
  &.top > .arrow {
    bottom: calc(@popover-arrow-outer-width * -1);
    left: 50%;
    border-top-color: @popover-border-color;
    border-bottom-width: 0;

    &:after {
      bottom: 1px;
      margin-left: calc(@popover-arrow-width * -1);
      border-top-color: @popover-background-default;
      border-bottom-width: 0;
      content: ' ';
    }
  }

  &.right > .arrow {
    top: 50%;
    left: calc(@popover-arrow-outer-width * -1);
    border-right-color: @popover-border-color;
    border-left-width: 0;

    &:after {
      bottom: calc(@popover-arrow-width * -1);
      left: 1px;
      border-right-color: @popover-background-default;
      border-left-width: 0;
      content: ' ';
    }
  }

  &.bottom > .arrow {
    top: calc(@popover-arrow-outer-width * -1);
    left: 50%;
    border-top-width: 0;
    border-bottom-color: @popover-border-color;

    &:after {
      top: 1px;
      margin-left: calc(@popover-arrow-width * -1);
      border-top-width: 0;
      border-bottom-color: @popover-background-default;
      content: ' ';
    }
  }

  &.left > .arrow {
    top: 50%;
    right: calc(@popover-arrow-outer-width * -1);
    border-right-width: 0;
    border-left-color: @popover-border-color;

    &:after {
      right: 1px;
      bottom: calc(@popover-arrow-width * -1);
      border-right-width: 0;
      border-left-color: @popover-background-default;
      content: ' ';
    }
  }
}

.popover.navigator-popover {
  max-width: 341px !important;
}

c8y-popover-confirm .right {
  right: @size-20 !important;
}

.popover.lns-connection-popover {
  top: @size-10 !important;
  left: 140px !important;
}
