/* ========================================
   Desktop Sidebar Navigation
   Icon-only left sidebar for ≥769px
   ======================================== */

/* Hidden by default (mobile gets bottom nav instead) */
.desktop-sidebar-nav {
    display: none;
}

/* Show on desktop/tablet (above mobile breakpoint) */
@media (min-width: 769px) {
    .desktop-sidebar-nav {
        --desktop-nav-accent-start: #ffd36e;
        --desktop-nav-accent-end: #ff8a5b;
        --desktop-nav-accent-soft: rgba(255, 173, 102, 0.18);
        --desktop-nav-glow: rgba(255, 145, 91, 0.24);
        display: flex;
        flex-direction: column;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: auto;
        bottom: 0;
        width: 72px;
        z-index: 1000;
        background: linear-gradient(180deg, rgba(10, 10, 18, 0.97) 0%, rgba(0, 0, 0, 0.99) 100%);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-right: 1px solid var(--border-color, #333);
        border-left: none;
        padding: 0;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
        overflow: visible;
    }

    /* Logo area at top of sidebar */
    .desktop-nav-profile-top {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: auto;
        padding: 12px 0 8px 0;
        gap: 4px;
        border-bottom: none;
        flex-shrink: 0;
        cursor: pointer;
        position: relative;
        text-decoration: none;
    }

    .desktop-nav-profile-top .desktop-nav-avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid rgba(255, 255, 255, 0.15);
        transition: border-color 0.2s ease, transform 0.2s ease;
    }

    .desktop-nav-profile-top:hover .desktop-nav-avatar {
        border-color: rgba(255, 255, 255, 0.4);
        transform: scale(1.05);
    }

    .desktop-nav-profile-top.active .desktop-nav-avatar {
        border-color: #00c9a7;
    }

    /* Nav items container */
    .desktop-nav-items {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 12px 0;
        flex: 1;
        width: 100%;
    }

    /* Individual nav item */
    .desktop-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 56px;
        border-radius: 0;
        text-decoration: none;
        color: var(--text-primary, #fff);
        gap: 4px;
        cursor: pointer;
        position: relative;
        transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
        border: none;
        background: transparent;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        box-shadow: none;
    }

    .desktop-nav-item:hover {
        background: transparent;
        color: var(--text-primary, #fff);
    }

    /* Active state */
    .desktop-nav-item.active {
        color: var(--text-primary, #fff);
        background: transparent;
        border-color: transparent;
        box-shadow: none;
    }

    /* Mobile-like active dot */
    .desktop-nav-item.active::after {
        content: '';
        position: absolute;
        bottom: 4px;
        left: 50%;
        transform: translateX(-50%);
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--text-primary, #fff);
        display: block !important;
    }

    /* Icon span */
    .desktop-nav-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 22px;
        line-height: 1;
    }

    .desktop-nav-icon-svg {
        width: 22px;
        height: 22px;
        overflow: visible;
    stroke: currentColor !important;
    }

    .desktop-nav-icon-orb {
        fill: var(--desktop-nav-accent-start);
        stroke: none;
        opacity: 0.95;
    }

    .desktop-nav-icon-accent {
        opacity: 0.95;
    }

    .desktop-nav-item:hover .desktop-nav-icon-orb,
    .desktop-nav-item.active .desktop-nav-icon-orb {
        filter: drop-shadow(0 0 5px var(--desktop-nav-glow));
    }

    /* Avatar image for Profile nav item */
    .desktop-nav-avatar {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid rgba(255, 255, 255, 0.15);
        transition: border-color 0.2s ease;
    }

    .desktop-nav-item:hover .desktop-nav-avatar {
        border-color: rgba(255, 255, 255, 0.4);
    }

    .desktop-nav-item.active .desktop-nav-avatar {
        border-color: #00c9a7;
    }

    /* Hide all tooltips universally */
    .desktop-nav-item::after, 
    .desktop-nav-profile-top::after,
    .desktop-nav-download::after,
    .desktop-nav-logout::after,
    .desktop-nav-recaptcha::after {
        content: none;
        display: none !important;
    }

    /* Badge on nav items (e.g., friend request count) */
    .desktop-nav-badge {
        position: absolute;
        top: 2px;
        right: 2px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 8px;
        background: #ef4444;
        color: #fff;
        font-size: 0.55rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
        pointer-events: none;
    }

    .desktop-nav-badge:empty {
        display: none;
    }

    /* Update Available button — shown when a new SW version is waiting */
    .desktop-nav-update {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        width: 100%; height: 56px; border: none; background: transparent;
        color: #00c9a7;
        cursor: pointer;
        flex-shrink: 0;
        transition: color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        gap: 4px;
    }

    .desktop-nav-update:hover {
        color: #33f0ca;
    }

    .desktop-nav-update .desktop-nav-icon-svg {
        width: 22px;
        height: 22px;
    }

    /* Download / Update button above reCAPTCHA */
    .desktop-nav-download {
        display: flex;
        flex-direction: column;
        gap: 4px;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 56px;
        border: none;
        background: transparent;
        color: var(--text-secondary, #a0a0a0);
        cursor: pointer;
        flex-shrink: 0;
        text-decoration: none;
        transition: color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .desktop-nav-download .desktop-nav-icon-svg {
        width: 22px;
        height: 22px;
    }

    .desktop-nav-download:hover {
        color: #818cf8;
    }

    /* Green glow when update is ready to install */
    .desktop-nav-download.update-ready {
        color: #00c9a7;
    }

    .desktop-nav-download.update-ready:hover {
        background:
            linear-gradient(180deg, rgba(52, 211, 153, 0.22), rgba(52, 211, 153, 0.1)),
            rgba(52, 211, 153, 0.08);
        color: #34d399;
        border-color: rgba(52, 211, 153, 0.5);
    }

    /* Subtle spin when downloading */
    .desktop-nav-download.update-downloading {
        color: #fbbf24;
    }

    /* Update badge dot */
    .desktop-nav-update-badge {
        position: absolute;
        top: 2px;
        right: 20px;
        width: 6px;
        height: 6px;
        background: #00c9a7;
        border-radius: 50%;
    }

    @keyframes update-pulse {
        0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.15); }
        50% { box-shadow: 0 0 12px 2px rgba(52, 211, 153, 0.25); }
    }

    /* reCAPTCHA disclosure icon above logout */
    .desktop-nav-recaptcha {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 46px;
        height: 34px;
        margin-bottom: 4px;
        opacity: 0.35;
        color: var(--text-secondary, #a0a0a0);
        text-decoration: none;
        border-radius: 10px;
        flex-shrink: 0;
        position: relative;
        transition: opacity 0.2s ease;
    }

    .desktop-nav-recaptcha:hover {
        opacity: 0.65;
    }

    .desktop-nav-recaptcha svg {
        width: 17px;
        height: 17px;
    }

    /* Logout button at bottom */
    .desktop-nav-logout {
        display: flex;
        flex-direction: column;
        gap: 4px;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 56px;
        border: none;
        background: transparent;
        color: var(--text-secondary, #a0a0a0);
        cursor: pointer;
        margin-bottom: 8px;
        flex-shrink: 0;
        transition: color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .desktop-nav-logout:hover {
        background:
            linear-gradient(180deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.08)),
            rgba(239, 68, 68, 0.06);
        color: #ef4444;
        border-color: rgba(239, 68, 68, 0.35);
        transform: translateY(-1px);
    }

    .desktop-nav-logout .desktop-nav-icon-svg {
        width: 22px;
        height: 22px;
    }

    /* Body padding on body.has-desktop-nav handles all in-flow content offset */
    body.has-desktop-nav {
        padding-left: 72px !important;
        padding-right: 0 !important;
    }

    body.has-desktop-nav.has-desktop-nav-pos-top {
        padding-left: 0 !important;
        padding-top: 74px !important;
    }

    body.has-desktop-nav.has-desktop-nav-pos-right {
        padding-left: 0 !important;
        padding-right: 72px !important;
    }

    body.has-desktop-nav.has-desktop-nav-pos-top-left,
    body.has-desktop-nav.has-desktop-nav-pos-top-right {
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-top: 0 !important;
    }

    body.has-desktop-nav.has-desktop-nav-pos-bottom-right {
        padding-left: 0 !important;
    }

    body.has-desktop-nav.has-desktop-nav-pos-bottom-left {
        padding-left: 0 !important;
    }

    .desktop-nav-label {
        font-size: 0.65rem;
        font-weight: 600;
        line-height: 1;
        white-space: nowrap;
        color: rgba(255, 255, 255, 0.9);
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    }

    /* Top layout variant */
    .desktop-sidebar-nav.desktop-nav-pos-top {
        flex-direction: row;
        align-items: center;
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        width: 100%;
        height: 72px;
        border-right: none;
        border-bottom: 1px solid var(--border-color, #333);
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.35);
        padding: 0 8px;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-profile-top,
    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-item,
    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-download,
    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-logout {
        width: auto;
        min-width: 58px;
        height: 64px;
        padding: 0 6px;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-profile-top {
        border-bottom: none;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-items {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 2px;
        width: auto;
        flex: 1;
        padding: 0 6px;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-recaptcha {
        margin: 0 4px 0 2px;
        width: 34px;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-logout {
        margin-bottom: 0;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top .desktop-nav-item.active::after {
        bottom: 2px;
    }

    /* Right full-height layout variant */
    .desktop-sidebar-nav.desktop-nav-pos-right {
        left: auto;
        right: 0;
        border-right: none;
        border-left: 1px solid var(--border-color, #333);
        box-shadow: -2px 0 20px rgba(0, 0, 0, 0.3);
    }

    /* Top-left / top-right floating layout variants */
    .desktop-sidebar-nav.desktop-nav-pos-top-left,
    .desktop-sidebar-nav.desktop-nav-pos-top-right {
        top: max(12px, env(safe-area-inset-top, 0px));
        bottom: auto;
        width: 76px;
        height: auto;
        max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px));
        border-left: 1px solid var(--border-color, #333);
        border-right: 1px solid var(--border-color, #333);
        border-radius: 16px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    }

    .desktop-sidebar-nav.desktop-nav-pos-top-left {
        left: max(12px, env(safe-area-inset-left, 0px));
        right: auto;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top-right {
        left: auto;
        right: max(12px, env(safe-area-inset-right, 0px));
    }

    .desktop-sidebar-nav.desktop-nav-pos-top-left .desktop-nav-items,
    .desktop-sidebar-nav.desktop-nav-pos-top-right .desktop-nav-items {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top-left .desktop-nav-recaptcha,
    .desktop-sidebar-nav.desktop-nav-pos-top-right .desktop-nav-recaptcha {
        width: 100%;
        margin: 2px 0;
    }

    .desktop-sidebar-nav.desktop-nav-pos-top-left .desktop-nav-logout,
    .desktop-sidebar-nav.desktop-nav-pos-top-right .desktop-nav-logout {
        margin-bottom: 2px;
    }

    /* Bottom-right floating layout variant */
    .desktop-sidebar-nav.desktop-nav-pos-bottom-right {
        top: auto;
        left: auto;
        right: max(12px, env(safe-area-inset-right, 0px));
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        width: 76px;
        height: auto;
        max-height: calc(100vh - 24px - env(safe-area-inset-bottom, 0px));
        border-left: 1px solid var(--border-color, #333);
        border-right: 1px solid var(--border-color, #333);
        border-radius: 16px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    }

    .desktop-sidebar-nav.desktop-nav-pos-bottom-left {
        top: auto;
        left: max(12px, env(safe-area-inset-left, 0px));
        right: auto;
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        width: 76px;
        height: auto;
        max-height: calc(100vh - 24px - env(safe-area-inset-bottom, 0px));
        border-left: 1px solid var(--border-color, #333);
        border-right: 1px solid var(--border-color, #333);
        border-radius: 16px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    }

    .desktop-sidebar-nav.desktop-nav-pos-bottom-left .desktop-nav-items {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .desktop-sidebar-nav.desktop-nav-pos-bottom-left .desktop-nav-recaptcha {
        width: 100%;
        margin: 2px 0;
    }

    .desktop-sidebar-nav.desktop-nav-pos-bottom-left .desktop-nav-logout {
        margin-bottom: 2px;
    }

    .desktop-sidebar-nav.desktop-nav-pos-bottom-right .desktop-nav-items {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .desktop-sidebar-nav.desktop-nav-pos-bottom-right .desktop-nav-recaptcha {
        width: 100%;
        margin: 2px 0;
    }

    .desktop-sidebar-nav.desktop-nav-pos-bottom-right .desktop-nav-logout {
        margin-bottom: 2px;
    }
}

/* ---- Desktop More Menu (Hamburger) ---- */
@media (min-width: 769px) {
    .desktop-nav-more-menu {
        display: none;
        position: fixed;
        left: 72px;
        background: linear-gradient(180deg, rgba(20, 20, 30, 0.98) 0%, rgba(10, 10, 18, 1) 100%);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--border-color, #333);
        border-left: none;
        border-radius: 0 16px 16px 0;
        box-shadow: 12px 0 30px rgba(0, 0, 0, 0.5);
        padding: 12px 0;
        min-width: 220px;
        max-height: calc(100vh - 24px);
        overflow-y: auto;
        z-index: 1000;
    }
    
    .desktop-nav-more-menu.show {
        display: block;
        animation: desktopMoreSlideIn 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    body.has-desktop-nav.has-desktop-nav-pos-top .desktop-nav-more-menu {
        left: auto;
        border-left: 1px solid var(--border-color, #333);
        border-radius: 14px;
        box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5);
    }

    body.has-desktop-nav.has-desktop-nav-pos-right .desktop-nav-more-menu {
        left: auto;
        right: 72px;
        border-left: 1px solid var(--border-color, #333);
        border-radius: 14px;
        box-shadow: -12px 0 30px rgba(0, 0, 0, 0.5);
    }

    body.has-desktop-nav.has-desktop-nav-pos-top-left .desktop-nav-more-menu {
        left: 88px;
        right: auto;
        border-left: 1px solid var(--border-color, #333);
        border-radius: 14px;
        box-shadow: 12px 0 30px rgba(0, 0, 0, 0.5);
    }

    body.has-desktop-nav.has-desktop-nav-pos-top-right .desktop-nav-more-menu {
        left: auto;
        right: 88px;
        border-left: 1px solid var(--border-color, #333);
        border-radius: 14px;
        box-shadow: -12px 0 30px rgba(0, 0, 0, 0.5);
    }

    body.has-desktop-nav.has-desktop-nav-pos-bottom-left .desktop-nav-more-menu {
        left: 88px;
        right: auto;
        border-left: 1px solid var(--border-color, #333);
        border-radius: 14px;
        box-shadow: 12px 0 30px rgba(0, 0, 0, 0.5);
    }

    body.has-desktop-nav.has-desktop-nav-pos-bottom-right .desktop-nav-more-menu {
        left: auto;
        right: 90px;
        border-left: 1px solid var(--border-color, #333);
        border-radius: 14px;
        box-shadow: -12px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    @keyframes desktopMoreSlideIn {
        from { opacity: 0; transform: translateX(-10px); }
        to { opacity: 1; transform: translateX(0); }
    }
    
    .desktop-nav-more-item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 12px 20px;
        color: var(--text-primary, #fff);
        text-decoration: none;
        transition: background 0.2s;
        font-size: 0.95rem;
        font-weight: 500;
    }
    
    .desktop-nav-more-item:hover {
        background: rgba(255, 255, 255, 0.08);
    }
    
    .desktop-nav-more-item.active {
        color: #00c9a7;
        background: rgba(0, 201, 167, 0.1);
        border-left: 3px solid #00c9a7;
        padding-left: 17px;
    }
    
    .desktop-nav-more-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        color: var(--text-secondary, #a0a0a0);
    }
    
    .desktop-nav-more-item.active .desktop-nav-more-icon {
        color: #00c9a7;
    }

    .desktop-nav-more-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* ---- Desktop notification dropdown (logo click opens it) ---- */
@media (min-width: 769px) {
    /* Override mobile notif dropdown for desktop use */
    .mobile-notif-dropdown.show {
        display: block !important;
        position: fixed;
        left: 80px;
        right: auto;
        top: 8px;
        width: 380px;
        max-height: 70vh;
        background: var(--secondary-bg, #1a1a1a);
        border: 1px solid var(--border-color, #333);
        border-radius: 12px;
        overflow-y: auto;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
        z-index: 10001;
    }

    .mobile-notif-backdrop.show {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 10000;
    }
}

/* Right sidebar spacing is handled via body.has-right-sidebar padding-right in style.css */

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .desktop-sidebar-nav,
    .desktop-nav-item,
    .desktop-nav-icon {
        transition: none !important;
    }

    .desktop-nav-item::after {
        transition: none !important;
    }
}

/* Hide desktop sidebar on mobile (explicit) */
@media (max-width: 768px) {
    .desktop-sidebar-nav {
        display: none !important;
    }
}
