body {
    padding-top: var(--header-height);
    transition: padding-top 0.3s ease;
    margin: 0;
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    box-sizing: border-box;
}

body.sidebar-open {
    overflow: hidden;
}

.main-content-wrapper {
    transition: padding-left 0.3s ease;
}

@media (min-width: 769px) {
    .main-content-wrapper {
        padding-left: var(--sidebar-collapsed-width);
    }

    body.sidebar-open .main-content-wrapper {
        padding-left: var(--sidebar-width);
    }
}

/* --- МОБИЛЬНАЯ ШАПКА --- */
.mobile-header {
    display: none;
}

.mobile-menu-toggle {
    display: none;
    cursor: pointer;
    z-index: 1001;
    transition: var(--transition);
}

/* --- САЙДБАР --- */
.sidebar-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-collapsed-width);
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--sidebar-border);
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

@media (min-width: 769px) {
    .sidebar-menu.expanded,
    .sidebar-menu:hover {
        width: var(--sidebar-width);
    }
}

.sidebar-brand {
    padding: 20px 15px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 60px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    color: var(--text-light);
    transition: var(--transition);
    white-space: nowrap;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    transition: var(--transition);
    object-fit: contain;
}

.brand-text {
    font-size: 1.4rem;
    font-weight: 700;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-menu.expanded .brand-text,
.sidebar-menu:hover .brand-text { /* Добавлено */
    opacity: 1;
    transform: translateX(0);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 2px; }

.sidebar-item {
    margin: 5px 10px;
    position: relative;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition);
    position: relative;
    white-space: nowrap;
    cursor: pointer;
}

.sidebar-link:hover {
    background: rgba(106, 90, 255, 0.1);
    color: var(--text-light);
    transform: translateX(3px);
}

.sidebar-link i {
    font-size: 20px;
    min-width: 24px;
    text-align: center;
    color: #A0A0A0;
    transition: var(--transition);
}

.sidebar-link:hover i {
    color: var(--hover-color);
    transform: scale(1.1);
}

.sidebar-text {
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.sidebar-menu.expanded .sidebar-text,
.sidebar-menu:hover .sidebar-text { /* Добавлено */
    opacity: 1;
    transform: translateX(0);
}

.sidebar-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.submenu-arrow {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    transition: var(--transition);
    opacity: 0;
    transform: translateX(-10px);
}

.sidebar-menu.expanded .submenu-arrow,
.sidebar-menu:hover .submenu-arrow { /* Добавлено */
    opacity: 1;
    transform: translateX(0);
}

.sidebar-item.active .submenu-arrow {
    transform: rotate(90deg);
}

.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin-top: 5px;
}

.sidebar-item.active .sidebar-submenu {
    max-height: 200px;
    padding: 10px 0;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px 8px 50px;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9rem;
}

.submenu-link:hover {
    background: rgba(106, 90, 255, 0.1);
    color: var(--text-light);
}

.submenu-link i {
    font-size: 14px;
    color: var(--primary-color);
    opacity: 0.7;
}

.sidebar-bottom {
    padding: 10px 0 20px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.logout-link:hover {
    background: rgba(255, 95, 109, 0.1);
    color: #FF5F6D;
}

.logout-link:hover i {
    color: #FF5F6D;
}

.sidebar-notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #FF5F6D, #FFC371);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.sidebar-link::before {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 15px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
    pointer-events: none;
}

.sidebar-link::after {
    content: '';
    position: absolute;
    left: calc(100% + 9px);
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
}

.sidebar-menu:not(.expanded) .sidebar-link:hover::before,
.sidebar-menu:not(.expanded) .sidebar-link:hover::after {
    opacity: 1;
    visibility: visible;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* --- МОДАЛЬНЫЕ ОКНА (УВЕДОМЛЕНИЯ И ПРОФИЛЬ) --- */
.notifications-modal, .profile-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.notifications-modal.active, .profile-modal.active {
    opacity: 1;
    visibility: visible;
}

.notifications-modal .modal-content,
.profile-modal .modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    padding: 0;
}

.notifications-modal.active .modal-content,
.profile-modal.active .modal-content {
    transform: scale(1);
}

.notifications-modal .modal-header,
.profile-modal .modal-header {
    background: rgba(255,255,255,0.02);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notifications-modal .modal-header h3,
.profile-modal .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.notifications-modal .modal-close,
.profile-modal .modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: var(--transition);
}

.notifications-modal .modal-close:hover,
.profile-modal .modal-close:hover {
    background: rgba(106, 90, 255, 0.1);
    color: var(--text-light);
}

