@import (once) "../../include/vars";
@import (once) "../../include/mixins";

.ribbon-menu {
    display: block;
    position: relative;

    div {
        position: relative;
    }
}

.ribbon-menu {
    .tabs-holder {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        .reset-list();
        z-index: 1;
        border-bottom: 1px solid @ribbonMenuBorder;
    }

    .tabs-holder {
        li, a {
            display: block;
            height: 24px;
            line-height: 24px;
        }

        li {
            color: @dark;
            background-color: @ribbonMenuBackground;
            border-left: 1px solid transparent;
            border-right: 1px solid transparent;
            border-bottom: 1px solid @ribbonMenuBorder;

            &:hover {
                border-left-color: @ribbonMenuBorder;
                border-right-color: @ribbonMenuBorder;
            }
        }

        li + li {
            margin-left: 3px;
        }

        a {
            text-decoration: none;
            padding: 0 14px;
            font-size: 12px;
            background-color: inherit;
            color: inherit;
        }

        .active {
            background-color: @ribbonMenuActiveBackground;
            border: 1px solid @ribbonMenuBorder;
            border-bottom-color: transparent;
        }

        .static {
            background-color: @ribbonMenuStaticBackground;
            color: @white;
        }
    }
}

.ribbon-menu {
    .content-holder {
        display: block;
        position: relative;
    }

    .content-holder {
        background-color: @ribbonMenuActiveBackground;
        border-left: none;
        border-right: none;

        .section {
            display: block;
            padding: 4px 4px;
            border-bottom: 1px solid @ribbonMenuBorder;
            justify-content: flex-start;

            &.active {
                display: flex;
            }

            &.non-active {
                display: none;
            }
        }

        .group {
            padding: 0 4px 24px;
            display: flex;
            cursor: default;
            background-color: inherit;
            position: relative;
            align-items: flex-start;
            align-content: flex-start;

            &:nth-child(1):last-child {
                flex-basis: 100%;
            }

            .title {
                display: block;
                position: absolute;
                left: 0;
                bottom: 0;
                width: 100%;
                line-height: 24px;
                height: 20px;
                font-size: 11px;
                text-align: center;
                border-top: 1px solid @ribbonMenuBorder;
                white-space: nowrap;
            }

            .group-divider {
                display: block;
                position: relative;
                height: 100%;
                margin: 0 4px;
                width: 1px;
                background-color: @ribbonMenuBorder;
            }

            & > *:not(.title), & > *:not(.group-divider) {
                margin: 2px;
            }
        }

        .group + .group {
            border-left: 1px solid @ribbonMenuBorder;
        }

    }
}

.ribbon-button, .ribbon-tool-button, .ribbon-button-dropdown, .ribbon-icon-button {
    cursor: pointer;
    min-width: 0;
    text-align: center;
    border: 1px solid transparent;
    background-color: @ribbonMenuActiveBackground;
    outline: none;
    position: relative;
}

.ribbon-button {
    height: auto;
    min-height: 64px;
    width: auto;
    padding: 4px;
    margin: 0;

    .caption, .icon {
        display: block;
        text-align: center;
    }

    .caption {
        font-size: 12px;
    }

    .icon {

        * {
            height: 32px;
            max-width: 32px;
            font-size: 26px;
            line-height: 32px;
        }
    }

    .icon + .caption {
        margin-top: 8px;
    }

    &.dropdown-toggle {
        padding-right: 4px!important;
        &::before {
            margin-left: -.65rem;
        }
    }
}

.ribbon-icon-button {
    height: 24px;
    width: auto;
    margin: 0;
    display: inline-flex;
    flex-flow: row nowrap;
    align-items: center;
    padding: 0 4px;
    flex-wrap: nowrap;

    .caption, .icon {
        display: block;
    }

    .caption {
        font-size: 12px;
        white-space: nowrap;
    }

    .icon {
        display: flex;
        justify-content: center;
        align-items: center;

        * {
            width: 16px;
            height: 16px;
            line-height: 16px;
            font-size: 14px;
        }
    }

    .icon + .caption, .caption + .icon {
        margin-left: 4px;
    }

    [class*=mif-] {
        vertical-align: inherit;
    }
}

.ribbon-tool-button {
    width: 24px;
    height: 24px;
    padding: 0 2px;
    margin: 0;

    * {
        width: 16px;
        height: 16px;
        line-height: 16px;
        font-size: 14px;
    }
}

.ribbon-icon-button, .ribbon-tool-button {
    &.dropdown-toggle {
        padding-right: 2px!important;
        &::before {
            display: none;
        }
        &::after {
            content: "";
            display: block;
            position: absolute;
            bottom: 0;
            right: 0;
            width: 0;
            height: 0;
            border-style: solid;
            border-width: 0 0 4px 4px;
            border-color: transparent transparent @dark  transparent;
            z-index: 1;
        }
    }
}

.ribbon-icon-button {
    &.dropdown-toggle {
        padding-right: 4px!important;
    }
}

