/* afaik popover needs a positioning context to be able to calculate the transform */
.PopoverContainer {
  position: absolute;
  z-index: 4;
}

.PopoverBody {
  pointer-events: auto;
  min-width: 1em; /* ewwwwwwww */
  display: flex;
  flex-direction: column;
  /* add a max-width so that long strings don't cause the popover to expand
   * see metabase#4930 */
  max-width: 500px;
}

.PopoverBody.PopoverBody--withBackground {
  border: 1px solid #edf2f5;
  box-shadow: 0 4px 10px var(--color-shadow);
  background-color: var(--color-bg-white);
  border-radius: 6px;
  overflow: auto;
}

.tippy-box,
.tippy-content {
  max-height: inherit;
  transition: transform 0s, visibility 0.3s, opacity 0.3s;
}

.tippy-box[data-theme~="tooltip"] {
  color: white;
  font-weight: bold;
  background-color: var(--color-bg-black);
  border: none;
  pointer-events: none;
  line-height: 1.26;
  font-size: 12px;
  border-radius: 6px;
  box-shadow: 0 4px 10px var(--color-shadow);
}

.tippy-box[data-theme~="tooltip"] .tippy-content {
  padding: 10px 12px;
}

.tippy-box[data-theme~="popover"] {
  font-size: inherit;
  background-color: var(--color-bg-white);
  color: var(--color-text-default);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 10px var(--color-shadow);
  background-color: var(--color-bg-white);
  border-radius: 6px;
  overflow: auto;
}

.tippy-box[data-theme~="popover"] .tippy-content {
  padding: 0;
}

/* remove the max-width in cases where the popover content needs to expand
 * initially added  for date pickers so the dual date picker can fully
 * expand as necessary - metabase#5971
 */
.PopoverBody.PopoverBody--autoWidth {
  max-width: none;
}

.PopoverBody.PopoverBody--tooltip {
  color: white;
  font-weight: bold;
  background-color: var(--color-bg-black);
  border: none;
  pointer-events: none;
  line-height: 1.26;
  padding: 10px 12px;
}
.PopoverBody.PopoverBody--tooltip.PopoverBody--tooltipConstrainedWidth {
  font-size: 12px;
  max-width: 200px;
}

/* shared arrow styles */
.PopoverBody--withArrow:before,
.PopoverBody--withArrow:after {
  position: absolute;
  content: "";
  display: block;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  pointer-events: none;
}

/* As Popover footer uses absolute positioning
 * to stick to bottom, options lists and other
 * middle content need extra margin-bottom
 */
.PopoverBody--marginBottom {
  margin-bottom: 60px;
}

.PopoverBody .Form-input {
  font-size: 1rem;
}

.PopoverBody .Form-field {
  margin-bottom: 0.75rem;
}

.PopoverHeader {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  min-width: 400px;
}

.PopoverHeader-item {
  flex: 1;
  position: relative;
  top: 1px; /* to overlap bottom border */
  text-align: center;
  padding: 1em;

  text-transform: uppercase;
  font-size: 0.8em;
  font-weight: 700;
  color: var(--color-text-medium);
  border-bottom: 2px solid transparent;
}

.PopoverHeader-item.selected {
  color: currentcolor;
  border-color: currentcolor;
}

.PopoverHeader-item--withArrow {
  margin-right: 8px;
}

.PopoverHeader-item--withArrow:before,
.PopoverHeader-item--withArrow:after {
  position: absolute;
  content: "";
  display: block;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  top: 50%;
  margin-top: -8px;
}

/* create a slightly larger arrow on the right for border purposes */
.PopoverHeader-item--withArrow:before {
  right: -16px;
  border-left-color: var(--color-border);
}

/* create a smaller inset arrow on the right */
.PopoverHeader-item--withArrow:after {
  right: -15px;
  border-left-color: var(--color-bg-white);
}

.PopoverFooter {
  background: white;
  position: absolute;
  bottom: 0;
  border-top: 1px solid var(--color-border);
  border-bottom-right-radius: 6px;
  border-bottom-left-radius: 6px;
  padding-top: 8px;
  width: calc(100% - 2px);
  /* Without z-index; calendar days, if selected, scroll above this component */
  z-index: 1;
}

.PopoverBody--withBackground .PopoverFooterWhenIsNotEqualOps,
.popover .PopoverFooterWhenIsNotEqualOps {
  bottom: 0;
  padding-bottom: 12px;
  padding-top: 10px;
  width: calc(100% - 26px);
}

.PopoverParameterFieldWidgetFooter {
  position: fixed;
  bottom: -7px;
}

/* create a slightly larger arrow on the top for border purposes */
.tether-element-attached-top .PopoverBody--withArrow:before {
  top: -20px;
  border-bottom-color: var(--color-border);
}
.tether-element-attached-top .PopoverBody--tooltip:before {
  border-bottom: none;
}

/* create a smaller inset arrow on the top */
.tether-element-attached-top .PopoverBody--withArrow:after {
  top: -18px;
  border-bottom-color: var(--color-bg-white);
}
.tether-element-attached-top .PopoverBody--tooltip:after {
  border-bottom-color: var(--color-bg-black);
}

/* create a slightly larger arrow on the bottom for border purposes */
.tether-element-attached-bottom .PopoverBody--withArrow:before {
  bottom: -20px;
  border-top-color: var(--color-border);
}
.tether-element-attached-bottom .PopoverBody--tooltip:before {
  border-top: none;
}

/* create a smaller inset arrow on the bottom */
.tether-element-attached-bottom .PopoverBody--withArrow:after {
  bottom: -18px;
  border-top-color: var(--color-bg-white);
}
.tether-element-attached-bottom .PopoverBody--tooltip:after {
  border-top-color: var(--color-bg-black);
}

/* if the tether element is attached right, move our arrows right */
.tether-target-attached-right .PopoverBody--withArrow:before,
.tether-target-attached-right .PopoverBody--withArrow:after {
  right: 12px;
}

/* if the tether element is attached center, move our arrows to the center */
.tether-element-attached-center .PopoverBody--withArrow:before,
.tether-element-attached-center .PopoverBody--withArrow:after {
  margin-left: 50%;
  left: -10px;
}

.tether-element-attached-right .PopoverBody--withArrow:before,
.tether-element-attached-right .PopoverBody--withArrow:after {
  right: 12px;
}

.tether-element-attached-left .PopoverBody--withArrow:before,
.tether-element-attached-left .PopoverBody--withArrow:after {
  left: 12px;
}

#popover-event-target {
  position: fixed;
  width: 6px;
  height: 6px;
  pointer-events: none;
}

/* transition classes */

.Popover-appear,
.Popover-enter {
  opacity: 0.01;
}

.Popover-appear.Popover-appear-active,
.Popover-enter.Popover-enter-active {
  opacity: 1;
  transition: opacity 100ms ease-in;
}

.Popover-leave {
  opacity: 1;
}

.Popover-leave.Popover-leave-active {
  opacity: 0.01;
  transition: opacity 100ms ease-in;
}
