/**
 * Header2 - Полностью независимый мобильный header
 * Без конфликтов с Brooklyn
 * Версия: 1.0.0
 */

/* ====================================
   ОБЩИЕ СТИЛИ
   ==================================== */

/* Скрываем Header2 на десктопах */
#header2,
#header2-mobile-menu {
    display: none;
}

/* УСИЛЕННОЕ скрытие на десктопах (>768px) - чтобы не перекрывать Brooklyn меню */
@media (min-width: 769px) {
    #header2,
    #header2-mobile-menu {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
        z-index: -9999 !important;
    }
}

/* Показываем только на мобильных */
@media (max-width: 768px) {
    #header2,
    #header2-mobile-menu {
        display: block;
    }

    /* Скрываем стандартный Brooklyn header на мобильных */
    #header-section {
        display: none !important;
    }
}

/* ====================================
   HEADER2 - Фиксированный header
   ==================================== */

@media (max-width: 768px) {
    .header2 {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-bottom: 1px solid #eee;
        z-index: 9999;
        display: flex;
        align-items: center;
        padding: 0 30px;
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        transform: translateY(0);
    }

    /* Header скрыт при скролле вниз */
    .header2--hidden {
        transform: translateY(-100%);
    }

    .header2.open {
        background: #fff;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }

    /* Контейнер header */
    .header2__container {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 15px;
                padding-top: 3vw;
        padding-bottom: 3vw;
    }

    /* Логотип */
    .header2__logo {
        flex-shrink: 0;
    }

    .header2__logo-link {
        display: block;
        text-decoration: none;
    }

    .header2__logo-img {
        max-height: 50px;
        width: auto;
        display: block;
    }

    .header2__logo-text {
        font-size: 20px;
        font-weight: 700;
        color: #333;
    }

    /* Кнопка консультации */
    .header2__consultation {
        margin-left: 15px;
        flex-shrink: 0;
    }

    .header2__consultation-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px 16px;
        background: #fff;
        color: #333;
        border: 1px solid #333;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 500;
        text-decoration: none;
        transition: all 0.3s ease;
        white-space: nowrap;
    }

    .header2__consultation-btn:hover {
        background: #333;
        color: #fff;
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    /* Социальные иконки */
    .header2__social {
        display: flex;
        gap: 10px;
        align-items: center;
        margin-left: auto;
        margin-right: 15px;
    }

    .header2__social-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        transition: opacity 0.2s ease, transform 0.2s ease;
        flex-shrink: 0;
    }

    .header2__social-link:hover {
        opacity: 0.8;
        transform: scale(1.05);
    }

    .header2__social-icon {
        width: 36px;
        height: 36px;
        display: block;
        object-fit: contain;
    }

    /* Бургер меню */
    .header2__burger {
        width: 32px;
        height: 24px;
        position: relative;
        cursor: pointer;
        z-index: 10000;
        flex-shrink: 0;
    }

    .header2__burger-line {
        position: absolute;
        left: 0;
        width: 100%;
        height: 3px;
        background: #ff0000;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    .header2__burger-line:nth-child(1) {
        top: 0;
    }

    .header2__burger-line:nth-child(2) {
        top: 50%;
        transform: translateY(-50%);
    }

    .header2__burger-line:nth-child(3) {
        bottom: 0;
    }

    /* Анимация бургера при открытии */
    .header2__burger.open .header2__burger-line:nth-child(1) {
        top: 50%;
        transform: translateY(-50%) rotate(45deg);
    }

    .header2__burger.open .header2__burger-line:nth-child(2) {
        opacity: 0;
    }

    .header2__burger.open .header2__burger-line:nth-child(3) {
        bottom: 50%;
        transform: translateY(50%) rotate(-45deg);
    }
}

/* ====================================
   FULLSCREEN MOBILE MENU
   ==================================== */