.ribbon-split-button {
    text-align: center;
    border: 1px solid transparent;
    padding: 0;
    margin: 0;

    &:not([disabled]):hover, &:not(.disabled):hover {
        border-color: @ribbonMenuItemBorder;

        .ribbon-split {
            border-color: @ribbonMenuItemBorder;
        }
    }

    .ribbon-main, .ribbon-split {
        display: block;
        text-align: center;
        min-width: 0;
        padding: 2px 4px;
        width: 100%;
        cursor: pointer;

        &:hover {
            background-color: @ribbonMenuItemHoverBackground;
        }
    }

    .ribbon-main {
        background-color: inherit;
        outline: none;
        position: relative;
        border: none;
    }

    .icon {
        * {
            height: 32px;
            max-width: 32px;
            font-size: 26px;
            line-height: 32px;
        }
    }

    .icon + .caption {
        margin-top: 8px;
    }

    .ribbon-split {
        font-size: 12px;
        border-top: 1px solid transparent;
        padding-bottom: 4px;

        &.dropdown-toggle {
            padding-right: 4px!important;
            &::before {
                display: none;
            }
            &::after {
                content: "";
                display: block;
                position: absolute;
                bottom: 2px;
                left: 50%;
                .translateX(-50%);
                .rotate(45deg);
                width: 0;
                height: 0;
                border-style: solid;
                border-width: 0 0 4px 4px;
                border-color: transparent transparent @dark  transparent;
                z-index: 1;
            }
        }
    }
}

.ribbon-dropdown {
    .reset-list();
    width: auto;
    float: left;
    display: block;
    position: absolute;
    background-color: @ribbonDropdownBackground;
    color: @dark;
    padding: 2px;
    border: 1px solid @ribbonMenuBorder;
    font-size: 12px;
    box-shadow: 2px 2px 2px 0 rgba(red(@ribbonDropdownShadow), green(@ribbonDropdownShadow), blue(@ribbonDropdownShadow), .7);
    z-index: @zindex-dropdown;
    top: 100%;
    left: 0;

    li, a {
        display: block;
        position: relative;
        background-color: inherit;
        color: inherit;
        height: 24px;
    }

    li {
        border: 1px solid transparent;
        padding-left: 24px;

        &:not([disabled]):hover, &:not(.disabled):hover {
            border-color: @ribbonMenuItemBorder;
            background-color: @ribbonMenuItemHoverBackground;
        }
    }

    a {
        line-height: 24px;
        text-decoration: none;
        padding: 0 8px;
        border-left: 1px solid @ribbonDropdownDivider;
        white-space: nowrap;
    }

    .divider {
        display: block;
        height: 1px;
        width: 100%;
        position: relative;
        background-color: @ribbonDropdownDivider;
    }

    .checked, .checked-one {

        &::before, &::after {
            position: absolute;
            display: block;
            content: "";
        }

        &::before {
            background-color: transparent;
            border-color: @dark;
            border-left: 2px solid;
            border-bottom: 2px solid;
            height: .325rem;
            width: .5rem;
            left: .5rem;
            top: 50%;
            .translateY(-50%);
            .rotate(-45deg);
            z-index: 2;
        }

        &::after {
            width: 23px;
            height: 22px;
            top: 0;
            left: 0;
            z-index: 1;
        }
    }

    .checked {
        &::after {
            border: 1px solid @ribbonMenuItemBorder;
            background-color: @ribbonMenuItemHoverBackground;
        }
    }

    .checked-one {
        &::before {
            width: .4rem;
            height: .4rem;
            border-radius: 50%;
            background-color: @dark;
        }
    }

    .ribbon-dropdown {
        top: -4px;
        left: 100%;
    }

    .dropdown-toggle {
        &::before {
            transform: rotate(-135deg)!important;
        }

        &.active-toggle {
            &::before {
                transform: rotate(45deg)!important;
            }
        }
    }
}

.ribbon-toggle-group {
    background-color: @light;
    display: flex;
    flex-flow: column wrap;
    max-height: 80px;
    border: 1px solid @ribbonMenuBorder;
    width: auto;

    .ribbon-icon-button {
        height: 20px;
        margin: 1px;
        background-color: inherit;

        & > * {
            height: 18px;
        }
    }
}

.ribbon-button, .ribbon-tool-button, .ribbon-icon-button {
    &:hover:enabled, &:not(.disabled):hover {
        border-color: @ribbonMenuItemBorder;
        background-color: @ribbonMenuItemHoverBackground;
    }
}

.ribbon-button, .ribbon-tool-button, .ribbon-split, .ribbon-main, .ribbon-icon-button {
    &:active, &.active {
        border-color: @ribbonMenuItemActiveBorder;
        background-color: @ribbonMenuItemActiveBackground!important;
    }
}

.ribbon-menu {
    .active-container {
        .ribbon-button, .ribbon-tool-button, .ribbon-icon-button {
            border-color: @ribbonMenuItemActiveBorder;
            background-color: @ribbonMenuItemActiveBackground!important;
        }
    }
}

// IE 10, 11
@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) {
    .ribbon-menu {
        .content-holder {
            .section {
                height: 130px;
            }
        }
    }

    .ribbon-toggle-group {
        height: 80px;
    }
}

// Edge
@supports (-ms-ime-align:auto) {
    .ribbon-menu {
        .content-holder {
            .section {
                height: 130px;
            }
        }
    }
}
