.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-container h1 {
    font-size: 32px;
    margin-bottom: 30px;
    color: #333;
}

.dashboard-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.user-info-card,
.user-courses-card,
.user-progress-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.user-info-card h2,
.user-courses-card h2,
.user-progress-card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 10px;
}

#userInfo {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.info-label {
    font-weight: 500;
    color: #666;
}

.info-value {
    color: #333;
    font-weight: 600;
}

#userCourses {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-course-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #4a90e2;
    cursor: pointer;
    transition: background 0.2s;
}

.user-course-item:hover {
    background: #e3f2fd;
}

.user-course-item.locked {
    opacity: 0.6;
    border-left-color: #999;
    cursor: not-allowed;
}

.progress-item {
    margin-bottom: 20px;
}

.progress-bar-container {
    background: #e0e0e0;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    background: linear-gradient(90deg, #4a90e2, #357abd);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 500;
}

@media (max-width: 768px) {
    .dashboard-content {
        grid-template-columns: 1fr;
    }
}

/* Уведомления о новых сообщениях в ЛК */
.dashboard-messenger-unread-badge {
    display: inline-block;
    min-width: 20px;
    padding: 2px 7px;
    margin-left: 6px;
    border-radius: 10px;
    background: #e53935;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    vertical-align: middle;
}

.messenger-unread-notice {
    margin: 0 20px 12px;
    padding: 0;
}

.messenger-unread-notice__btn {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    display: block;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #3390ec, #2870c7);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 4px 14px rgba(51, 144, 236, 0.35);
    -webkit-tap-highlight-color: transparent;
}

.messenger-unread-notice__btn:active {
    filter: brightness(1.05);
}

@media (max-width: 768px) {
    .messenger-unread-notice {
        margin: 0 10px 10px;
    }
}

/* --- Только ЛК (dashboard.html): лишняя синяя кнопка «Навігація»; остальные страницы не затрагиваем --- */
body.page-user-dashboard #navToggle {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Меню ЛК сверху сайдбара (без лишнего отступа под «гамбургер», раздел «Книги» убран) */
body.page-user-dashboard #sidebar {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}

body.page-user-dashboard #sidebar .sidebar-nav {
    padding-top: 12px !important;
}

/* Хост для кнопки сворачивания: position:relative только здесь, не на #sidebar (иначе ломается fixed) */
body.page-user-dashboard .dashboard-sidebar-pin-host {
    position: relative;
    flex-shrink: 0;
    min-height: 44px;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 769px) {
    body.page-user-dashboard #sidebar .sidebar-nav.sidebar-nav--user-dashboard {
        padding-top: 8px !important;
    }
}

/* На мобилке ЛК сайдбар в потоке — кнопка «закрепить скрытие» только для десктопа */
@media (max-width: 768px) {
    body.page-user-dashboard #sidebarPinToggle,
    body.page-user-dashboard #sidebarUnhideFab {
        display: none !important;
    }
}

/* Мобилка: меню участника в потоке вместо скрытой панели без гамбургера */
@media (max-width: 768px) {
    body.page-user-dashboard #sidebar {
        position: relative;
        left: 0 !important;
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: none;
        padding-top: 56px;
        box-sizing: border-box;
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
        z-index: 1;
    }

    /* Фиксированная шапка внутри main — отступ без зарезервированного места под гамбургер */
    body.page-user-dashboard .main-content {
        padding-top: 88px;
    }
}

/* --- Мессенджер ЛК на телефоне: один экран — список ИЛИ чат (как в Telegram); десктоп не затрагивается --- */
body.page-user-dashboard .messenger-mobile-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 4px 0 0;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: #f0f0f0;
    color: #3390ec;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

body.page-user-dashboard .messenger-mobile-back-btn:active {
    background: #e0e0e0;
}

