/*━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━*/
/*                    V3_NAVBAR - НАВИГАЦИЯ                        */
/*━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━*/

/* ────────────────────────────────────────────────────────────── */
/* БАЗОВЫЕ СТИЛИ (общие для всех размеров)                         */
/* ────────────────────────────────────────────────────────────── */

#navbar_body {
    display: flex;
    flex-grow: 1;
    align-items: center;
}

#navbar_body ul {
    list-style: none !important;
    padding-left: 0 !important;
    margin-bottom: 0 !important;
}

#navbar_body a {
    text-decoration: none;
}

/* ────────────────────────────────────────────────────────────── */
/* СТРЕЛКИ - По умолчанию скрыты                                   */
/* ────────────────────────────────────────────────────────────── */

#navbar_body a .arrow {
    display: none;
}

/* ════════════════════════════════════════════════════════════════ */
/* DESKTOP VERSION (≥992px)                                          */
/* ════════════════════════════════════════════════════════════════ */

@media (min-width: 992px) {

    /* Размер шрифта */
    #navbar_body a,
    #navbarSupportedContent input {
        font-size: clamp(0.7rem, 0.6rem + 0.4vw, 1.1rem);
    }

    /* ────────────────────────────────────────────────────────── */
    /* Level 0 (основное меню)                                     */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body>ul.level_0 {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }

    #navbar_body>ul.level_0>li {
        position: relative;
    }

    #navbar_body>ul.level_0>li>a {
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
        display: block;
        padding: 0.5rem 0.5rem;
        color: rgba(255, 255, 255, 0.75);
        white-space: nowrap;
    }

    #navbar_body>ul.level_0>li>a:hover {
        color: rgba(255, 255, 255, 1);
    }

    #navbar_body>ul.level_0>li.active>a {
        color: rgba(255, 255, 255, 1);
        font-weight: bold;
    }

    #navbar_body>ul.level_0>li.parent>a {
        display: flex;
        align-items: center;
    }

    /* ────────────────────────────────────────────────────────── */
    /* СТРЕЛКИ для Level 0 - показываем только у .parent           */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body>ul.level_0>li.parent>a .arrow {
        display: flex;
		align-items: center;
		justify-content: center;
        margin-left: 0.255em;
        vertical-align: 0.255em;
        font-family: "Font Awesome 7 Free";
        font-weight: 900;
        transition: transform 0.3s ease, background-color 0.3s ease;
        cursor: pointer;
		width: 1.5rem;
    	height: 1.5rem;
		border-radius: 0.25rem;

    }
	
	#navbar_body ul.level_0>li.parent>a .arrow:hover {
		background-color: rgba(255, 255, 255, 0.1);
	}
	

    #navbar_body>ul.level_0>li.parent>a .arrow::before {
        content: "\f107"; /* chevron-down */
    }

    /* Поворот стрелки при .clicked */
    #navbar_body>ul.level_0>li.parent>a.clicked .arrow {
        transform: rotate(180deg);
    }

    /* ────────────────────────────────────────────────────────── */
    /* Dropdown (level_1, level_2)                                 */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body ul.level_1,
    #navbar_body ul.level_2 {
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;

        position: absolute;
        min-width: 10rem;
        padding: 0.5rem 0;
        margin: 0;

        background-color: #fff;
        border: 1px solid rgba(0, 0, 0, 0.15);
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    }

    /* Level_1 под родителем */
    #navbar_body ul.level_1 {
        width: 25rem;
        top: 100%;
        left: 0;
        z-index: 2;
        border-radius: 0 0 0.375rem 0.375rem;
        padding-top: 0;
    }

    /* Level_2 справа от родителя */
    #navbar_body ul.level_2 {
        width: 15rem;
        top: 0;
        left: 100%;
        z-index: 3;
        border-radius: 0 0.375rem 0.375rem 0.375rem;
    }

    /* Показ по классу .show */
    #navbar_body ul.level_1.show,
    #navbar_body ul.level_2.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Ссылки внутри dropdown */
    #navbar_body ul.level_1>li,
    #navbar_body ul.level_2>li {
        position: relative;
    }

    #navbar_body ul.level_1>li>a,
    #navbar_body ul.level_2>li>a {
        display: block;
        width: 100%;
        padding: 0.25rem 1rem;
        color: #212529 !important;
        white-space: nowrap;
        background-color: transparent;
        text-wrap: wrap;
    }

    #navbar_body ul.level_1>li>a:hover,
    #navbar_body ul.level_2>li>a:hover {
        color: #1e2125 !important;
        background-color: #e9ecef;
    }

    #navbar_body ul.level_1>li.active>a,
    #navbar_body ul.level_2>li.active>a {
        color: #fff !important;
        background-color: #0d6efd;
    }

    #navbar_body ul.level_1>li.parent>a {
        display: flex;
        align-items: center;
    }

    /* ────────────────────────────────────────────────────────── */
    /* СТРЕЛКИ для Level 1 - показываем только у .parent           */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body ul.level_1>li.parent>a .arrow {
		display: flex;
		align-items: center;
		justify-content: center;
        margin-left: auto;
        font-family: "Font Awesome 7 Free";
        font-weight: 900;
        transition: transform 0.3s ease, background-color 0.3s ease;
        cursor: pointer;
		flex: 0 0 auto;
		width: 1.5rem;
    	height: 1.5rem;
		border-radius: 0.25rem;
    }
	
	#navbar_body ul.level_1>li.parent>a .arrow:hover {
		background-color: rgba(13, 110, 253, 0.1);
	}

    #navbar_body ul.level_1>li.parent>a .arrow::before {
        content: "\f105"; /* chevron-right */
    }

    /* Поворот стрелки при .clicked */
    #navbar_body ul.level_1>li.parent>a.clicked .arrow {
        transform: rotate(180deg);
    }

    /* ────────────────────────────────────────────────────────── */
    /* Кнопки пагинации                                            */
    /* ────────────────────────────────────────────────────────── */

    .nav-pagination-up,
    .nav-pagination-down {
        border: 1px solid rgba(0, 0, 0, 0.15);
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
        background-color: #e9ecef;
        text-align: center;
        font-weight: 400;
        height: 35px;
        display: flex;
        align-items: center;
    }

    #navbar_body ul.level_2>li.nav-pagination-up {
        margin-top: -0.5rem;
    }

    .nav-pagination-down {
        margin-bottom: -0.5rem;
        border-radius: 0 0 0.375rem 0.375rem;
    }

    .nav-pagination-up button,
    .nav-pagination-down button {
        color: #1e2125;
        padding: var(--bs-nav-link-padding-y) var(--bs-nav-link-padding-x);
        border: 0;
        background: 0 0;
    }

    /* ────────────────────────────────────────────────────────── */
    /* Адаптивные размеры                                          */
    /* ────────────────────────────────────────────────────────── */

    @media (min-width: 991.98px) and (max-width: 1399.98px) {
        #navbar_body>ul.level_0>li>a {
            padding: 0.5rem 0.2rem;
        }

        #navbar_body ul.level_1 {
            width: 15rem;
        }

        #navbar_body ul.level_2 {
            width: 15rem;
        }
    }

    @media (min-width: 1200px) {
        #navbar_body>ul.level_0>li>a {
            font-weight: bold;
        }
    }
}

