/* ------------------------------------------------------------------------------
*
*  # Navs related component
*
*  Overrides for navs related bootstrap component
*
*  Version: 1.3
*  Latest update: Aug 10, 2016
*
* ---------------------------------------------------------------------------- */


// Basic styles
// -------------------------

.nav {

    // Nav items
    > li {
        > a {

            // Remove outline on focus
            &:focus {
                outline: 0;
            }
        }

        // Disabled state sets text to gray and nukes hover/tab effects
        &.disabled > a {

            // Mute elements
            > .badge,
            > .label,
            > .status-mark,
            > img {
                .opacity(0.75);
            }
        }
    }

    // Open dropdowns
    .open > a {
        &,
        &:hover,
        &:focus {
            background-color: transparent;
            border-color: transparent;
            color: @gray-dark;
        }
    }

    // Optional sizing
    &.nav-lg > li > a {
        padding: @nav-link-padding-large;
    }
    &.nav-sm > li > a {
        padding: @nav-link-padding-small;
    }
    &.nav-xs > li > a {
        padding: @nav-link-padding-mini;
    }

    // Tabs nav image
    .tab-img {
        max-height: @line-height-computed;
        display: inline-block;
        vertical-align: top;
    }
}



// Tabs
// -------------------------

// Base styles
.nav-tabs {
    margin-bottom: @line-height-computed;

    // Tabs list item
    > li {
        float: none;

        // Actual tabs (as links)
        > a {
            margin-right: 0;
            color: @color-grey-300;
            border-radius: 0;
            text-transform: uppercase;

            // Hover/focus states
            &:hover,
            &:focus {
                background-color: transparent;
                border-color: transparent;
                color: @text-color;
            }

            // Ripple fix
            &.legitRipple {
                margin-bottom: -1px;
            }

            // Right aligned icons
            > [class*=icon-].pull-right {
                float: right;
                margin-top: ((@line-height-computed - @icon-font-size) / 2);
            }
        }
    }


    //
    // Tab layouts
    //

    // Justified tabs
    // Needs to be dublicated. Sadly.
    &.nav-justified {
        .nav-tabs-justified();
    }


    // Tabs with highlighted top border
    &.nav-tabs-highlight {
        @media (min-width: @screen-sm-min) {
            > li {

                // Change border radius and top border width
                > a {
                    &,
                    &:hover,
                    &:focus {
                        border-top-width: 2px;
                    }
                }

                // Apply top border color. Replace it with any variable or color
                &.active > a {
                    &,
                    &:hover,
                    &:focus {
                        border-top-color: @color-pink-400;
                    }
                }
            }
        }
    }


    // Tabs with top border
    &.nav-tabs-top {
        @media (min-width: @screen-sm-min) {

            // List items
            > li {
                margin-bottom: 0; // Remove bottom spacing

                // Change border radius and top border width
                > a {
                    &,
                    &:hover,
                    &:focus {
                        border: 0;
                    }

                    // Top highlight line
                    &:after {
                        content: '';
                        position: absolute;
                        top: 0;
                        left: 0;
                        right: 0;
                        height: 2px;
                    }
                }

                // Add top border on hover
                &.open > a,
                > a:hover,
                > a:focus {
                    &:after {
                        background-color: @nav-tabs-border-color;
                    }
                }

                // Apply top border color. Replace it with any variable or color
                &.active > a {

                    // Highlight background color
                    &:after {
                        background-color: @color-pink-300;
                    }

                    // States
                    &,
                    &:hover,
                    &:focus {
                        background-color: transparent;
                    }
                }
            }

            // Without bottom border
            &.top-divided {
                border-bottom-color: transparent;
            }
        }
    }


    // Tabs with bottom border
    &.nav-tabs-bottom {
        @media (min-width: @screen-sm-min) {

            // Tab nav item
            > li {
                margin-bottom: 0;

                // Link
                > a {
                    border-width: 0;
                    margin-bottom: -1px;

                    // Bottom highlight
                    &:after {
                        content: '';
                        position: absolute;
                        bottom: 0;
                        left: 0;
                        right: 0;
                        height: 2px;
                    }
                }

                // Apply bottom border color and change width. Replace color with any variable or color
                &.active > a {

                    // Highlight background color
                    &:after {
                        background-color: @color-pink-300;
                    }

                    // States
                    &,
                    &:hover,
                    &:focus {
                        background-color: transparent;
                        border-width: 0;
                    }
                }
            }

            // Without bottom border
            &.bottom-divided {
                border-bottom-color: transparent;
            }
        }
    }


    // Tabs with custom solid background
    &[class*=bg-] {
        border-bottom: 0;

        // Add common styles for all bg color variations
        > li {
            margin-bottom: 0;

            // Link
            > a {
                color: #fff;
                border-width: 0;

                // Hover state
                &:hover,
                &:focus {
                    background-color: fade(#000, 5%);
                }
            }

            // Opened dropdown menu
            &.open:not(.active) > a {
                color: #fff;
                background-color: fade(#000, 5%);
            }
        }

        // Apply permanent darker color for active item
        > .active > a {
            &,
            &:hover,
            &:focus {
                background-color: fade(#000, 10%);
                border-width: 0;
                color: #fff;
            }
        }

        // Mute disabled links
        > .disabled > a {
            &,
            &:hover,
            &:focus {
                color: fade(#fff, 50%);
            }
        }

        // Setup desktop view
        @media (min-width: @screen-sm-min) {
            .box-shadow(@shadow-depth1);

            // Bordered content
            .tab-content-bordered & {
                .border-bottom-radius(0);
            }
        }
    }


    // Tabs with solid background
    &.nav-tabs-solid {
        @media (min-width: @screen-sm-min) {
            background-color: darken(@body-bg, 10%);
            border: 0;
            .box-shadow(@shadow-depth1);

            // Inside panels
            .panel & {
                background-color: @nav-tabs-solid-bg;
            }

            // Add border radius
            > li {
                margin-bottom: 0;

                // Link styles
                > a {
                    border-width: 0;

                    // Bottom highlight
                    &:after {
                        content: '';
                        position: absolute;
                        bottom: 0;
                        left: 0;
                        right: 0;
                        height: 2px;
                    }

                    // Hover state
                    &:hover,
                    &:focus {
                        background-color: @nav-tabs-solid-hover-bg;
                    }
                }
            }

            // Apply background color to active tab. Replace it with any variable or color
            > .active > a,
            > .active > a:hover,
            > .active > a:focus {
                background-color: transparent;
                border-width: 0;

                // Highlight color
                &:after {
                    background-color: @color-pink-300;
                }
            }

            // Style dropdown link
            > .open:not(.active) > a {
                background-color: @nav-tabs-solid-hover-bg;
            }

            // Rounded
            &.nav-tabs-component {
                > li:first-child > a:after {
                    border-radius: 0 0 0 @border-radius-base;
                }

                &.nav-justified > li:last-child > a:after {
                    border-radius: 0 0 @border-radius-base 0;
                }
            }
        }
    }


    // Tabs with top icon
    &.nav-tabs-icon {
        > li > a > i {
            margin-right: @element-horizontal-spacing;
        }

        // Desktop view
        @media (min-width: @screen-sm-min) {

            // Links
            > li > a {
                padding-bottom: (@line-height-computed - (@padding-base-vertical * 1.5));

                // Icon
                > i {
                    display: block;
                    margin: 0 0 @padding-base-vertical;
                }
            }

            // Sizes
            &.nav-lg > li > a {
                padding-bottom: (@line-height-computed-large - (@padding-base-vertical * 1.5));

                > i {
                    margin-bottom: @padding-large-vertical;
                }
            }
            &.nav-sm > li > a {
                padding-bottom: (@line-height-computed-small - (@padding-base-vertical * 1.5));

                > i {
                    margin-bottom: @padding-small-vertical;
                }
            }
            &.nav-xs > li > a {
                padding-bottom: (@line-height-computed-mini - (@padding-base-vertical * 1.5));

                > i {
                    margin-bottom: @padding-xs-vertical;
                }
            }
        }
    }


    // Setup desktop view
    @media (min-width: @screen-sm-min) {
        font-size: 0;

        // Menu items
        > li {
            display: inline-block;
            font-size: @font-size-base;
        }
    }


    // Setup mobile view
    @media (max-width: @screen-xs-max) {
        border-bottom: 0;
        position: relative;
        background-color: #fff;
        padding: @list-spacing 0;
        border-radius: @border-radius-base;
        .box-shadow(@shadow-depth1);

        // Tab nav item
        > li {
            margin-bottom: 0;

            // Add permanent link styles
            > a {
                border-width: 0 0 0 2px;
                border-left-color: transparent;

                // Hover state
                &:hover,
                &:focus {
                    background-color: @nav-tabs-mobile-link-hover-bg;
                }

                // Stick right elements to the right side
                .position-right {
                    &[class*=icon-] {
                        float: right;
                        margin-top: ((@line-height-computed - @icon-font-size) / 2);
                    }

                    // Labels/badges
                    &.label,
                    &.badge {
                        float: right;
                    }
                }
            }

            // Left border and bg colors for active link
            &.active > a {
                &,
                &:hover,
                &:focus {
                    border-width: 0 0 0 2px;
                    border-left-color: @color-pink-400;
                    background-color: @nav-tabs-mobile-link-active-bg;
                }
            }

            // Dublicate left border for dropdown link
            &.open:not(.active) > a {
                &,
                &:hover,
                &:focus {
                    background-color: @nav-tabs-mobile-link-hover-bg;
                }
            }

            // Make all left aligned
            &.pull-right {
                float: none!important;
            }
        }

        // Add text header to the tabs section
        &:before {
            content: 'Contents';
            color: inherit;
            margin-top: (@content-padding-base - @list-spacing);
            margin-left: @padding-base-horizontal;
            margin-bottom: @content-padding-base;
            .opacity(0.5);
        }

        // Remove left border for solid and custom tabs
        &[class*=bg-] {
            > li > a {
                border-left-width: 0!important;
            }
        }

        // Tabs with solid background
        &[class*=bg-] {
            > li {
                > a:hover,
                > a:focus,
                &.open:not(.active) > a {
                    background-color: fade(#000, 5%);
                }
            }
        }

        // Vertical tabs
        .nav-tabs-right & {
            margin-bottom: 0;
            margin-top: @line-height-computed;
        }
    }
}



// Vertical tabs
// -------------------------

@media (min-width: @screen-sm-min) {

    // Base
    .nav-tabs-vertical {
        display: table;
        width: 100%;

        // Tabs base
        > .nav-tabs {
            display: table-cell;
            border-bottom: 0;
            width: 300px;

            // Tabs nav item
            > li {
                display: block;
                margin-bottom: 0;
            }
        }

        // Solid and custom colored tabs
        > .nav-tabs-solid > li:last-child > a:after {
            .border-bottom-radius(@border-radius-base);
        }
        > .nav-tabs[class*=bg-] {
            > li:first-child > a {
                .border-top-radius(@border-radius-base);
            }

            > li:last-child > a {
                .border-bottom-radius(@border-radius-base);
            }
        }

        // Tab content
        > .tab-content {
            display: table-cell;

            // With padding
            > .has-padding {
                padding: 0;
                padding-top: (@padding-base-vertical * 1.5);
            }
        }

        // Bordered tab content
        &.tab-content-bordered > .tab-content {
            border-top-width: 1px;
        }
    }

    // Left tabs
    .nav-tabs-left {

        // Basic tabs
        > .nav-tabs {
            border-right: 1px solid @nav-tabs-border-color;

            // Items
            > li {
                margin-right: -1px;

                // Active links
                &.active > a,
                &.active > a:hover,
                &.active > a:focus {
                    border-bottom-color: @nav-tabs-border-color;
                    border-right-color: transparent;
                }
            }

            // Tabs component
            &.nav-tabs-component > li > a {
                border-radius: @border-radius-base 0 0 @border-radius-base;
            }
        }

        // Highlighted tabs
        > .nav-tabs-highlight {
            > li > a {
                &,
                &:hover,
                &:focus {
                    border-top-width: 1px;
                    border-left-width: 2px;
                }
            }

            // Active tabs item
            > li.active > a,
            > li.active > a:hover,
            > li.active > a:focus {
                border-top-color: @nav-tabs-border-color;
                border-left-color: @color-pink-400;
            }
        }

        // With top border
        > .nav-tabs-top,
        > .nav-tabs-bottom {
            padding-right: @grid-gutter-width;
        }

        // Divided tabs
        > .top-divided,
        > .bottom-divided {
            padding-right: 0;
            border-right-width: 0;
        }

        // Solid and custom colored tabs
        > .nav-tabs-solid,
        > .nav-tabs[class*=bg-] {
            border-right: 0;
            border-radius: @border-radius-base;

            > li {
                margin-right: 0;
            }
        }

        // Tab content
        > .tab-content {
            padding-left: @grid-gutter-width;
        }

        // Bordered tab content
        &.tab-content-bordered > .tab-content {
            border-left-width: 0;
        }
    }

    // Right tabs
    .nav-tabs-right {

        // Basic tabs
        > .nav-tabs {
            border-left: 1px solid @nav-tabs-border-color;

            // Nav items
            > li {
                margin-left: -1px;

                // Active tab
                &.active > a,
                &.active > a:hover,
                &.active > a:focus {
                    border-bottom-color: @nav-tabs-border-color;
                    border-left-color: transparent;
                }
            }

            // Tabs component
            &.nav-tabs-component > li > a {
                border-radius: 0 @border-radius-base @border-radius-base 0;
            }
        }

        // Highlighted tabs
        > .nav-tabs-highlight {
            > li > a {
                &,
                &:hover,
                &:focus {
                    border-top-width: 1px;
                    border-right-width: 2px;
                }
            }

            // Active tabs
            > li.active > a,
            > li.active > a:hover,
            > li.active > a:focus {
                border-top-color: @nav-tabs-border-color;
                border-right-color: @color-pink-400;
            }
        }

        // With top border
        > .nav-tabs-top,
        > .nav-tabs-bottom {
            padding-left: @grid-gutter-width;
        }

        // Divided tabs
        > .top-divided,
        > .bottom-divided {
            padding-left: 0;
            border-left-width: 0;
        }

        // Solid and custom colored tabs
        > .nav-tabs-solid,
        > .nav-tabs[class*=bg-] {
            border-left: 0;
            border-radius: @border-radius-base;

            > li {
                margin-left: 0;
            }
        }

        // Tab content
        > .tab-content {
            padding-right: @grid-gutter-width;
        }

        // Bordered tab content
        &.tab-content-bordered > .tab-content {
            border-right-width: 0;
        }
    }
}



// Pills
// -------------------------

// Base
.nav-pills {
    margin-bottom: @line-height-computed;

    // Pill item
    > li {
        float: none;

        // Links rendered as pills
        > a {
            color: @gray-dark;
            text-transform: uppercase;
        }

        // Inline links
        & + li {
            margin-left: 0;

            // Add top spacing on mobile
            > a {
                margin-top: 2px;
            }
        }
    }

    // Link if dropdown opened
    .open > a {
        &,
        &:hover,
        &:focus {
            background-color: @nav-link-hover-bg;
        }
    }

    // Bordered and toolbar pills
    &.nav-pills-bordered,
    &.nav-pills-toolbar {
        > li > a,
        > .open > a {
            border: 1px solid @nav-tabs-border-color;
        }

        // Active state
        > .active > a,
        > .active > a:hover,
        > .active > a:focus {
            border-color: @nav-pills-active-link-hover-bg;
        }
    }

    // Toolbar pills
    &.nav-pills-toolbar {
        @media (min-width: @screen-sm-min) {
            > li {
                > a {
                    border: 1px solid @nav-tabs-border-color;
                    border-radius: 0;
                }

                &:first-child > a {
                    border-radius: @border-radius-base 0 0 @border-radius-base;
                }

                &:last-child > a {
                    border-radius: 0 @border-radius-base @border-radius-base 0;
                }

                & + li > a {
                    margin-top: 0;
                    margin-left: 0;
                    border-left: 0;
                }
            }
        }
    }


    // Setup desktop view
    @media (min-width: @screen-sm-min) {
        font-size: 0;

        // Pill item
        > li {
            display: inline-block;
            font-size: @font-size-base;

            // Links
            + li > a {
                margin-top: 0;
                margin-left: @tags-spacing;
            }
        }

        // Justified pills
        &.nav-justified {
            > li {
                display: table-cell;
            }
        }
    }

    // Stick right elements to the right side
    @media (max-width: @screen-xs-max) {
        > li > a {
            .position-right {

                // Icons
                &[class*=icon-] {
                    float: right;
                    margin-top: ((@line-height-computed - @icon-font-size) / 2);
                }

                // Labels and badges
                &.label,
                &.badge {
                    float: right;
                }
            }
        }
    }
}

// Stacked pills
.nav-stacked {
    > li {
        display: block;

        // Links
        > a {
            .pull-right {
                &[class*=icon-] {
                    float: right;
                    margin-top: ((@line-height-computed - @icon-font-size) / 2);
                }

                // Labels/badges
                &.label,
                &.badge {
                    float: right;
                }
            }
        }

        // Sibling links
        + li > a {
            margin-left: 0;
        }
    }
}



// Nav variations
// -------------------------

// Justified nav links
.nav-justified {

    // Remove bottom margin
    > li > a {
        margin-bottom: 0;
    }
}

// Justified tabs
.nav-tabs-justified {

    // Links
    > li > a {
        border-radius: 0;
        margin-bottom: 0;

        // Hover state
        &:hover,
        &:focus {
            border-bottom-color: @nav-tabs-border-color;
        }
    }

    // Setup desktop view
    @media (min-width: @screen-sm-min) {

        // Justified tabs with top border only
        &.nav-tabs-top {
            border-bottom: 1px solid @nav-tabs-border-color;

            // Links
            > li > a,
            > li > a:hover,
            > li > a:focus {
                border: 0;
            }
        }

        // Justified tabs with bottom border only
        &.nav-tabs-bottom {
            border-bottom: 1px solid @nav-tabs-border-color;
        }

        // Justified tabs with highlighted top border
        &.nav-tabs-highlight {
            > li > a,
            > li > a:hover,
            > li > a:focus {
                border-top-width: 2px;
            }
        }
    }

    // Setup mobile view
    @media (max-width: @screen-xs-max) {
        > li {
            &.active > a {
                &,
                &:hover,
                &:focus {
                    border-width: 0 0 0 2px;
                    border-left-color: @color-pink-400;
                }
            }
        }
    }
}

// Add rounded corners to the tabs
@media (min-width: @screen-sm-min) {

    // Default tabs
    .nav-tabs.nav-tabs-component {
        > li > a {
            border-radius: @border-radius-base @border-radius-base 0 0;
        }

        // Solid and with custom color
        &.nav-tabs-solid,
        &[class*=bg-] {
            border-radius: @border-radius-base;

            // Links
            > li > a {
                border-radius: 0;
            }

            // Link in first item
            > li:first-child > a {
                border-radius: @border-radius-base 0 0 @border-radius-base;
            }
        }
    }

    // Justified tabs
    .nav-tabs-component.nav-justified:extend(.nav-tabs-component) {
        &.nav-tabs-solid,
        &[class*=bg-] {
            > li:last-child > a {
                border-radius: 0 @border-radius-base @border-radius-base 0;
            }
        }
    }
}



// Tab content area
// -------------------------

// Add padding as panes don't have it by default
.tab-content > .has-padding {

    // Bordered tab content
    .tab-content-bordered & {
        padding: @panel-body-padding;
    }

    // Inside flat panel
    .panel-flat > .panel-heading + & {
        padding-top: 0;
    }

    // Remove padding on mobiles
    @media (min-width: @screen-sm-min) {
        padding: @panel-body-padding;
    }
}

// Panel tab content
.panel-tab-content {
    > .has-padding {
        padding: @panel-body-padding;
    } 
}

// Bordered tab content
.tab-content-bordered {

    // Add padding and borders to tab content area
    .tab-content {
        border-radius: @border-radius-base;
        border: 1px solid transparent;

        &:not([class*=bg-]) {
            border-color: @nav-tabs-active-link-hover-border-color;
            background-color: @nav-tabs-active-link-hover-bg;
        }

        @media (min-width: @screen-sm-min) {
            border-top-width: 0;
            border-radius: 0 0 @border-radius-base @border-radius-base;
        }
    }

    // Setup desktop view
    @media (min-width: @screen-sm-min) {
        .nav-tabs {
            margin-bottom: 0;

            // Add specific styles for solid tabs
            &.nav-tabs-solid {
                border-radius: @border-radius-base @border-radius-base 0 0;
                .box-shadow (0 0 0 1px @nav-tabs-border-color inset);

                > li:first-child > a {
                    border-radius: @border-radius-base 0 0 0;
                }

                &.nav-justified > li:last-child > a {
                    border-radius: 0 @border-radius-base 0 0;
                }
            }
        }

        // Tabs with solid color
        > .nav-tabs[class*=bg-] {
            .border-top-radius(@border-radius-base);

            & + .tab-content[class*=bg-] {
                border-top-width: 1px;
                border-top-color: fade(#fff, 50%);
            }
        }
    }
}



// Responsive stuff
// -------------------------

// Setup desktop view
@media (min-width: @screen-sm-min) {

    // Dropdown top margin correction in some tabs layouts
    .nav-tabs[class*=bg-],
    .nav-tabs-top {
        .dropdown-menu {
            margin-top: 0;
        }
    }

    // Top 1px gap for dropdown in bottom divided layout
    .nav-justified.bottom-divided .dropdown-menu {
        margin-top: 1px;
    }
}


// Setup mobile view
@media (max-width: @screen-xs-max) {
    .nav-tabs,
    .nav-pills {

        // Make dropdown full width on mobile
        .dropdown-menu,
        &.nav-justified > .dropdown .dropdown-menu {
            left: -1px;
            right: -1px;
            margin-top: 2px;
        }

        // Always use left text alignment on mobile
        &.nav-justified,
        &.text-center,
        &.text-right {
            > li > a {
                text-align: left;
            }
        }
    }
}