.notifications-modal .modal-body,
.profile-modal .modal-body {
    padding: 15px;
    max-height: 60vh;
    overflow-y: auto;
}

/* --- СТИЛИ ДЛЯ ПРОФИЛЯ --- */
.profile-info { display: flex; align-items: center; gap: 15px; }
.profile-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-color); }
.profile-avatar-placeholder { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--primary-color), var(--hover-color)); display: flex; align-items: center; justify-content: center; color: white; font-size: 24px; border: 1px solid var(--border-color); }
.profile-details h3 { margin: 0; font-size: 1rem; color: var(--text-light); font-weight: 600; }
.user-status { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 2px; }

.profile-menu { display: flex; flex-direction: column; gap: 8px; }
.profile-menu-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 15px;
    color: var(--text-muted); text-decoration: none; border-radius: 12px;
    transition: all 0.2s; background: var(--secondary-background); border: 1px solid transparent;
}
.profile-menu-item:hover {
    background: rgba(106, 90, 255, 0.1); color: var(--primary-color);
    border-color: var(--primary-color); transform: translateX(5px);
}
.profile-menu-item i { width: 20px; text-align: center; font-size: 1rem; color: var(--text-muted); transition: color 0.2s; }
.profile-menu-item:hover i { color: var(--primary-color); }
.profile-menu-item span { font-weight: 500; font-size: 0.95rem; }

/* --- КНОПКИ УВЕДОМЛЕНИЙ --- */
.mark-all-read-btn {
    width: 100%; margin-bottom: 15px; padding: 10px;
    border-radius: 10px; background: var(--secondary-background);
    border: 1px solid var(--border-color); color: var(--text-muted);
    font-family: 'Minecraft', sans-serif; font-size: 0.85rem;
    cursor: pointer; transition: all 0.2s;
}
.mark-all-read-btn:hover {
    border-color: var(--success-color); color: var(--success-color);
    background: rgba(40, 199, 111, 0.05);
}

.view-all-notifications {
    display: block; text-align: center; margin-top: 15px; padding: 12px;
    background: rgba(106, 90, 255, 0.1); color: var(--primary-color);
    border-radius: 12px; text-decoration: none; font-weight: bold;
    font-size: 0.9rem; transition: all 0.2s;
}
.view-all-notifications:hover {
    background: var(--primary-color); color: white;
}

/* Списки уведомлений внутри модалки */
.notifications-list { display: flex; flex-direction: column; gap: 10px; }
/* Остальные стили карточек берутся из notifications.css */

/* Back to top */
.back-to-top {
    position: fixed; bottom: 30px; right: 30px; background: var(--primary-color); color: white;
    width: 50px; height: 50px; border-radius: 50%; border: none; cursor: pointer; opacity: 0;
    visibility: hidden; transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); z-index: 999; transform: translateY(20px);
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--hover-color); transform: translateY(-5px); box-shadow: 0 6px 20px rgba(106, 90, 255, 0.3); }

#popup-notification-container { position: fixed; top: 20px; right: 20px; z-index: 10000; max-width: 400px; }
.popup-notification {
    background: var(--sidebar-bg); border: 1px solid var(--sidebar-border); border-radius: 12px;
    padding: 15px; margin-bottom: 10px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    transform: translateX(100%); transition: transform 0.3s ease; display: flex; align-items: flex-start; gap: 12px;
}
.popup-notification.show { transform: translateX(0); }
.popup-notification.hide { transform: translateX(100%); opacity: 0; }

[data-theme="light"] .sidebar-menu { background: var(--sidebar-bg); border-right: 1px solid rgba(94, 76, 220, 0.15); box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05); }
[data-theme="light"] .sidebar-brand { border-bottom: 1px solid rgba(94, 76, 220, 0.15); }
[data-theme="light"] .sidebar-bottom { border-top: 1px solid rgba(94, 76, 220, 0.15); }
[data-theme="light"] .notification-item { background: rgba(94, 76, 220, 0.02); }
[data-theme="light"] .notification-item.unread { background: rgba(94, 76, 220, 0.05); border-left-color: #5E4CDC; }
[data-theme="light"] .popup-notification { background: rgba(255, 255, 255, 0.98); border: 1px solid rgba(94, 76, 220, 0.2); box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1); }

