/* ========================================
   VerticalNavMenu — the site's primary navigation
   ----------------------------------------
   Class prefix: .vnav-*  (kept isolated from navbar.css, which now only
   holds the shared profile / dropdown / badge classes this file reuses).

   Collapsed state is driven by `body.vnav-active-collapsed`, not by a class
   on .vnav-root — the pre-boot script in App.razor sets it from localStorage
   before Blazor renders, so the rail width and the content offset always
   agree on first paint.
   ======================================== */

/* Sidebar width lives here only: the rail width, the body offset that clears it
   and the popover offsets measured from it all have to agree. */
:root {
    --vnav-w: 288px;
    --vnav-w-collapsed: 72px;
}

/* --- Body-level shift so main content clears the fixed sidebar --------- */
body.vnav-active {
    padding-left: var(--vnav-w);
    transition: padding-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.vnav-active.vnav-active-collapsed {
    padding-left: var(--vnav-w-collapsed);
}

@media (max-width: 767.98px) {
    body.vnav-active,
    body.vnav-active.vnav-active-collapsed {
        padding-left: 0;
        padding-top: 64px; /* room for the mobile top-bar */
    }
}

/* --- Root wrapper (holds sidebar + mobile bits) ------------------------ */
.vnav-root {
    position: relative;
}

/* --- Sidebar surface --------------------------------------------------- */
.vnav-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--vnav-w);
    z-index: 1030;
    display: flex;
    flex-direction: column;
    background: rgba(15, 22, 33, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
    /* overflow: visible so footer popovers (notifications, sponsor progress) can
       render past the sidebar's right edge. backdrop-filter above makes this
       element the containing block for their `position: fixed`, so `overflow`
       here also controls their clipping. Inner scrolling stays scoped to
       `.vnav-nav` which owns its own overflow-y/-x below. */
    overflow: visible;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.vnav-active-collapsed .vnav-sidebar {
    width: var(--vnav-w-collapsed);
}

/* --- Header (logo + toggle) ------------------------------------------- */
.vnav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 0.75rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.vnav-brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    overflow: hidden;
}

.vnav-brand img {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed: stack logo above the toggle so both stay visible in the 72px column. */
.vnav-active-collapsed .vnav-header {
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.6rem 0.25rem 0.4rem;
    justify-content: center;
}

.vnav-active-collapsed .vnav-brand img {
    width: 40px;
    height: 30px;
}

.vnav-toggle,
.vnav-mobile-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.vnav-toggle:hover,
.vnav-mobile-close:hover {
    background: rgba(13, 202, 240, 0.15);
    border-color: rgba(13, 202, 240, 0.5);
    color: #fff;
}

/* --- User block (avatar / role / wallet), pinned under the header ------ */
.vnav-user {
    flex-shrink: 0;
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Matches .vnav-wallet below so the two read as a pair of controls. */
.vnav-user-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.4rem 0.55rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Bootstrap 5 puts `.show` on the toggle, not on the `.dropdown` wrapper, so a
   `.dropdown.show >` selector silently never matches; aria-expanded is the same
   state expressed as the ARIA contract. */
.vnav-user-btn:hover,
.vnav-user-btn[aria-expanded="true"] {
    background: rgba(13, 202, 240, 0.12);
    border-color: rgba(13, 202, 240, 0.45);
    color: #fff;
}

.vnav-user-btn:hover .nav-profile-avatar,
.vnav-user-btn[aria-expanded="true"] .nav-profile-avatar {
    border-color: rgba(13, 202, 240, 0.5);
}

/* min-width:0 lets the flex child shrink so Bootstrap's .text-truncate can fire. */
.vnav-user-text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.2;
}

/* The caret carries .vnav-label (to hide in the rail), which would otherwise
   grow it to fill the row and leave the chevron floating mid-button. */
.vnav-user-btn .nav-profile-caret {
    flex: 0 0 auto;
}

.vnav-user-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vnav-wallet {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.55rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.vnav-wallet:hover {
    background: rgba(13, 202, 240, 0.12);
    border-color: rgba(13, 202, 240, 0.45);
    color: #fff;
}

.vnav-wallet-amount {
    font-variant-numeric: tabular-nums;
}

.vnav-wallet-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-left: auto;
    border-radius: 50%;
    background: rgba(13, 202, 240, 0.18);
    border: 1px solid rgba(13, 202, 240, 0.35);
    color: #0dcaf0;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.vnav-wallet:hover .vnav-wallet-plus {
    background: rgba(13, 202, 240, 0.35);
    border-color: rgba(13, 202, 240, 0.7);
    color: #fff;
}

.vnav-user-icons {
    margin-left: auto;
}

/* --- Section divider inside the nav list ------------------------------ */
.vnav-divider {
    height: 1px;
    margin: 0.5rem 0.4rem;
    background: rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}

/* --- Nav list scrollable region --------------------------------------- */
.vnav-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.vnav-nav::-webkit-scrollbar {
    width: 6px;
}

.vnav-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.vnav-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(13, 202, 240, 0.4);
}