/* ════════════════════════════════════════════════════════════════ */
/* MOBILE VERSION (<992px)                                           */
/* ════════════════════════════════════════════════════════════════ */

@media (max-width: 991.98px) {

    /* ────────────────────────────────────────────────────────── */
    /* Скролл navbar                                               */
    /* ────────────────────────────────────────────────────────── */

    .navbar-collapse {
        max-height: calc(100vh - 56px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #navbar_body {
        overflow-y: auto;
        opacity: 1 !important;
    }

    /* ────────────────────────────────────────────────────────── */
    /* Level 0 - вертикальное меню                                 */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body>ul.level_0 {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    #navbar_body>ul.level_0>li {
        width: 100%;
    }

    /* Базовые ссылки */
    #navbar_body>ul.level_0>li>a {
        display: block;
        width: 100%;
        padding: 0.5rem 0.5rem;
        color: rgba(255, 255, 255, 0.75);
    }

    #navbar_body>ul.level_0>li>a:hover {
        color: rgba(255, 255, 255, 1);
    }

    /* Активная страница */
    #navbar_body>ul.level_0>li.active>a {
        color: rgba(255, 255, 255, 1);
        font-weight: bold;
    }

    /* ────────────────────────────────────────────────────────── */
    /* Стрелка для перехода + раскрытие                            */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body li.parent>a {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* ────────────────────────────────────────────────────────── */
    /* Dropdown (статичный)                                        */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body ul.level_1,
    #navbar_body ul.level_2 {
        position: static;
        box-shadow: none;
        border: none;
        border-radius: 0;
        display: none !important;
        margin-left: 1rem;
        width: calc(100% - 1rem);
    }

    /* Показать при клике */
    #navbar_body li.parent>a.clicked+ul {
        display: block !important;
    }

    /* ────────────────────────────────────────────────────────── */
    /* Кнопка перехода на корневую страницу                        */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body li.parent>a.nav-link {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    #navbar_body li.parent>a.nav-link>button {
        border: 0.5px solid;
        min-width: 2.5rem;
        border-radius: 5px;
        background-color: rgba(255, 0, 0, 0.1);
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
        margin-left: auto;
    }

    #navbar_body li.parent>a.nav-link>button:hover {
        color: rgba(255, 255, 255, 0.85);
    }

    /* Иконка стрелки перехода */
    #navbar_body li.parent>a.nav-link>button::before {
        font-family: "Font Awesome 7 Free";
        font-weight: 900;
        content: "\f178";
        font-size: 0.875rem;
    }

    /* ────────────────────────────────────────────────────────── */
    /* Индикатор dropdown (chevron)                                */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body>ul.level_0>li.parent>a.nav-link>span::before,
    #navbar_body ul.level_1>li.parent>a.nav-link>span::before {
        display: inline-block;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
        font-family: "Font Awesome 7 Free";
        font-weight: 900;
        content: "\f107";
        transition: transform 0.3s ease;
    }

    /* Поворот при раскрытии */
    #navbar_body>ul.level_0>li.parent>a.nav-link.clicked>span::before,
    #navbar_body ul.level_1>li.parent>a.nav-link.clicked>span::before {
        transform: rotate(180deg);
    }

    /* ────────────────────────────────────────────────────────── */
    /* Level 1 - первый уровень вложенности                        */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body ul.level_1 {
        background-color: rgba(255, 255, 255, 0.1);
    }

    #navbar_body ul.level_1>li>a {
        display: block;
        padding: 0.5rem 1rem;
        color: rgba(255, 255, 255, 0.75) !important;
    }

    #navbar_body ul.level_1>li>a:hover {
        color: rgba(255, 255, 255, 1) !important;
        background-color: rgba(255, 255, 255, 0.1);
    }

    /* ────────────────────────────────────────────────────────── */
    /* Level 2 - второй уровень вложенности                        */
    /* ────────────────────────────────────────────────────────── */

    #navbar_body ul.level_2 {
        background-color: rgba(255, 255, 255, 0.05);
    }

    #navbar_body ul.level_2>li>a {
        display: block;
        padding: 0.5rem 1rem;
        color: rgba(255, 255, 255, 0.65) !important;
    }

    #navbar_body ul.level_2>li>a:hover {
        color: rgba(255, 255, 255, 1) !important;
        background-color: rgba(255, 255, 255, 0.05);
    }

    /* ────────────────────────────────────────────────────────── */
    /* Форма поиска                                                */
    /* ────────────────────────────────────────────────────────── */

    .navbar-collapse form.d-flex {
        width: 100%;
        margin-top: 1rem;
        padding: 0 1rem 1rem;
    }

    /* ────────────────────────────────────────────────────────── */
    /* Узкие экраны (<700px) - перенос текста                      */
    /* ────────────────────────────────────────────────────────── */

    @media (max-width: 700px) {

        #navbar_body li.parent>a,
        #navbar_body li.parent_active>a {
            white-space: normal !important;
            word-wrap: break-word !important;
            overflow-wrap: break-word !important;
            line-height: 1.3 !important;
        }

        #navbar_body ul.level_1>li>a,
        #navbar_body ul.level_2>li>a {
            white-space: normal !important;
            word-wrap: break-word !important;
            overflow-wrap: break-word !important;
            line-height: 1.3 !important;
        }
    }
}