/* ═══════════════════════════════════════════════════════════
   SHARED MOBILE NAVIGATION — Aion-style fullscreen overlay
    Used on all pages except Aion (which has its own version).
    Active below desktop width.
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 759px) {
    html.board-page,
    body.board-page,
    body.charts-page,
    html.page--home,
    html.page--news {
        --shared-mobile-topbar-height: 3rem;
    }
    html.board-page #main-navbar,
    body.board-page #main-navbar,
    body.charts-page #main-navbar,
    html.page--home #main-navbar,
    html.page--news #main-navbar {
        display: none !important;
    }
    html.board-page #page_content_wrapper,
    body.board-page #page_content_wrapper,
    body.charts-page #page_content_wrapper,
    html.page--home #page_content_wrapper,
    html.page--news #page_content_wrapper {
        padding-top: 0 !important;
    }
    body.board-page.login-page #page_content_wrapper > main {
        height: auto !important;
        min-height: calc(100vh - var(--shared-mobile-topbar-height, 3rem) - env(safe-area-inset-top, 0px)) !important;
        min-height: calc(100dvh - var(--shared-mobile-topbar-height, 3rem) - env(safe-area-inset-top, 0px)) !important;
        padding-top: calc(var(--shared-mobile-topbar-height, 3rem) + env(safe-area-inset-top, 0px) + 0.75rem) !important;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem) !important;
        overflow: visible !important;
        align-items: center !important;
    }
    body.charts-page.login-page #page_content_wrapper > main {
        height: auto !important;
        min-height: calc(100vh - var(--shared-mobile-topbar-height, 3rem) - env(safe-area-inset-top, 0px)) !important;
        min-height: calc(100dvh - var(--shared-mobile-topbar-height, 3rem) - env(safe-area-inset-top, 0px)) !important;
        padding-top: calc(var(--shared-mobile-topbar-height, 3rem) + env(safe-area-inset-top, 0px) + 0.75rem) !important;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem) !important;
        overflow: visible !important;
        align-items: center !important;
    }
    .mobile-nav-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 1200;
        pointer-events: none;
    }
    .mobile-nav-overlay.is-open {
        display: block;
        pointer-events: auto;
    }
    #mobile-nav-backdrop {
        position: absolute;
        inset: 0;
    }

    /* Navigation Panel animation */
    #mobile-nav-panel { transition: opacity 0.2s ease-out; }
    #mobile-nav-backdrop { transition: opacity 0.3s ease; }
    #mobile-nav-panel a.active { background: rgba(147, 51, 234, 0.12); }

    /* Nav panel background */
    #mobile-nav-panel {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: auto;
        width: min(100vw, 24rem);
        max-width: 24rem;
        background: radial-gradient(circle at top, rgba(88, 101, 242, 0.08), transparent 30%),
                    linear-gradient(180deg, #020617 0%, #050816 100%);
        border-right: 1px solid rgba(51, 65, 85, 0.55);
        box-shadow: 24px 0 60px rgba(2, 6, 23, 0.38);
    }

    /* Shell + Header */
    .mobile-nav-shell { display: flex; min-height: 100%; flex: 1; flex-direction: column; }
    .mobile-nav-header {
        display: flex; align-items: center;
        justify-content: space-between;
        padding: calc(env(safe-area-inset-top, 0px) + 0.6rem) 0.5rem 0.5rem 1rem;
        border-bottom: 1px solid rgba(51, 65, 85, 0.4);
    }
    .mobile-nav-header__user { display: flex; align-items: center; gap: 0.625rem; min-width: 0; }
    .mobile-nav-header__avatar { width: 2rem; height: 2rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
    .mobile-nav-header__name { font-size: 0.88rem; font-weight: 600; color: #f1f5f9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Back button (← Zurück) — mirrors chart-more-header__back */
    .mobile-nav-header .chart-more-header__back {
        display: inline-flex; align-items: center; gap: 0.35rem;
        height: 2rem; padding: 0 0.65rem; border-radius: 0.65rem;
        background: transparent; border: none; color: #cbd5e1; flex-shrink: 0;
        font-size: 0.78rem; font-weight: 600; cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.18s ease, transform 0.18s ease, background 0.18s ease;
    }
    .mobile-nav-header .chart-more-header__back svg {
        width: 1.25rem; height: 1.25rem; flex-shrink: 0;
    }
    .mobile-nav-header .chart-more-header__back:active {
        color: #ffffff; background: rgba(59, 130, 246, 0.12);
        transform: translateX(-1px) scale(0.98);
    }
    @media (hover: hover) {
        .mobile-nav-header .chart-more-header__back:hover {
            color: #ffffff; background: rgba(59, 130, 246, 0.08);
            transform: translateX(-1px);
        }
    }

    /* Close button (X) — mirrors chart-more-header__close */
    .mobile-nav-header .chart-more-header__close {
        display: inline-flex; align-items: center; justify-content: center;
        width: 2.25rem; height: 2.25rem; border-radius: 0.75rem;
        border: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(255, 255, 255, 0.04); color: #e2e8f0;
        cursor: pointer; flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
    }
    .mobile-nav-header .chart-more-header__close:active {
        transform: scale(0.97);
    }
    @media (hover: hover) {
        .mobile-nav-header .chart-more-header__close:hover {
            color: #ffffff; background: rgba(255, 255, 255, 0.08);
            border-color: rgba(255, 255, 255, 0.14);
        }
    }

    /* Scroll area */
    .mobile-nav-scroll { display: flex; flex: 1; flex-direction: column; gap: 1rem; overflow-y: auto; padding: 0.5rem 0 1.5rem; }

    /* Sections */
    .mobile-nav-section { display: flex; flex-direction: column; gap: 0.125rem; padding-top: 0.625rem; border-top: 1px solid rgba(255, 255, 255, 0.06); }
    .mobile-nav-section:first-child { border-top: none; padding-top: 0; }
    .mobile-nav-section-label { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(148, 163, 184, 0.7); padding: 0.25rem 0.75rem; }
    .mobile-nav-list { display: flex; flex-direction: column; gap: 0; }

    /* Row item */
    .mobile-nav-row {
        position: relative; display: flex; align-items: center; gap: 0.625rem;
        padding: 0.5rem 0.75rem; border-radius: 0; color: #ffffff;
        text-decoration: none; transition: background 0.15s, color 0.15s;
        cursor: pointer; appearance: none; -webkit-appearance: none;
        border: none; background: transparent; width: 100%; text-align: left; font: inherit;
    }
    #mobile-nav-panel a.mobile-nav-row { color: #ffffff !important; }
    #mobile-nav-panel a.mobile-nav-row.mobile-nav-row--danger { color: #fca5a5 !important; }
    .mobile-nav-row__icon {
        display: flex; width: 1.75rem; height: 1.75rem;
        min-width: 1.75rem; min-height: 1.75rem; max-width: 1.75rem; max-height: 1.75rem;
        align-items: center; justify-content: center; border-radius: 0.45rem;
        background: rgba(255, 255, 255, 0.05); flex-shrink: 0; overflow: hidden;
    }
    .mobile-nav-row__icon svg { width: 0.95rem; height: 0.95rem; flex-shrink: 0; }
    .mobile-nav-row__label { flex: 1; color: inherit; text-align: left; font-size: 0.84rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-nav-row__value { max-width: 7rem; color: rgba(148, 163, 184, 0.82); text-align: right; font-size: 0.74rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-nav-row__chevron { width: 0.8rem; height: 0.8rem; color: rgba(148, 163, 184, 0.4); flex-shrink: 0; }

    /* Color variants per page */
    .mobile-nav-row--home .mobile-nav-row__icon  { color: #cbd5e1; background: rgba(148, 163, 184, 0.1); }
    .mobile-nav-row--news .mobile-nav-row__icon  { color: #93c5fd; background: rgba(59, 130, 246, 0.1); }
    .mobile-nav-row--board .mobile-nav-row__icon { color: #6ee7b7; background: rgba(16, 185, 129, 0.1); }
    .mobile-nav-row--aion .mobile-nav-row__icon  { color: #c4b5fd; background: rgba(147, 51, 234, 0.1); }
    .mobile-nav-row--install .mobile-nav-row__icon { color: #a78bfa; background: rgba(124, 58, 237, 0.16); }
    .mobile-nav-row--charts .mobile-nav-row__icon { color: #67e8f9; background: rgba(6, 182, 212, 0.1); }
    .mobile-nav-row--portal .mobile-nav-row__icon { color: #fbbf24; background: rgba(245, 158, 11, 0.1); }
    .mobile-nav-row--theme .mobile-nav-row__icon  { color: #fcd34d; background: rgba(245, 158, 11, 0.1); }
    .mobile-nav-row--support .mobile-nav-row__icon { color: #86efac; background: rgba(34, 197, 94, 0.1); }

    /* Active state */
    .mobile-nav-row.active { background: rgba(147, 51, 234, 0.12); color: #ffffff; }
    .mobile-nav-row.active .mobile-nav-row__icon { background: rgba(147, 51, 234, 0.18); color: #e9d5ff; }

    /* Danger */
    .mobile-nav-row--danger { color: #fca5a5 !important; background: transparent; }
    .mobile-nav-row--danger .mobile-nav-row__icon { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }

    /* Footer section */
    .mobile-nav-section--footer { margin-top: auto; padding-top: 0.625rem; border-top: 1px solid rgba(255, 255, 255, 0.06); }

    /* Hover states */
    @media (hover: hover) {
        .mobile-nav-row:hover { background: rgba(255, 255, 255, 0.05); color: #ffffff; }
        .mobile-nav-row--danger:hover { background: rgba(239, 68, 68, 0.08); color: #fecaca !important; }
    }

    /* Hamburger button in navbar */
    #global-mobile-nav-hamburger {
        display: inline-flex;
    }

    .shared-mobile-topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: var(--shared-mobile-topbar-height, 3rem);
        padding: 0 0.5rem;
        background:
            radial-gradient(circle at top, rgba(88, 101, 242, 0.08), transparent 52%),
            linear-gradient(180deg, rgba(2, 6, 23, 0.96) 0%, rgba(5, 8, 22, 0.94) 100%);
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        box-shadow: 0 10px 28px rgba(2, 6, 23, 0.22);
    }
    .shared-mobile-topbar > .shared-mobile-topbar__button:first-child {
        order: 3;
    }
    .shared-mobile-topbar__title {
        order: 2;
    }
    .shared-mobile-topbar__spacer,
    .shared-mobile-topbar > .shared-mobile-topbar__button:not(:first-child) {
        order: 1;
    }
    .shared-mobile-topbar__title {
        min-width: 0;
        flex: 1;
        padding: 0 0.75rem;
        text-align: center;
        color: #f8fafc;
        font-size: 0.88rem;
        font-weight: 700;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .shared-mobile-topbar__button,
    .shared-mobile-topbar__spacer {
        width: 2.25rem;
        height: 2.25rem;
        min-width: 2.25rem;
        min-height: 2.25rem;
        flex-shrink: 0;
    }
    .shared-mobile-topbar__spacer {
        pointer-events: none;
    }
    .shared-mobile-topbar__button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 0.75rem;
        background: rgba(255, 255, 255, 0.04);
        color: #e2e8f0;
        cursor: pointer;
        transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, color 0.18s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .shared-mobile-topbar__button svg {
        width: 1.15rem;
        height: 1.15rem;
        flex-shrink: 0;
    }
    .shared-mobile-topbar__button:active {
        transform: scale(0.97);
    }
    @media (hover: hover) {
        .shared-mobile-topbar__button:hover {
            background: rgba(255, 255, 255, 0.08);
            border-color: rgba(255, 255, 255, 0.14);
            color: #ffffff;
        }
    }
    html.theme-light .shared-mobile-topbar {
        background:
            radial-gradient(circle at top, rgba(59, 130, 246, 0.08), transparent 52%),
            linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(241, 245, 249, 0.94) 100%);
        border-bottom-color: rgba(15, 23, 42, 0.08);
        box-shadow: 0 12px 28px rgba(148, 163, 184, 0.22);
    }
    html.theme-light .shared-mobile-topbar__title {
        color: #0f172a;
    }
    html.theme-light .shared-mobile-topbar__button {
        background: rgba(15, 23, 42, 0.04);
        border-color: rgba(15, 23, 42, 0.08);
        color: #0f172a;
    }
    html.theme-light .mobile-nav-header .chart-more-header__close {
        background: rgba(15, 23, 42, 0.04);
        border-color: rgba(15, 23, 42, 0.08);
        color: #0f172a;
    }
    @media (hover: hover) {
        html.theme-light .shared-mobile-topbar__button:hover {
            background: rgba(15, 23, 42, 0.08);
            border-color: rgba(15, 23, 42, 0.14);
        }
        html.theme-light .mobile-nav-header .chart-more-header__close:hover {
            background: rgba(15, 23, 42, 0.08);
            border-color: rgba(15, 23, 42, 0.14);
            color: #0f172a;
        }
    }

    .shared-mobile-topbar > .shared-mobile-topbar__button:first-child,
    #global-mobile-nav-hamburger {
        width: 2.25rem !important;
        height: 2.25rem !important;
        min-width: 2.25rem !important;
        min-height: 2.25rem !important;
        border-radius: 0.5rem !important;
        border: 1px solid rgba(71, 85, 105, 0.55) !important;
        background: rgba(255, 255, 255, 0.04) !important;
        color: #ffffff !important;
    }

    .shared-mobile-topbar > .shared-mobile-topbar__button:first-child svg,
    #global-mobile-nav-hamburger svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }

    @media (hover: hover) {
        .shared-mobile-topbar > .shared-mobile-topbar__button:first-child:hover,
        #global-mobile-nav-hamburger:hover {
            background: rgba(255, 255, 255, 0.08) !important;
            border-color: rgba(100, 116, 139, 0.68) !important;
            color: #ffffff !important;
        }
    }

    html.theme-light .shared-mobile-topbar > .shared-mobile-topbar__button:first-child,
    html.theme-light #global-mobile-nav-hamburger {
        background: rgba(15, 23, 42, 0.04) !important;
        color: #0f172a !important;
    }

    @media (hover: hover) {
        html.theme-light .shared-mobile-topbar > .shared-mobile-topbar__button:first-child:hover,
        html.theme-light #global-mobile-nav-hamburger:hover {
            background: rgba(15, 23, 42, 0.08) !important;
        }
    }

    /* Light-mode: nav panel background, rows, danger/logout row */
    html.theme-light #mobile-nav-panel {
        background: #ffffff !important;
        border-right-color: rgba(15, 23, 42, 0.08) !important;
        box-shadow: 24px 0 60px rgba(15, 23, 42, 0.12) !important;
    }
    html.theme-light .mobile-nav-header {
        border-bottom-color: rgba(15, 23, 42, 0.08) !important;
    }
    html.theme-light .mobile-nav-header__name {
        color: #0f172a !important;
    }
    html.theme-light .mobile-nav-section {
        border-top-color: rgba(15, 23, 42, 0.07) !important;
    }
    html.theme-light .mobile-nav-section-label {
        color: #94a3b8 !important;
    }
    html.theme-light .mobile-nav-row {
        color: #1e293b !important;
    }
    html.theme-light #mobile-nav-panel a.mobile-nav-row {
        color: #1e293b !important;
    }
    html.theme-light .mobile-nav-row__icon {
        background: rgba(15, 23, 42, 0.05) !important;
        color: #475569 !important;
    }
    /* Logout / danger row — must be clearly red, not invisible */
    html.theme-light .mobile-nav-row--danger,
    html.theme-light #mobile-nav-panel a.mobile-nav-row.mobile-nav-row--danger {
        color: #dc2626 !important;
    }
    html.theme-light .mobile-nav-row--danger .mobile-nav-row__icon {
        background: rgba(239, 68, 68, 0.08) !important;
        color: #dc2626 !important;
    }
    html.theme-light .mobile-nav-row--support .mobile-nav-row__icon {
        background: rgba(22, 163, 74, 0.08) !important;
        color: #16a34a !important;
    }
    html.theme-light .mobile-nav-row--install .mobile-nav-row__icon {
        background: rgba(124, 58, 237, 0.1) !important;
        color: #7c3aed !important;
    }
    html.theme-light .mobile-nav-section--footer {
        border-top-color: rgba(15, 23, 42, 0.07) !important;
    }
    @media (hover: hover) {
        html.theme-light .mobile-nav-row:hover {
            background: rgba(15, 23, 42, 0.04) !important;
            color: #0f172a !important;
        }
        html.theme-light .mobile-nav-row--danger:hover {
            background: rgba(239, 68, 68, 0.06) !important;
            color: #b91c1c !important;
        }
    }
}

/* Hide hamburger button on desktop */
@media (min-width: 760px) {
    #global-mobile-nav-hamburger {
        display: none !important;
    }
    .mobile-nav-overlay {
        display: none !important;
    }
    .shared-mobile-topbar {
        display: none !important;
    }
}