/* --- Top-level nav items (direct link + section toggle) --------------- */
.vnav-link,
.vnav-section-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.6rem;
    background: transparent;
    border: 0;
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    text-align: left;
    letter-spacing: 0.5px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease, color 0.2s ease, padding 0.2s ease;
}

.vnav-link:hover,
.vnav-section-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.vnav-link.active {
    color: #0dcaf0;
    background: rgba(13, 202, 240, 0.1);
}

.vnav-link.active::before,
.vnav-section-toggle[aria-expanded="true"]::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    background: #0dcaf0;
    border-radius: 0 2px 2px 0;
}

/* --- Sub-nav (expandable section body) --------------------------------
   Blazor owns the open state (`.vnav-open-section`). The 0fr->1fr grid-row
   trick animates to the content's natural height, which a max-height
   transition cannot do without hardcoding a guess. */
.vnav-subnav {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.vnav-subnav.vnav-open-section {
    grid-template-rows: 1fr;
}

/* min-height:0 is required or the grid row refuses to shrink below content height. */
.vnav-subnav-inner {
    overflow: hidden;
    min-height: 0;
    padding: 0.2rem 0 0.3rem 0.4rem;
    margin-left: 0.6rem;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.vnav-sublink {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.6rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 0.4rem;
    transition: background-color 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}

.vnav-sublink:hover {
    background: rgba(13, 202, 240, 0.1);
    color: #fff;
    padding-left: 0.85rem;
}

.vnav-sublink.active {
    color: #0dcaf0;
    background: rgba(13, 202, 240, 0.12);
}

.vnav-subnav-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.6rem 0.15rem;
    margin-top: 0.15rem;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* --- Icons + labels (fixed icon column so labels align) --------------- */
.vnav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    flex-shrink: 0;
    opacity: 0.85;
}

.vnav-link:hover .vnav-icon,
.vnav-section-toggle:hover .vnav-icon,
.vnav-sublink:hover .vnav-icon {
    opacity: 1;
}

.vnav-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transition: opacity 0.15s ease;
}

/* --- SVG icons (weapons / knives / gloves / agents) -------------------- */
.vnav-svg-icon .skins-menu-item {
    height: 16px;
    max-width: 22px;
    width: auto;
}

