// VARIABLES

$f_z_index_flyout: 7000 !default;
$f_z_index_flyout--dropdown: 5000 !default;

$f_font_size: 0.9rem !default;
$f_font_size_tooltip: 0.8rem !default;
$f_font_size_icon: 18px !default;

$f_color_light: #fff !default;
$f_color_dark: #313941 !default;
$f_color_tooltip: #333 !default;
$f_color_border: #ddd !default;

$f_border_radius: 3px !default;

// TOOLS

.flyout-clearfix {
    &:before,
    &:after {
        content: "";
        display: table;
    }

    &:after {
        clear: both;
    }
}

// CONTAINER CLASSES

.has-flyout--fixed { // body
    background: $f_color_dark;
    position: fixed;
    overflow: hidden;
}

.has-flyout { // flyout and button container
    position: relative;
    display: inline-block;
}

// FLYOUT

.flyout {
    z-index: $f_z_index_flyout;
    position: absolute;

    box-sizing: border-box;

    padding: 1px; // to give some space to the system scrollbar

    border-radius: $f_border_radius;
    box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.075);

    text-align: left;
    font-size: $f_font_size;
    line-height: 1.4;

    // margin to bottom when the flyout is the last el on the page
    // does not apply to fixed
    // margin-bottom: 25px;

    // WRAPPER
    .flyout__wrapper {
        overflow: auto;
        overflow-x: hidden;
        height: auto;
        padding: 15px;
    }

    // THEME LIGHT
    &.flyout--light {
        background: $f_color_light;
        border: 1px solid $f_color_border; // only for outerHeight
        color: $f_color_dark;
    }

    // THEME DARK
    &.flyout--dark {
        background: $f_color_dark;
        color: $f_color_light;
    }

    // FIXED
    &.flyout--fixed {
        z-index: $f_z_index_flyout;
        position: fixed;
        left: 0;
        width: 100% !important;
        height: 100% !important;

        .flyout__wrapper {
            height: calc(100% - 45px);
            max-height: none !important;
        }
    }

    // TYPE MENU
    &.flyout--menu {
        border-radius: 0;
    }

    // TYPE TOOLTIP
    &.flyout--tooltip {
        width: 175px;
        background: $f_color_tooltip;
        color: $f_color_light;

        .flyout__wrapper {
            padding: 8px;

            p {
                margin: 0;
                font-size: $f_font_size_tooltip;
                line-height: 1.2;
            }
        }

        // ARROW
        
        &.flyout--top-right, &.flyout--top-left, &.flyout--top-middle {
            .flyout__arrow {
                border-top-color: $f_color_dark;
            }
        }

        &.flyout--right-top, &.flyout--right-bottom, &.flyout--right-middle {
            .flyout__arrow {
                border-right-color: $f_color_dark;
            }
        }

        &.flyout--bottom-right, &.flyout--bottom-left, &.flyout--bottom-middle {
            .flyout__arrow {
                border-bottom-color: $f_color_dark;
            }
        }

        &.flyout--left-top, &.flyout--left-bottom, &.flyout--left-middle {
            .flyout__arrow {
                border-left-color: $f_color_dark;
            }
        }

        .flyout__arrow {
            position: absolute;
            border: 5px solid transparent;
        }
    }

    // TYPE DROPDOWN
    &.flyout--dropdown {
        z-index: $f_z_index_flyout--dropdown;

        .flyout__wrapper {
            > ul {
                list-style: none;
                margin: 0;
                padding: 0;

                > li {
                    @extend .flyout-clearfix;

                    width: 100%;
                    margin: 0;
                    padding: 0.7rem 0;
                    border-bottom: 1px solid $f_color_border;

                    &:first-child {
                        padding-top: 0;
                    }
                    
                    &:last-child {
                        padding-bottom: 0;
                        border-bottom: none;
                    }

                    > a {
                        display: block;

                        p {
                            margin: 0;
                            color: $f_color_dark;
                        }
                    }
                }
            }
        }

        &.flyout--dropdown-has-icons-right,
        &.flyout--dropdown-has-icons-left {
            .flyout__wrapper {
                > ul > li > a {
                    position: relative;

                    > i {
                        font-size: $f_font_size_icon;

                        &:first-child,
                        &:last-child {
                            position: absolute;
                            top: 2px;
                            width: 25px;
                            text-align: center;
                        }
                    }
                }
            }
        }

        &.flyout--dropdown-has-icons-right .flyout__wrapper {
            > ul > li > a {
                padding-right: 30px;

                > i:last-child {
                    right: -5px;
                }
            }
        }

        &.flyout--dropdown-has-icons-left .flyout__wrapper {
            > ul > li > a {
                padding-left: 25px;

                > i:first-child {
                    left: -5px;
                }
            }
        }
    }
}