@media (max-width: 768px) {
    /* Fullscreen меню */
    .header2-mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        background: #F5F8F9;
        z-index: 9998;

        /* Всегда flex */
        display: flex;
        flex-direction: column;

        /* Отступ сверху для header */
        padding-top: 50px;
        padding-bottom: 30px;

        /* Скрыто по умолчанию через opacity */
        opacity: 0;
        pointer-events: none;

        /* Плавная анимация */
        transition: opacity 0.3s ease;

        /* Прокрутка */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Меню открыто */
    .header2.open ~ .header2-mobile-menu {
        opacity: 1;
        pointer-events: all;
    }

    /* Контейнер меню */
    .header2-mobile-menu__wrapper {
        width: 100%;
        padding: 20px 30px;
    }

    /* Список меню */
    .header2-mobile-menu__list {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .header2-mobile-menu__item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        padding-bottom: 15px;

        /* Начальное состояние для анимации */
        opacity: 0;
        transform: translateY(20px);
        transition: all 0.3s ease;
    }

    .header2-mobile-menu__item:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    /* Анимация появления пунктов меню */
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__item {
        opacity: 1;
        transform: translateY(0);
    }

    /* Cascade эффект - расширено для всех пунктов включая подменю */
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(1) { transition-delay: 0.05s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(2) { transition-delay: 0.1s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(3) { transition-delay: 0.15s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(4) { transition-delay: 0.2s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(5) { transition-delay: 0.25s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(6) { transition-delay: 0.3s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(7) { transition-delay: 0.35s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(8) { transition-delay: 0.4s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(9) { transition-delay: 0.45s; }
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__list > .header2-mobile-menu__item:nth-child(10) { transition-delay: 0.5s; }

    /* Подменю появляются с задержкой после родительского элемента */
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__submenu .header2-mobile-menu__item {
        opacity: 0;
        transform: translateX(10px);
        transition: all 0.25s ease;
    }

    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__item--has-children:hover .header2-mobile-menu__submenu .header2-mobile-menu__item,
    .header2.open ~ .header2-mobile-menu .header2-mobile-menu__submenu .header2-mobile-menu__item {
        opacity: 1;
        transform: translateX(0);
    }

    .header2-mobile-menu__link {
        display: block;
        padding: 10px 0;
        color: #333;
        font-size: 20px;
        font-weight: 500;
        text-decoration: none;
        transition: all 0.2s ease;
    }

    .header2-mobile-menu__link:hover {
        color: #ff0000;
        padding-left: 15px;
    }

    /* Подменю (вложенные пункты) */
    .header2-mobile-menu__submenu {
        list-style: none;
        margin: 0;
        padding: 0;
        margin-top: 10px;
    }

    .header2-mobile-menu__submenu .header2-mobile-menu__item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        padding-bottom: 10px;
        margin-bottom: 10px;
    }

    .header2-mobile-menu__submenu .header2-mobile-menu__item:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }

    .header2-mobile-menu__submenu .header2-mobile-menu__link {
        color: #666;
        font-size: 16px;
        font-weight: 400;
        padding: 8px 0 8px 20px;
        position: relative;
    }

    .header2-mobile-menu__submenu .header2-mobile-menu__link:before {
        content: "—";
        position: absolute;
        left: 0;
        color: #ff0000;
    }

    .header2-mobile-menu__submenu .header2-mobile-menu__link:hover {
        color: #ff0000;
        padding-left: 25px;
    }

    /* Пункт с подменю - добавляем индикатор */
    .header2-mobile-menu__item--has-children > .header2-mobile-menu__link:after {
        content: "";
        display: inline-block;
        width: 0;
        height: 0;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 5px solid #ff0000;
        margin-left: 8px;
        vertical-align: middle;
    }

    /* Кнопка консультации */
    .header2-mobile-menu__consultation {
        margin-top: 30px;
        padding-top: 20px;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }

    .header2-mobile-menu__consultation-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 14px 30px;
        background: #ff0000;
        color: #fff !important;
        border-radius: 8px;
        font-size: 16px;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.3s ease;
        text-align: center;
    }

    .header2-mobile-menu__consultation-btn:hover {
        background: #cc0000;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
    }

    /* Блокировка скролла */
    body.header2-menu-open {
        overflow: hidden !important;
        position: relative !important;
        height: 100vh !important;
        width: 100% !important;
    }
}

/* ====================================
   АДАПТИВНОСТЬ
   ==================================== */

@media (max-width: 480px) {
    .header2 {
        padding: 0 15px;
    }

    .header2__logo-img {
        max-height: 40px;
    }

    .header2__logo-text {
        font-size: 18px;
    }

    /* Кнопка консультации на маленьких экранах */
    .header2__consultation {
        margin-left: 10px;
    }

    .header2__consultation-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .header2-mobile-menu__wrapper {
        padding: 20px 20px;
    }

    .header2-mobile-menu__link {
        font-size: 18px;
    }

    .header2__social {
        gap: 8px;
        margin-right: 10px;
    }

    .header2__social-link {
        width: 32px;
        height: 32px;
    }

    .header2__social-icon {
        width: 32px;
        height: 32px;
    }
}

/* ====================================
   ОТСТУП ДЛЯ КОНТЕНТА ПОД FIXED HEADER
   ==================================== */

/* Только на мобильных - компенсируем fixed header */
@media (max-width: 768px) {
    body,
    #main-content {
        padding-top: 11vw;
    }
}
