/* ============================================
   ЕДИНОЕ СТАНДАРТНОЕ АДАПТИВНОЕ МЕНЮ
   Централизованные стили для мобильного меню
   ============================================ */

:root {
    --admin-header-height: 72px;
}

/* Кнопка меню - отображается на всех устройствах */
.menu-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background 0.2s;
    z-index: 10001;
    position: relative;
    align-items: center;
    justify-content: center;
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
}

.menu-toggle i {
    display: none;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.menu-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Мобильное меню */
.mobile-menu {
    display: none;
    position: fixed;
    top: var(--admin-header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(99, 102, 241, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    padding: 20px;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: calc(100vh - var(--admin-header-height));
}

/* Когда меню открыто, оно должно начинаться ниже header */
/* Высота header обычно около 60-70px, добавляем небольшой отступ */
body.menu-open .mobile-menu {
    top: var(--admin-header-height);
}

/* Убеждаемся, что мобильное меню не перекрывает header */
body.menu-open .mobile-menu.active {
    top: var(--admin-header-height);
}

/* Заголовок в мобильном меню */
.mobile-menu-header {
    display: none;
    
}

.mobile-menu-title {
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.mobile-menu-title i {
    font-size: 1.2rem;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mobile-menu.active {
    display: flex;
    animation: slideDown 0.3s ease;
}

.mobile-menu a {
    color: white;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 8px;
    transition: background 0.2s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.mobile-menu a:hover,
.mobile-menu a:focus {
    background: rgba(255, 255, 255, 0.2);
    outline: none;
}

.mobile-menu a i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Анимация появления меню */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Блокировка скролла body при открытом меню */
/* Используем только overflow: hidden, без position: fixed, чтобы не влиять на цвета контента */
body.menu-open {
    overflow: hidden;
    height: 100vh;
    /* Не используем position: fixed, чтобы не влиять на рендеринг и цвета контента */
}

/* Убеждаемся, что когда меню закрыто, прокрутка работает нормально */
body:not(.menu-open) {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
}

/* Для мобильных устройств - гарантируем прокрутку */
@media (max-width: 768px) {
    body:not(.menu-open) {
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh;
    }
    html {
        overflow-y: auto !important;
        height: auto !important;
    }
}

/* Десктопное меню скрыто на всех устройствах */
.header-actions {
    display: none !important;
}

/* Обеспечиваем видимость header поверх меню */
.header {
    z-index: 10002 !important;
    position: sticky !important;
    top: 0 !important;
}

/* Когда меню открыто, header должен быть виден поверх меню и всегда наверху */
body.menu-open .header {
    z-index: 10003 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
}

/* Убеждаемся, что кнопка меню также видна поверх меню */
body.menu-open .menu-toggle {
    z-index: 10004 !important;
    position: relative !important;
}

/* Убеждаемся, что заголовок h1 в header также виден поверх меню */
body.menu-open .header h1 {
    z-index: 10005 !important;
    position: relative !important;
}

/* При открытом меню header остается видимым и фиксированным */
/* Header остается sticky при открытом меню - не меняем на fixed */
/* Это предотвращает изменение цветов контента */

/* Адаптивность для кнопки меню */
@media (max-width: 768px) {
    .menu-toggle {
        padding: 8px 14px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .menu-toggle {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* Дополнительные стили для подменю (если используется в admin.html) */
.mobile-menu .mobile-menu-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mobile-menu .mobile-menu-group-title {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-menu .mobile-submenu {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-left: 20px;
}

.mobile-menu .mobile-submenu a {
    font-size: 0.9rem;
    padding: 10px 16px;
}

.mobile-menu .mobile-submenu a.active {
    background: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

/* Стили для селектора языка в мобильном меню */
.mobile-menu .language-selector {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 15px;
    padding-top: 15px;
    padding-bottom: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    width: 100%;
    visibility: visible !important;
    opacity: 1 !important;
    /* order удален - порядок определяется порядком элементов в DOM */
}

.mobile-menu .language-selector i {
    color: white;
    font-size: 1.1rem;
}

.mobile-menu .language-selector select {
    background: var(--primary);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Source Sans Pro', sans-serif;
    min-width: 100px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.mobile-menu .language-selector select:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.mobile-menu .language-selector select:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.mobile-menu .language-selector select option {
    background: rgba(255, 255, 255, 0.2);
    color: black;
}