.sidebar-item.active-page > .sidebar-link, .sidebar-item.active-page > a.sidebar-link {
    background: linear-gradient(135deg, rgba(106, 90, 255, 0.2), rgba(106, 90, 255, 0.1));
    color: var(--text-light); border-left: 3px solid var(--primary-color); padding-left: 12px;
}
.sidebar-item.active-page > .sidebar-link i,
.sidebar-item.active-page > a.sidebar-link i {
    color: var(--primary-color);
    /* transform: scale(1.1);  <--- Удаляем или комментируем эту строку */
}
.submenu-link.active-subpage {
    background: rgba(106, 90, 255, 0.15); color: var(--primary-color);
    border-left: 2px solid var(--primary-color); padding-left: 48px;
}
.submenu-link.active-subpage i { color: var(--primary-color); transform: scale(1.1); }

.theme-indicator {
    font-size: 10px; padding: 2px 8px; border-radius: 8px; margin-left: auto;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    opacity: 0; transform: translateX(-10px); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); white-space: nowrap;
}
.sidebar-menu.expanded .theme-indicator { opacity: 1; transform: translateX(0); }
[data-theme="light"] .theme-indicator { background-color: rgba(0, 0, 0, 0.08); color: #5A5A5A; }
[data-theme="dark"] .theme-indicator { background-color: rgba(255, 255, 255, 0.1); color: #A0A0A0; }
[data-theme="auto"] .theme-indicator { background: linear-gradient(135deg, rgba(106, 90, 255, 0.1), rgba(255, 255, 255, 0.05)); color: var(--text-muted); }

/* ==========================================
   АДАПТИВНОСТЬ (MOBILE)
   ========================================== */
@media (max-width: 768px) {
    body {
        padding-top: 0; /* Контент начинается с самого верха */
    }

    /* Шапка теперь прозрачная и не перекрывает клики */
    .mobile-header {
        display: flex;
        justify-content: flex-end; /* Кнопка справа */
        align-items: flex-start; /* Кнопка сверху */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 0; /* Высота 0, чтобы не занимать место в потоке */
        padding: 20px; /* Отступы для кнопки */
        z-index: 1002;
        pointer-events: none; /* Пропускаем клики сквозь пустую область */
        box-sizing: border-box;
    }

    /* Сама кнопка - кликабельная */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--sidebar-bg); /* Фон кнопки (стекло) */
        backdrop-filter: blur(10px);
        color: var(--text-light);
        border: 1px solid var(--sidebar-border);
        border-radius: 8px; /* Скругленный квадрат */
        font-size: 22px;
        margin: 0;
        pointer-events: auto; /* Включаем клики для кнопки */
        box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    }

    /* Скрываем лого в сайдбаре */
    .sidebar-brand.desktop-only {
        display: none;
    }

    /* Меню на весь экран */
    .sidebar-menu {
        position: fixed;
        top: 0; /* Начинается от самого верха */
        left: 0;
        width: 100%;
        height: 100%; /* На всю высоту */
        height: 100dvh;
        transform: translateY(-150%);
        border-right: none;
        border-bottom: 1px solid var(--sidebar-border);
        box-shadow: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        z-index: 1001; /* Под кнопкой */
        visibility: hidden;
        padding-top: 80px; /* Отступ сверху, чтобы контент не наезжал на кнопку закрытия */
        padding-bottom: 40px;
    }

    .sidebar-menu.mobile-open {
        transform: translateY(0);
        visibility: visible;
    }

    .sidebar-menu .sidebar-text,
    .sidebar-menu .submenu-arrow,
    .sidebar-menu .brand-text,
    .theme-indicator {
        opacity: 1;
        transform: translateX(0);
    }

    /* Компактная сетка снизу */
    .sidebar-bottom {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 15px;
    }

    .sidebar-bottom .sidebar-item {
        margin: 0;
    }

    .sidebar-bottom .sidebar-profile-item {
        grid-column: 1 / -1;
    }

    .sidebar-bottom .sidebar-item:not(.sidebar-profile-item) .sidebar-link {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 15px 10px;
        gap: 8px;
        background: rgba(255, 255, 255, 0.03);
        height: 100%;
        justify-content: center;
    }

    .sidebar-bottom .sidebar-item:not(.sidebar-profile-item) i {
        font-size: 22px;
        margin-bottom: 0;
    }

    .sidebar-bottom .sidebar-item:not(.sidebar-profile-item) .sidebar-text {
        font-size: 0.85rem;
    }

    .sidebar-bottom .theme-indicator {
        display: none;
    }

    .sidebar-link::before, .sidebar-link::after {
        display: none !important;
    }

    .back-to-top {
        bottom: 80px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 380px) {
    .sidebar-bottom { gap: 8px; padding: 10px; }
    .sidebar-bottom .sidebar-item:not(.sidebar-profile-item) .sidebar-link { padding: 10px 5px; }
}