@use 'mixins/breakpoints';
@use 'variables';

.dg-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding: 0.719rem 1.25rem;
    justify-content: space-between;
    font-size: variables.$dg-font-size-md;
    z-index: 100;

    .nav.nav-spacer {
        display: flex;
        visibility: hidden;
        width: 0;
        margin: 0;
        flex: 0 0 auto;
    }

    .navbar-brand {
        display: inline-flex;
        align-items: center;
        margin-right: 1rem;

        .logo {
            margin-right: 10px;
            width: 30px;
            height: 30px;
        }

        .title {
            font-weight: 600;
            color: variables.$dg-white;
            text-decoration: none;
            &:hover {
                text-decoration: none;
            }
        }
    }

    .navbar-toggler {
        margin-left: 10px;
        display: none;
    }

    .nav {
        display: flex;
        a {
            padding: 6px 18px;
            margin-right: 8px;
            text-decoration: none;

            &.active {
                border-radius: 4px;
                text-decoration: none !important;
            }

            &:hover {
                text-decoration: none !important;
            }
        }
    }

    .spacer {
        flex: 1;
    }

    .action-items {
        display: flex;
        align-items: center;
        flex: auto;
        justify-content: flex-end;

        .search-container {
            flex: auto;
            max-width: 300px;
        }

        .action-icon {
            padding: 0;
            width: 32px;
            height: 32px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            border-radius: 6px;
            transition: all 0.2s;
            cursor: pointer;
            outline: none;

            .dg-icon {
                font-size: variables.$dg-font-size-lg;
            }
        }

        .action-icon-item {
            margin-left: 12px;
        }
    }

    @include breakpoints.dg-media-breakpoint-down('md') {
        flex-wrap: wrap;
        justify-content: space-between;

        .navbar-toggler {
            display: block;
        }

        .spacer,
        .nav,
        .action-items {
            display: none;
        }

        .nav {
            flex-direction: column;
            flex-basis: 100%;
            margin-top: 8px;
            margin-bottom: 6px;
        }

        .action-items {
            flex-direction: column;
            align-items: flex-start;
            .action-item {
                margin-bottom: 10px;
            }
        }

        &.show {
            .spacer,
            .nav,
            .action-items {
                display: flex;
            }
        }
    }
}

@mixin dg-navbar-theme($background-color, $box-shadow, $color) {
    background-color: $background-color;
    box-shadow: $box-shadow;

    .nav {
        a {
            color: $color;
        }
    }
    .navbar-brand {
        .title {
            color: $color;
        }
    }

    .repo-url {
        color: $color;
    }
}

.dg-navbar-theme-angular {
    .dg-navbar {
        @include dg-navbar-theme(
            variables.$dg-navbar-background-angular,
            variables.$dg-navbar-box-shadow-angular,
            variables.$dg-navbar-color-angular
        );

        .nav {
            a {
                &:hover {
                    color: rgba($color: variables.$dg-white, $alpha: 0.8); // $gray-200;
                }

                &.active {
                    background: hsla(0, 0%, 100%, 0.15);
                }
            }
        }

        .action-items {
            .action-icon {
                color: variables.$dg-white;
                &:hover,
                &.active {
                    background-color: hsla(0, 0%, 100%, 0.15);
                }
            }
        }
    }
}
@mixin dg-navbar-theme-default() {
    .dg-navbar {
        @include dg-navbar-theme(
            variables.$dg-navbar-background-default,
            variables.$dg-navbar-box-shadow-default,
            variables.$dg-navbar-color-default
        );

        .nav {
            a {
                &:hover {
                    color: variables.$dg-primary;
                }

                &.active {
                    color: variables.$dg-primary;
                    background: rgba(variables.$dg-primary, 0.12);
                }
            }
        }

        .action-items {
            .action-icon {
                color: variables.$dg-text-color;

                &:hover,
                &.active {
                    background-color: variables.$dg-navbar-action-bg-color;
                }
            }
        }
    }
}

.dg-navbar-theme-default {
    @include dg-navbar-theme-default();
}

:root[theme='dark'] {
    .dg-navbar-theme-angular {
        @include dg-navbar-theme-default();
    }
}