/* --- Section caret ---------------------------------------------------- */
.vnav-section-caret {
    margin-left: auto;
    opacity: 0.6;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.vnav-section-toggle[aria-expanded="true"] .vnav-section-caret {
    transform: rotate(180deg);
    opacity: 1;
}

/* --- NAUJAS badge slot inside a sublink ------------------------------- */
.vnav-badge {
    margin-left: auto;
    flex-shrink: 0;
}

/* --- Footer (players online + Discord) -------------------------------- */
.vnav-footer {
    flex-shrink: 0;
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.vnav-players,
.vnav-discord {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.6rem;
    border-radius: 0.5rem;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Both footer cards use the app's info/banner surface language (a 135deg gradient,
   as in .info-banner / .stat-card-info), not the flat .vnav-link.active tint — that
   one reads as a "you are here" nav highlight, which these are not. */
.vnav-players {
    background: linear-gradient(135deg, rgba(13, 202, 240, 0.15) 0%, rgba(13, 202, 240, 0.05) 100%);
    border-color: rgba(13, 202, 240, 0.3);
    color: rgba(255, 255, 255, 0.85);
}

/* Deliberately no `.active` variant, even though this is a NavLink: the Discord card
   beside it is a plain <a> and never changes, so a highlight on /serveriai alone would
   break the pair and make one card look like a different component on one route. */
.vnav-players:hover {
    background: linear-gradient(135deg, rgba(13, 202, 240, 0.25) 0%, rgba(13, 202, 240, 0.1) 100%);
    border-color: rgba(13, 202, 240, 0.5);
    color: #fff;
}

.vnav-discord {
    background: linear-gradient(135deg, rgba(88, 101, 242, 0.2) 0%, rgba(88, 101, 242, 0.07) 100%);
    border-color: rgba(88, 101, 242, 0.35);
    color: rgba(255, 255, 255, 0.85);
}

.vnav-discord:hover {
    background: linear-gradient(135deg, rgba(88, 101, 242, 0.3) 0%, rgba(88, 101, 242, 0.12) 100%);
    border-color: rgba(88, 101, 242, 0.6);
    color: #fff;
}

/* Two-line labels (name over count) need tighter leading than the default. */
.vnav-players .vnav-label,
.vnav-discord .vnav-label {
    line-height: 1.25;
}

/* Carries .vnav-label (to hide in the rail), whose flex-grow would stretch it across
   the row and leave the glyph sitting mid-link instead of at the end. */
.vnav-discord-ext {
    flex: 0 0 auto;
    margin-left: auto;
    opacity: 0.6;
}

.vnav-login-btn .vnav-label {
    white-space: nowrap;
}

/* --- Collapsed-mode adjustments --------------------------------------- */
.vnav-active-collapsed .vnav-label,
.vnav-active-collapsed .vnav-section-caret,
.vnav-active-collapsed .vnav-badge,
.vnav-active-collapsed .vnav-subnav,
.vnav-active-collapsed .vnav-subnav-header,
.vnav-active-collapsed .vnav-user-icons {
    display: none !important;
}

.vnav-active-collapsed .vnav-user {
    align-items: center;
    padding: 0.5rem 0.25rem;
}

.vnav-active-collapsed .vnav-user-btn,
.vnav-active-collapsed .vnav-user-actions {
    justify-content: center;
}

.vnav-active-collapsed .vnav-link,
.vnav-active-collapsed .vnav-section-toggle,
.vnav-active-collapsed .vnav-sublink,
.vnav-active-collapsed .vnav-discord,
.vnav-active-collapsed .vnav-players {
    justify-content: center;
    padding: 0.6rem 0.4rem;
}

.vnav-active-collapsed .vnav-icon {
    margin: 0;
}

.vnav-active-collapsed .vnav-footer {
    padding: 0.5rem;
}

/* --- Mobile top-bar --------------------------------------------------- */
/* The blur lives on a pseudo-element, NOT on the bar itself: `backdrop-filter`
   makes an element the containing block for its `position: fixed` descendants,
   which trapped the notifications panel's full-screen `inset: 0` modal inside
   this 64px bar. The pseudo-element has no fixed descendants, so the effect
   survives while the bell / sponsor popovers escape to the viewport. */
.vnav-mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1025;
    background: rgba(15, 22, 33, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 64px;
}

.vnav-mobile-topbar::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
}

.vnav-mobile-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.vnav-mobile-hamburger:hover,
.vnav-mobile-hamburger:focus {
    background: rgba(13, 202, 240, 0.15);
    border-color: rgba(13, 202, 240, 0.5);
    color: #fff;
    outline: none;
}

.vnav-brand-mobile img {
    max-height: 44px;
    width: auto;
}

/* --- Mobile off-canvas behavior --------------------------------------- */
@media (max-width: 767.98px) {
    .vnav-sidebar {
        width: 280px;
        transform: translateX(-100%);
    }

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

    /* Ignore desktop-collapsed state on mobile (drawer is full-width regardless) */
    .vnav-active-collapsed .vnav-sidebar {
        width: 280px;
    }

    .vnav-active-collapsed .vnav-label,
    .vnav-active-collapsed .vnav-section-caret,
    .vnav-active-collapsed .vnav-badge,
    .vnav-active-collapsed .vnav-subnav-header {
        display: initial !important;
    }

    .vnav-active-collapsed .vnav-subnav {
        display: grid !important;
    }

    .vnav-active-collapsed .vnav-user {
        align-items: stretch;
        padding: 0.75rem;
    }

    .vnav-active-collapsed .vnav-link,
    .vnav-active-collapsed .vnav-section-toggle,
    .vnav-active-collapsed .vnav-sublink,
    .vnav-active-collapsed .vnav-discord,
    .vnav-active-collapsed .vnav-players,
    .vnav-active-collapsed .vnav-user-btn,
    .vnav-active-collapsed .vnav-user-actions {
        justify-content: flex-start;
        padding: 0.55rem 0.6rem;
    }

    .vnav-active-collapsed .vnav-user-btn,
    .vnav-active-collapsed .vnav-user-actions {
        padding: 0;
    }
}

.vnav-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1029;
    animation: vnav-backdrop-fade 0.2s ease-out;
}

@keyframes vnav-backdrop-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Reposition floating panels from the sidebar user block ------------
   NotificationsBell (.notif-panel-wrap) and the sponsor progress popover
   (.sponsor-badge-popover) default to `position: absolute; right: 0;
   top: 100%` — anchored to the button and right-aligned, which fits the
   horizontal navbar but overflows the sidebar. `.vnav-sidebar` has
   `backdrop-filter`, which makes it the containing block for `position:
   fixed` descendants, so these offsets are measured from the sidebar's own
   box: push them just past its right edge instead.
   Desktop-only — on mobile both panels use their own inset:0 full-screen
   modal path, and the bell lives in the top bar rather than here.
   Both offsets derive from `--vnav-w` / `--vnav-w-collapsed`, so changing the
   sidebar width moves them automatically. */
@media (min-width: 768px) {
    .vnav-user .notif-panel-wrap,
    .vnav-user .sponsor-badge-popover {
        position: fixed;
        top: 6rem;
        right: auto;
        bottom: auto;
        left: calc(var(--vnav-w) + 0.5rem);
    }

    .vnav-active-collapsed .vnav-user .notif-panel-wrap,
    .vnav-active-collapsed .vnav-user .sponsor-badge-popover {
        left: calc(var(--vnav-w-collapsed) + 0.5rem);
    }
}
