@use './variables';
@use 'sass:color';
//
// Popovers
// --------------------------------------------------

.popover {
    position: absolute;
    top: 0;
    left: 0;
    z-index: variables.$zindex-popover;
    display: none;
    padding: 1px;
    font-size: variables.$font-size-base;
    color: variables.get-color('gray');
    background-color: variables.$popover-bg;
    background-clip: padding-box;
    border: 1px solid variables.$popover-border-color;
    border-radius: 3px;

    // Offset the popover to account for the popover arrow
    &.top {
        margin-top: -#{variables.$popover-arrow-width};
    }
    &.right {
        margin-left: variables.$popover-arrow-width;
    }
    &.bottom {
        margin-top: variables.$popover-arrow-width;
    }
    &.left {
        margin-left: -#{variables.$popover-arrow-width};
    }
}

.popover-title {
    margin: 0; // reset heading margin
    padding: 8px 14px;
    font-size: variables.$font-size-base;
    background-color: variables.$popover-title-bg;
    border-bottom: 1px solid color.adjust(variables.$popover-title-bg, $lightness: -5%);
    border-radius: (variables.$border-radius-large - 1) (variables.$border-radius-large - 1) 0 0;
}

.popover-content {
    padding: 24px;

    h5,
    p,
    .close {
        color: variables.get-color('gray');
    }

    h5 {
        font-size: 16px;
        margin-bottom: 8px;
    }

    p {
        font-size: 14px;
        line-height: 17px;
    }

    .close {
        position: absolute;
        text-shadow: none;
        opacity: 1;
        font-size: 30px;
        top: 3px;
        right: 12px;
    }
}

// Arrows
// .arrow is outer, .arrow:after is inner

//overwrite default arrow border color;
.popover.popover-top.bs-popover-top > .popover-arrow.arrow {
    border-top-color: variables.$popover-border-color;
}

.popover.popover-right.bs-popover-right > .popover-arrow.arrow {
    border-right-color: variables.$popover-border-color;
}

.popover.popover-bottom.bs-popover-bottom > .popover-arrow.arrow {
    border-bottom-color: variables.$popover-border-color;
}

.popover.popover-left.bs-popover-left > .popover-arrow.arrow {
    border-left-color: variables.$popover-border-color;
}

.popover > .arrow,
.popover > .arrow:after {
    position: absolute;
    display: block;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
}

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

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

.popover.top > .arrow {
    left: 50%;
    margin-left: -#{variables.$popover-arrow-outer-width};
    border-bottom-width: 0;
    border-top-color: variables.$popover-arrow-outer-fallback-color; // IE8 fallback
    border-top-color: variables.$popover-arrow-outer-color;
    bottom: -#{variables.$popover-arrow-outer-width};

    &:after {
        content: ' ';
        bottom: 1px;
        margin-left: -#{variables.$popover-arrow-width};
        border-bottom-width: 0;
        border-top-color: variables.$popover-arrow-color;
    }
}

.popover.right > .arrow {
    top: 50%;
    left: -#{variables.$popover-arrow-outer-width};
    margin-top: -#{variables.$popover-arrow-outer-width};
    border-left-width: 0;
    border-right-color: variables.$popover-arrow-outer-fallback-color; // IE8 fallback
    border-right-color: variables.$popover-arrow-outer-color;

    &:after {
        content: ' ';
        left: 1px;
        bottom: -#{variables.$popover-arrow-width};
        border-left-width: 0;
        border-right-color: variables.$popover-arrow-color;
    }
}

.popover.bottom > .arrow {
    left: 50%;
    margin-left: -#{variables.$popover-arrow-outer-width};
    border-top-width: 0;
    border-bottom-color: variables.$popover-arrow-outer-fallback-color; // IE8 fallback
    border-bottom-color: variables.$popover-arrow-outer-color;
    top: -#{variables.$popover-arrow-outer-width};

    &:after {
        content: ' ';
        top: 1px;
        margin-left: -#{variables.$popover-arrow-width};
        border-top-width: 0;
        border-bottom-color: variables.$popover-arrow-color;
    }
}

.popover.left > .arrow {
    top: 50%;
    right: -#{variables.$popover-arrow-outer-width};
    margin-top: -#{variables.$popover-arrow-outer-width};
    border-right-width: 0;
    border-left-color: variables.$popover-arrow-outer-fallback-color; // IE8 fallback
    border-left-color: variables.$popover-arrow-outer-color;

    &:after {
        content: ' ';
        right: 1px;
        border-right-width: 0;
        border-left-color: variables.$popover-arrow-color;
        bottom: -#{variables.$popover-arrow-width};
    }
}
.popover.popover-dark {
    border: none;
    box-shadow: none;
    background: none;

    .popover-content {
        max-width: variables.$tooltip-max-width;
        padding: 16px;
        color: variables.$tooltip-color;
        background-color: variables.$tooltip-bg;
        box-shadow: 2px 2px 8px 0 variables.$tooltip-box-shadow-color;
        border-radius: variables.$border-radius-base;

        h5,
        p,
        .close {
            color: variables.$text-color;
        }
    }
    .popover-arrow {
        border-color: transparent;

        &:after {
            border-color: transparent !important;
        }
    }
    // Using very specific selectors to avoid using !important
    &.top,
    &.top-left,
    &.top-right {
        margin-top: 0;
        > .popover-arrow.arrow {
            border-top-color: variables.$tooltip-arrow-color;
            bottom: -10px;
        }
    }
    &.right > .popover-arrow.arrow {
        border-right-color: variables.$tooltip-arrow-color;
        left: -10px;
    }
    &.left > .popover-arrow.arrow {
        border-left-color: variables.$tooltip-arrow-color;
        right: -10px;
    }
    &.bottom,
    &.bottom-left,
    &.bottom-right {
        > .popover-arrow.arrow {
            border-bottom-color: variables.$tooltip-arrow-color;
            top: -10px;
        }
    }
}
