//
// Dependencies
// --------------------------------------------------

@import "global.less";
@import "icon.less";

//
// Tabs control
// - The control supports 3 basic CSS classes: master, primary and secondary.
// --------------------------------------------------

@import "tab.base.less";

@color-scroll-indicator:                     #bbbbbb;

@color-tab-border:                           #e0e0e0;
@color-tab-inactive-text:                    rgba(0,0,0,.4);
@color-tab-active-text:                      @color-text-title;
@color-tab-active-border:                    #d0d0d0;
@color-tab-bg:                               #ffffff;
@color-tab-active-marker:                    #ec8017;
@color-tab-content-active-bg:                #ffffff;
@color-tab-content-border:                   #e3e5e7;

@nav-link-padding:                          10px 15px;
@nav-link-hover-bg:                         @gray-lighter;

@nav-disabled-link-color:                   @gray-light;
@nav-disabled-link-hover-color:             @gray-light;

@nav-open-link-hover-color:                 #fff;

@nav-tabs-border-color:                     #ddd;

@nav-tabs-link-hover-border-color:          @gray-lighter;

@nav-tabs-active-link-hover-bg:             @body-bg;
@nav-tabs-active-link-hover-color:          @gray;
@nav-tabs-active-link-hover-border-color:   #ddd;

@nav-tabs-justified-link-border-color:            #ddd;
@nav-tabs-justified-active-link-border-color:     @body-bg;

@nav-pills-border-radius:                   @border-radius-base;
@nav-pills-active-link-hover-bg:            @component-active-bg;
@nav-pills-active-link-hover-color:         @component-active-color;

