/* Header and sidebar share an exact viewport boundary. */
#mainNav {
    position: sticky;
    top: 0;
    z-index: 1030;
    flex-shrink: 0;
    background-color: #392d41;
}

/* Sidebar Structure */
.ghost-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    background-color: #1a0e20; /* fallback */
    background: rgba(25, 15, 30, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.ghost-sidebar.open {
    transform: translateX(0);
}

.ghost-sidebar-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 20px 10px;
}

/* Mobile Header */
.ghost-sidebar-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px 20px 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1.1rem;
}

.ghost-sidebar-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
}
.ghost-sidebar-close:hover {
    color: #fff;
}

/* Desktop override */
@media (min-width: 992px) {
    .ghost-sidebar {
        transform: translateX(0);
        z-index: 1020;
        top: var(--ghost-sidebar-top, 90px);
        bottom: auto;
        height: var(--ghost-sidebar-height, calc(100dvh - 90px));
        background: transparent;
        backdrop-filter: none;
        border-right: none;
    }

    .has-sidebar .ghost-content,
    .has-sidebar > .container {
        margin-left: 72px;
    }

    .has-sidebar footer.footer { margin-left: 72px; }

    .ghost-sidebar-mobile-header {
        display: none;
    }
}

/* Sidebar Navigation Items */
.ghost-sidebar-section {
    margin-bottom: 25px;
}

.ghost-sidebar-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.3);
    margin: 0 10px 10px 10px;
    font-weight: 600;
}

.ghost-sidebar-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 2px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    border-radius: 12px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.ghost-sidebar-item:hover, .ghost-sidebar-item:focus {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    text-decoration: none;
}

.ghost-sidebar-item.active, .ghost-sidebar-item[aria-current="page"] {
    background: #fff;
    color: #000 !important;
    font-weight: 600;
}
.ghost-sidebar-item.active .ghost-sidebar-count,
.ghost-sidebar-item[aria-current="page"] .ghost-sidebar-count {
    color: #666;
}

.ghost-sidebar-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Fix massive inline SVGs */
.ghost-sidebar-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.ghost-sidebar-icon img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ghost-sidebar-icon i {
    font-size: 1.1rem;
}

.ghost-sidebar-label {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ghost-sidebar-badge {
    background: #00d26a;
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 20px;
    margin-left: 8px;
}

.ghost-sidebar-count {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
    margin-left: 8px;
}

/* Tags */
.ghost-sidebar-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 10px;
}

.ghost-sidebar-tag {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.ghost-sidebar-tag:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    text-decoration: none;
}

.ghost-sidebar-tag.active {
    background: #b5a9cd;
    color: #1a0e20;
    font-weight: 600;
}

/* Links Section */
.ghost-sidebar-links a {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.ghost-sidebar-links a i {
    margin-right: 10px;
    font-size: 1rem;
}

.ghost-sidebar-links a:hover {
    color: #fff;
    text-decoration: none;
}

/* Language Dropdown */
.ghost-sidebar-language {
    padding: 0 10px;
    margin-bottom: 20px;
}
.ghost-sidebar-language summary {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 0.85rem;
    list-style: none;
}
.ghost-sidebar-language summary::-webkit-details-marker {
    display: none;
}
.ghost-sidebar-language summary i {
    margin-right: 10px;
    font-size: 1rem;
}
.ghost-sidebar-language summary span {
    flex-grow: 1;
}
.ghost-sidebar-language summary strong {
    color: #fff;
}
.ghost-sidebar-language-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
    padding-left: 26px;
}
.ghost-sidebar-language-options a {
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    text-decoration: none;
}
.ghost-sidebar-language-options a:hover,
.ghost-sidebar-language-options a.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Separator */
.ghost-sidebar-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 15px 10px;
}

/* Copyright */
.ghost-sidebar-copyright {
    padding: 0 10px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.2);
    text-align: center;
    margin-top: auto;
}

/* Overlay */
.ghost-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1030;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    border: none;
    cursor: pointer;
}

body.sidebar-open .ghost-sidebar-overlay {
    display: block;
    opacity: 1;
}

/* Navbar Toggle Button */
.ghost-sidebar-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    margin-right: 15px;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

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