/* Десктоп ЛК: мессенджер не «висит» внизу из-за старой прокрутки; блок прижат к потоку под шапкой */
@media (min-width: 769px) {
    body.page-user-dashboard #messengerPage .messenger-container {
        margin-top: 0 !important;
        position: relative;
        top: 0;
        align-self: flex-start;
        width: 100%;
        max-width: 100%;
    }

    /* Вкладка «Мессенджер»: по ширине почти весь экран, выше по вертикали (меню ЛК скрыто скриптом) */
    body.page-user-dashboard.dashboard-messenger-tab .main-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    body.page-user-dashboard.dashboard-messenger-tab .admin-container {
        padding: 6px 8px 12px;
        max-width: none;
    }

    body.page-user-dashboard.dashboard-messenger-tab #messengerPage .messenger-container {
        height: calc(100vh - 92px);
        min-height: 400px;
        max-height: calc(100vh - 64px);
        border-radius: 6px;
    }
}

@media (max-width: 768px) {
    body.page-user-dashboard #messengerPage {
        padding: 0 !important;
        margin: 0 !important;
    }

    body.page-user-dashboard #messengerPage .messenger-container {
        flex-direction: column;
        height: auto;
        min-height: 0;
        max-height: none;
        border-radius: 0;
    }

    body.page-user-dashboard #messengerPage .messenger-sidebar {
        width: 100% !important;
        max-width: none;
        min-height: 0;
        flex: 1 1 auto;
        border-right: none;
    }

    /* Режим «только список» */
    body.page-user-dashboard #messengerPage .messenger-container:not(.messenger-mobile--chat-open) .messenger-chat-area {
        display: none !important;
    }

    /* Режим «открыт чат» — fullscreen */
    body.page-user-dashboard #messengerPage .messenger-container.messenger-mobile--chat-open {
        position: fixed;
        inset: 0;
        z-index: 2000;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
        height: 100svh;
        max-height: 100dvh;
        max-height: 100svh;
        border-radius: 0;
        margin: 0;
    }

    body.page-user-dashboard #messengerPage .messenger-container.messenger-mobile--chat-open .messenger-sidebar {
        display: none !important;
    }

    body.page-user-dashboard #messengerPage .messenger-container.messenger-mobile--chat-open .messenger-chat-area {
        display: flex !important;
        flex-direction: column;
        flex: 1 1 0;
        width: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
        height: auto;
        border-radius: 0;
        overflow: hidden;
    }

    body.page-user-dashboard #messengerPage .messenger-container.messenger-mobile--chat-open .messenger-mobile-back-btn {
        display: inline-flex;
    }

    body.page-user-dashboard #messengerPage .messenger-container.messenger-mobile--chat-open .messenger-chat-header {
        flex-wrap: nowrap;
        align-items: center;
        border-radius: 0;
    }

    body.page-user-dashboard #messengerPage .messenger-container.messenger-mobile--chat-open .messenger-messages {
        flex: 1 1 auto;
        min-height: 0;
    }

    body.page-user-dashboard #messengerPage .messenger-container.messenger-mobile--chat-open .messenger-input-area {
        width: 100%;
        border-radius: 0;
    }

    /* Вкладка «Мессенджер»: убрать «резиновые» пустоты сверху/снизу — блок тянется по контенту и высоте экрана */
    body.page-user-dashboard.dashboard-messenger-tab .main-content {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }

    body.page-user-dashboard.dashboard-messenger-tab .admin-container {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: min(100vh - 88px, 100dvh - 88px);
        padding: 0 8px 8px;
        box-sizing: border-box;
    }

    body.page-user-dashboard.dashboard-messenger-tab #messengerPage {
        flex: 1 1 auto;
        display: flex !important;
        flex-direction: column;
        min-height: 0;
    }

    body.page-user-dashboard.dashboard-messenger-tab #messengerPage .messenger-container {
        flex: 1 1 auto;
        min-height: 0 !important;
        max-height: none;
    }

    body.page-user-dashboard.dashboard-messenger-tab #messengerPage .messenger-sidebar {
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }

    body.page-user-dashboard.dashboard-messenger-tab #messengerPage .messenger-chat-list {
        flex: 1 1 auto;
        min-height: 0;
    }
}
