/* Стили для подменю */
.has-submenu {
    position: relative;
}

.submenu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    z-index: 1000;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    
    /* СБРОС ВСЕХ СТИЛЕЙ ДЛЯ ДЕСКТОПА */
    display: block !important;
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
}

.submenu li {
    margin: 0;
    display: block !important;
    width: 100% !important;
}

.submenu a {
    display: block !important;
    padding: 0.75rem 1.5rem;
    color: var(--dark) !important;
    text-decoration: none;
    transition: all 0.15s ease;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    border-left: 2px solid transparent;
    white-space: nowrap;
    width: 100% !important;
    box-sizing: border-box !important;
}

.has-submenu:hover .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.submenu a:hover {
    background: #f8fafc;
    color: var(--primary) !important;
    border-left-color: var(--primary);
}

/* ДЕСКТОПНАЯ ВЕРСИЯ - ВСЕ СТИЛИ ВЕРХНЕГО УРОВНЯ */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none !important;
    }
    
    /* ВОССТАНАВЛИВАЕМ ОРИГИНАЛЬНЫЕ СТИЛИ МЕНЮ */
    nav ul {
        display: flex !important;
        list-style: none;
        gap: 2rem;
        align-items: center;
        margin: 0;
        padding: 0;
        
        /* СБРОС МОБИЛЬНЫХ СТИЛЕЙ */
        position: static !important;
        width: auto !important;
        height: auto !important;
        max-height: none !important;
        background: transparent !important;
        flex-direction: row !important;
        padding: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
        z-index: auto !important;
    }

    /* ВОССТАНАВЛИВАЕМ СТИЛИ ПУНКТОВ МЕНЮ */
    #navMenu > li {
        width: auto !important;
        margin-bottom: 0 !important;
    }

    #navMenu > li > a {
        display: flex !important;
        align-items: center !important;
        padding: 0.5rem 0 !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        width: auto !important;
        font-size: inherit !important;
        min-height: auto !important;
        justify-content: center !important;
    }

    /* УБИРАЕМ СТРЕЛКИ С ДЕСКТОПА */
    .has-submenu > a::after {
        display: none !important;
    }

    /* ВОССТАНАВЛИВАЕМ ПОДМЕНЮ НА ДЕСКТОПЕ */
    .submenu {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        background: white !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        min-width: 200px !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateY(-5px) !important;
        transition: all 0.2s ease !important;
        z-index: 1000 !important;
        padding: 0.5rem 0 !important;
        margin-top: 0.5rem !important;
        display: block !important;
    }

    .has-submenu:hover .submenu {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
    }

    /* ВОССТАНАВЛИВАЕМ СТИЛИ ПОДПУНКТОВ */
    .submenu a {
        display: block !important;
        padding: 0.75rem 1.5rem !important;
        border-left: 2px solid transparent !important;
        border-bottom: none !important;
        white-space: nowrap !important;
        background: white !important;
        font-size: 0.9rem !important;
    }

    .submenu a::before {
        display: none !important;
    }

    .contact-header {
        display: flex !important;
    }
}

/* Адаптивность для мобильных - КОМПАКТНАЯ ВЕРСИЯ */
@media (max-width: 768px) {
    /* ВКЛЮЧАЕМ КНОПКУ МЕНЮ */
    .mobile-menu-btn {
        display: block !important;
    }

    /* СКРЫВАЕМ ОБЫЧНОЕ МЕНЮ НА МОБИЛЬНЫХ */
    nav ul {
        display: none !important;
        position: fixed;
        top: 70px;
        left: 0;
        width: 100%;
        height: auto !important;
        max-height: calc(100vh - 70px);
        background: white;
        flex-direction: column;
        padding: 0.5rem;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
        z-index: 999;
        gap: 0.25rem;
    }

    /* ПОКАЗЫВАЕМ МЕНЮ ПРИ АКТИВАЦИИ */
    nav ul.active {
        display: flex !important;
    }

    /* КОМПАКТНЫЕ ПУНКТЫ МЕНЮ */
    #navMenu > li {
        width: 100%;
        margin-bottom: 0.25rem;
    }

    #navMenu > li > a {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.7rem 0.8rem;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        background: #f9fafb;
        width: 100%;
        box-sizing: border-box;
        font-size: 0.9rem;
        min-height: auto;
    }

    /* СТРЕЛКИ ДЛЯ ПОДМЕНЮ НА МОБИЛЬНЫХ */
    .has-submenu > a::after {
        content: '›';
        font-size: 1.1em;
        transition: transform 0.3s ease;
        margin-left: 0.5rem;
    }

    .has-submenu.active > a::after {
        transform: rotate(90deg);
    }

    /* КОМПАКТНОЕ ПОДМЕНЮ */
    .has-submenu {
        position: static;
    }
    
    .submenu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: white;
        box-shadow: none;
        border: none;
        border-radius: 0;
        margin-top: 0.25rem;
        padding: 0;
        display: none;
        width: 100%;
        min-width: auto;
        height: auto !important;
        max-height: none !important;
    }
    
    .has-submenu.active .submenu {
        display: block;
    }
    
    .submenu li {
        margin-bottom: 0.1rem;
    }
    
    .submenu a {
        display: flex;
        align-items: center;
        padding: 0.6rem 0.8rem 0.6rem 1.5rem;
        border-left: none;
        border-bottom: 1px solid #f1f5f9;
        white-space: normal;
        background: white;
        font-size: 0.85rem;
        min-height: auto;
    }

    .submenu a::before {
        content: '—';
        margin-right: 0.4rem;
        color: var(--primary);
        font-weight: bold;
        font-size: 0.8rem;
    }

    /* СКРЫВАЕМ КОНТАКТЫ В ШАПКЕ НА МОБИЛЬНЫХ */
    .contact-header {
        display: none !important;
    }
}

/* ФИКС ДЛЯ ОЧЕНЬ МАЛЕНЬКИХ ЭКРАНОВ */
@media (max-width: 380px) {
    nav ul {
        top: 60px;
        max-height: calc(100vh - 60px);
        padding: 0.3rem;
    }
    
    #navMenu > li > a {
        padding: 0.6rem 0.7rem;
        font-size: 0.85rem;
    }
    
    .submenu a {
        padding: 0.5rem 0.7rem 0.5rem 1.3rem;
        font-size: 0.8rem;
    }
    
    .submenu a::before {
        margin-right: 0.3rem;
    }
}