/*
 * MECHART v7.1
 * Desktop fixed navigation shell.
 *
 * >= 961px:
 * - topbar remains at the top
 * - left sidebar never scrolls with the main content
 * - only .workspace scrolls vertically
 *
 * <= 960px:
 * - restore the responsive/tablet/mobile document scrolling behavior
 */

@media (min-width: 961px) {
    html,
    body {
        height: 100%;
        overflow: hidden !important;
    }

    body {
        min-height: 100dvh;
    }

    .app {
        height: 100dvh !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .topbar {
        position: relative !important;
        top: auto !important;
        z-index: 500 !important;
        flex: 0 0 60px !important;
        height: 60px !important;
        min-height: 60px !important;
    }

    .body-grid {
        flex: 1 1 auto !important;
        height: calc(100dvh - 60px) !important;
        min-height: 0 !important;
        overflow: hidden !important;

        display: grid !important;
        grid-template-columns: var(--app-sidebar-width, 230px) minmax(0, 1fr) !important;
        align-items: stretch !important;
    }

    .left-sidebar {
        position: relative !important;
        top: auto !important;
        align-self: stretch !important;

        width: auto !important;
        height: 100% !important;
        max-height: none !important;
        min-height: 0 !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;

        scrollbar-width: thin;
    }

    /*
     * The right side becomes the only page-scrolling surface.
     * Every internal view (home / market / calendar / portfolio)
     * lives inside .workspace, so the sidebar remains fixed while
     * switching and scrolling between them.
     */
    .workspace {
        grid-column: 2 !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior-y: contain !important;
        -webkit-overflow-scrolling: touch;

        scrollbar-gutter: stable;
    }

    .app-view,
    .main-content,
    .home-dashboard,
    .calendar-main,
    .portfolio-main {
        min-height: 0 !important;
    }

    /* Prevent nested vertical page scroll containers from fighting .workspace. */
    .app-view {
        overflow: visible !important;
    }

    /* Keep dropdowns above the independently scrolling workspace. */
    .profile-menu-wrap,
    .profile-dropdown {
        z-index: 1300 !important;
    }
}

/*
 * Tablet/mobile:
 * The sidebar becomes the horizontal nav from responsive-stability.css.
 * Re-enable normal document scrolling so there is no trapped scroll area.
 */
@media (max-width: 960px) {
    html,
    body {
        height: auto !important;
        min-height: 100% !important;
        overflow-x: clip !important;
        overflow-y: auto !important;
    }

    .app {
        height: auto !important;
        min-height: 100dvh !important;
        overflow: visible !important;
    }

    .body-grid {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .left-sidebar {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .workspace {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        scrollbar-gutter: auto !important;
    }
}


/* ===== MECHART v7.4 original footer restoration ===== */
@media (min-width: 961px) {
    /*
     * The original footer now lives at the bottom of .workspace.
     * The sidebar stays fixed; the footer follows the right-side content
     * exactly like the old page footer instead of becoming a fixed bar.
     */
    .workspace > .site-footer {
        position: relative !important;
        inset: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;

        margin: 40px 0 0 !important;
        padding: 24px !important;
        box-sizing: border-box !important;

        display: block !important;
        overflow: visible !important;

        border-top: 1px solid rgba(255, 255, 255, .08) !important;
        background: transparent !important;
        box-shadow: none !important;

        text-align: center !important;
        z-index: auto !important;
    }

    .workspace > .site-footer .footer-links {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 18px !important;
        flex-wrap: wrap !important;

        width: 100% !important;
        margin: 0 0 10px !important;
        text-align: center !important;
    }

    .workspace > .site-footer .footer-links a,
    .workspace > .site-footer .footer-links span {
        color: #aeb8d0 !important;
        font-size: 12px !important;
        text-decoration: none !important;
        cursor: pointer !important;
    }

    .workspace > .site-footer .footer-copy {
        width: 100% !important;
        color: #7f8aa3 !important;
        font-size: 12px !important;
        text-align: center !important;
        white-space: normal !important;
        overflow: visible !important;
    }
}

@media (max-width: 960px) {
    .workspace > .site-footer {
        position: relative !important;
        inset: auto !important;
        width: 100% !important;
        margin: 32px 0 0 !important;
        padding: 22px 14px !important;
        border-top: 1px solid rgba(255, 255, 255, .08) !important;
        background: transparent !important;
        text-align: center !important;
    }

    .workspace > .site-footer .footer-links {
        display: flex !important;
        justify-content: center !important;
        gap: 14px !important;
        flex-wrap: wrap !important;
        margin-bottom: 10px !important;
    }

    .workspace > .site-footer .footer-copy {
        text-align: center !important;
    }
}