.control-tabs {
    position: relative;

    margin-bottom: 20px;

    &:last-child {
        margin-bottom: 0;
    }

    .horizontal-scroll-indicators(@color-scroll-indicator);

    &.scroll-active-before:before { color: @color-tab-active-border; }
    &.scroll-active-after:after { color: @color-tab-active-border; }

    &:before, &:after {
        top: 10px;
        margin-top: 0;
    }

    > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs {
        white-space: nowrap;
        font-size: 0;
        overflow: hidden;
        border-bottom: none;
        vertical-align: bottom;
        > li {
            font-size: 15px;
            float: none;
            display: inline-block;
            vertical-align: bottom;
            margin-right: 20px;
            position: relative;
            z-index: @zindex-tab - 2;

            &:last-child {
                margin-right: 0;
            }

            a {
                border-left: none!important;
                border-top: none!important;
                border-right: none!important;
                padding: 0 0 10px 0;
                color: @color-tab-inactive-text;
                background: @body-bg;
                font-weight: 400;

                overflow: hidden;

                &:hover {
                    background-color: transparent;
                    border-bottom-color: transparent;
                }

                &:before {
                    font-size: 14px;
                }

                > span.title > span {
                    max-width: 150px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    display: inline-block;
                    border-top: 2px solid @color-tab-border;
                    margin-top: -4px;
                    padding-top: 7px;
                }
            }

            span.tab-close {
                display: none;
            }

            &.active {
                z-index: @zindex-tab;

                a {
                    color: @color-tab-active-text;
                }

                &:after {
                    width: 100%;
                    height: 3px;
                    bottom: 0;
                    background: @color-tab-active-border;
                }

            }
        }
    }

    > div.tab-content {
        > div.tab-pane {
            padding: @padding-standard 0 0 0;
            display: none;
            .clearfix();

            &.active {
                display: block;

                &.layout-cell {
                   display: table-cell;
                }
            }

            &.pane-compact {
                padding: 0;
            }
            &.pane-padded {
                padding: 20px 20px 0 20px;
            }
        }
    }

    &[data-closable] {
        > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs {
            > li {
                margin-right: 5px;

                a {
                    padding-left: 20px !important;
                    padding-right: 0 !important;
                }

                span.tab-close {
                    display: block;
                    position: absolute;
                    width: 20px;
                    height: 20px;
                    top: 5px;
                    left: -5px;
                    text-align: right;
                    font-size: 12px;
                    color: @color-tab-inactive-text !important;
                    cursor: pointer;
                    i {
                        display: inline-block;
                        z-index: @zindex-tab + 1;
                        top: -7px;
                        right: 5px;
                        position: relative;
                    }
                    &:hover i {
                        color: @brand-danger;
                    }
                }

                &.active span.close {
                    color: @color-tab-inactive-text;
                }

                &[data-modified] {
                    span.tab-close i {
                        top: -4px;

                        &:before {
                            content: @circle;
                            font-size: 9px;
                        }
                    }
                }
            }
        }
    }

    //
    // Master tabs
    //

    &.master-tabs {
        > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs {
            > li {
                a {
                    font-size: 15px;
                    border-bottom: transparent 4px solid;
                    position: relative;
                    z-index: @zindex-tab + 1;
                    line-height: 100%;
                }

                &.active {
                    a { border-bottom: @color-tab-active-border 4px solid; }
                }
            }
        }
    }

    //
    // Primary tabs
    //

    &.primary-tabs {
        margin-bottom: 5px;

        > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs {
            position: relative;
            margin-left: 0;
            margin-right: 0;

            &:before {
                position: absolute;
                bottom: 0;
                height: 1px;
                width: 100%;
                z-index: @zindex-tab - 1;
                content: ' ';
                border-bottom: 2px solid @color-tab-active-border;
            }

            > li {
                padding-right: 0;
                padding-left: 0;
                margin-left: 0;
                margin-right: -20px;
                background: transparent;

                &:first-child {
                    padding-left: @padding-standard !important;
                }

                &:last-child {
                    margin-right: 0;
                }

                a {
                    font-size: @font-size-base;
                    padding-bottom: 3px;
                    margin: 0;
                    position: relative;
                    z-index: @zindex-tab + 1;
                    background: transparent;
                    overflow: visible;

                    > span.title {
                        position: relative;
                        display: inline-block;
                        padding: 4px 25px 0px 25px;
                        .box-sizing(border-box);
                        z-index: @zindex-tab;

                        &:before, &:after {
                            content: '';
                            display: block;
                            border-top: 2px solid @color-tab-border;
                            position: absolute;
                            background: @body-bg;
                            top: 0;
                            z-index: -1;
                            width: 20px;
                            bottom: -2px;
                            transform-origin: bottom;
                        }

                        &:before {
                            left: 0;
                            border-left: 2px solid @color-tab-border;
                            .border-radius(8px 0 0 0);
                            .transform( ~'skewX(-20deg)');
                        }

                        &:after {
                            right: 0;
                            border-right: 2px solid @color-tab-border;
                            .border-radius(0 8px 0 0);
                            .transform( ~'skewX(20deg)');
                        }
                    }
                }

                &:last-child {
                    background-image: none;
                    margin-right: 0;
                    padding-right: 5px;
                }

                &:first-child {
                    padding-left: 0;
                }

                &.active a {
                    z-index: @zindex-tab + 3;

                    > span.title {
                        z-index: @zindex-tab + 2;
                        border-top-color: #d6d6d6;

                        &:before, &:after{
                            border-color: @color-tab-active-border;
                        }

                        span {
                            border-top-color: @color-tab-active-border;
                        }
                    }

                    &:before {
                        position: absolute;
                        bottom: 0;
                        height: 2px;
                        right: 2px;
                        left: 2px;
                        content: ' ';
                        background-color: @body-bg;
                    }
                }
            }
        }

        > div.tab-content {
        }

        // Tab divider to sit inset the standard padding (20px)
        &.tabs-inset {
            > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs {
                margin-left: -20px;
                margin-right: -20px;
            }
        }
    }

    //
    // Secondary tabs
    //

    &.secondary-tabs {
        > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs {
            > li {
                padding-right: 10px;
                margin-right: 10px;
                border-right: 1px solid @color-tab-border;

                a {
                    font-size: 14px;
                    font-weight: bold;
                    padding-bottom: 0;
                }

                &:last-child {
                    border-right: none;
                    margin-right: 0;
                    padding-right: 0;
                }
            }
        }

        > div.tab-content {
            > div.tab-pane {
                padding-top: 15px;
            }
        }
    }

    //
    // Content tabs
    //

    &.content-tabs {

        > ul.nav-tabs {
            position: relative;

            &:before {
                content: ' ';
                position: absolute;
                bottom: 0;
                left: 0;
                width: 100%;
                height: 1px;
                background: @color-tab-content-border;
            }

            li {
                margin-right: 0;
                border-top: 1px solid @color-tab-content-border;
                border-right: 1px solid @color-tab-content-border;

                a {
                    font-size: 12px;
                    padding: 11px 20px;
                    margin: 0;
                    border: none;
                    text-transform: uppercase;
                    background: transparent;

                    span.title {
                        span {
                            border-top: none;
                        }
                    }
                }

                &:first-child {
                    border-left: 1px solid @color-tab-content-border;
                }

                &:last-child {
                    border-right: 1px solid @color-tab-content-border;
                }

                &.active {
                    background: @color-tab-content-active-bg;
                    a {
                        font-weight: 600;
                    }
                }
            }
        }

        // Tab divider to sit inset the standard padding (20px)
        &.tabs-inset {
            > ul.nav-tabs, > div > ul.nav-tabs, > div > div > ul.nav-tabs {
                margin-left: -20px;
                margin-right: -20px;
                li:first-child {
                    margin-left: 20px;
                }
            }
        }

        // Tabs to sit in by the standard offset (20px)
        &.tabs-offset {
            > ul.nav-tabs {
                li:first-child {
                    margin-left: 20px;
                }
            }
        }

        // Tabs to sit flush to the element above
        &.tabs-flush {
            > ul.nav-tabs {
                li {
                    border-top: none;
                }
                li:last-child {
                    border-right: 1px solid transparent;
                }
                li:first-child {
                    border-left: 1px solid transparent;
                }
                li.active:last-child {
                    border-right: 1px solid @color-tab-content-border;
                }
            }
        }

        > .tab-content > .tab-pane {
            padding-top: 0;

            div.list-header,
            div.padded-container,
            div.toolbar-widget {
                background: @color-tab-content-active-bg;
                padding-top: 20px;
            }

            // Pane to sit inset the standard padding (20px)
            &.pane-inset {
                margin-left: -20px;
                margin-right: -20px;
            }
        }

    }
}

&.hide-tabs {
    .control-tabs {
        ul.nav-tabs {
            display: none;
        }

        > div.tab-content > div.tab-pane {
            padding-top: 0;
        }
    }
}

.form-sidebar {
    .control-tabs.secondary {
        > div > ul.nav-tabs > li a {
            background: transparent;
        }
    }
}