@media (min-width: 992px) {
    .ghost-sidebar-toggle {
        display: none !important; /* Hide toggle button on desktop */
    }

    .ghost-sidebar {
        width: 72px;
        overflow: hidden;
        transition: width 0.16s ease-out, background-color 0.16s ease-out;
    }

    /* Keep the contents at their expanded size. Only the right edge reveals;
       icons, rows, headings and scroll position never reflow on hover. */
    .ghost-sidebar-inner {
        box-sizing: border-box;
        width: 250px;
        min-width: 250px;
        overflow-x: hidden;
        scrollbar-gutter: stable;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    }

    .ghost-sidebar-item {
        height: 44px;
        box-sizing: border-box;
        justify-content: flex-start;
        position: relative;
        isolation: isolate;
    }

    .ghost-sidebar-item:hover,
    .ghost-sidebar-item:focus,
    .ghost-sidebar-item.active,
    .ghost-sidebar-item[aria-current="page"] {
        background: transparent;
    }

    /* Paint the highlight separately so the compact tile has a rounded
       right edge without changing the row or moving its icon. */
    .ghost-sidebar-item::before {
        content: "";
        position: absolute;
        z-index: -1;
        left: 4px;
        top: 4px;
        width: calc(100% - 8px);
        height: 36px;
        border-radius: 10px;
        pointer-events: none;
        transition: width 0.16s ease-out, background-color 0.12s ease-out;
    }

    .ghost-sidebar-item:hover::before,
    .ghost-sidebar-item:focus::before {
        background: rgba(255, 255, 255, 0.05);
    }

    .ghost-sidebar-item.active::before,
    .ghost-sidebar-item[aria-current="page"]::before {
        background: #fff;
    }

    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-item::before {
        width: 40px;
    }

    /* Use the same larger artwork in both states, keeping its center fixed. */
    .ghost-sidebar-icon svg {
        width: 24px;
        height: 24px;
    }

    .ghost-sidebar-icon img {
        width: 32px;
        height: 32px;
        max-width: none;
        max-height: none;
        flex-shrink: 0;
    }

    .ghost-sidebar-icon i {
        font-size: 24px;
        line-height: 1;
    }

    .ghost-sidebar-links a {
        height: 40px;
        box-sizing: border-box;
        white-space: nowrap;
    }

    .ghost-sidebar-links a i,
    .ghost-sidebar-language summary i {
        flex: 0 0 24px;
        width: 24px;
        margin-right: 12px;
        text-align: center;
        font-size: 22px;
    }

    .ghost-sidebar-language { padding: 0 12px; }
    .ghost-sidebar-language summary { min-height: 40px; }

    /* Keep tags discoverable as compact chips instead of an empty section. */
    .ghost-sidebar-tags { flex-direction: column; align-items: flex-start; padding: 0 4px; }
    .ghost-sidebar-tag {
        box-sizing: border-box;
        width: 100%;
        height: 30px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-tag { width: 40px; padding: 4px; text-align: center; }

    .ghost-sidebar-label,
    .ghost-sidebar-badge,
    .ghost-sidebar-count {
        transition: opacity 0.12s ease-out;
    }

    .ghost-sidebar:hover, .ghost-sidebar:focus-within {
        width: 250px;
        background: #1a0e20;
    }

    .has-sidebar .ghost-content,
    .has-sidebar > .container {
        margin-left: 72px;
    }

    /* Retain label geometry and accessible link names in the compact rail. */
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-label,
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-badge,
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-count,
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-links a span,
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-language summary span,
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-language summary strong {
        opacity: 0;
    }

    /* Preserve section spacing without leaving invisible controls clickable. */
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-heading,
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-language-options,
    .ghost-sidebar:not(:hover):not(:focus-within) .ghost-sidebar-copyright {
        visibility: hidden;
    }

}

.ghost-sidebar-search { margin: 0 0 20px; }
.ghost-sidebar-search input { width: 100%; min-width: 0; border-radius: 10px; }
body.sidebar-open { overflow: hidden; }
@media (min-width: 992px) {
    .ghost-sidebar-search { display: none; }
    body.sidebar-open .ghost-sidebar-overlay { display: none; }
}
@media (max-width: 991.98px) {
    #mainNav > .container-fluid { flex-wrap: nowrap; gap: 10px; }
    #mainNav .ghost-sidebar-toggle { flex: 0 0 42px; width: 42px; height: 42px; padding: 0; margin: 0; }
    #mainNav .navbar-brand { flex: 1 1 auto; min-width: 0; margin: 0; overflow: hidden; }
    #mainNav .site-logo { display: block; width: auto; max-width: 100%; height: auto; max-height: 42px; object-fit: contain; }
    #mainNav .ghost-header-account { flex: 0 0 40px; width: 40px; }
    #mainNav .ghost-header-account .user-avatar { width: 40px; height: 40px; margin: 0; }
    #mainNav .ghost-header-account .user-avatar img { width: 100%; height: 100%; object-fit: cover; }
    #mainNav .ghost-header-account .nav-link { padding: 0; }
    #mainNav .ghost-header-account .b-login { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
    #mainNav #nav-menu { display: none !important; }
    .ghost-sidebar { width: min(280px, calc(100vw - 44px)); z-index: 1060; height: 100dvh; }
    .ghost-sidebar-overlay { z-index: 1050; }
}
@media (prefers-reduced-motion: reduce) {
    .ghost-sidebar, .ghost-sidebar-overlay,
    .ghost-sidebar-item::before,
    .ghost-sidebar-label, .ghost-sidebar-badge, .ghost-sidebar-count { transition: none; }
}
