/* ========================================
   Top Navigation Bar (Shared)
   ======================================== */
.navbar {
    display: none; /* Hidden on desktop by default */
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2600; /* Stays above the side panel */
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    height: 65px;
    transition: transform 0.3s ease-in-out;
    will-change: transform;
}

.navbar.nav-hidden {
    transform: translateY(-100%);
}

.nav-container {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    width: 100%;
    height: 100%;
}

.navbar-logo {
    font-size: 24px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; /* Correctly clips to the Tron logo icon */
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

/* Top Search Box */
.search-box form {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.search-box form:focus-within {
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.search-box input {
    border: none;
    background: transparent;
    padding: 10px 20px;
    width: 240px;
    outline: none;
    color: var(--text-color);
    font-size: 14px;
}

/* Account & Profile Items */
.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px;
    border-radius: 25px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    text-decoration: none;
}

.user-profile:hover {
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.user-profile img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-cyan);
}

.nav-icon {
    font-size: 18px;
    color: var(--text-secondary);
    transition: color 0.3s;
}

/* Global Badge Styling for Sidebar & Nav links */
.sidebar-menu .badge,
.mobile-nav-link .badge,
.navbar .badge {
    background: var(--primary-gradient);
    color: white;
    font-size: 9px;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Ensure mobile menu is hidden on desktop by default */
.mobile-menu-dropdown {
    display: none;
}

/* ========================================
   Collapsible Sidebar/Panel Groups (Shared)
   ======================================== */
.sidebar-group {
    margin-bottom: 2px;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.sidebar-group-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    user-select: none;
}

.sidebar-group-header:hover {
    background: var(--bg-hover);
}

.sidebar-group-header span {
    font-size: 13px;
    font-weight: 700;
    flex: 1;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.sidebar-group-header .arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.sidebar-group.open .arrow {
    transform: rotate(180deg);
}

.sidebar-group-content {
    display: none;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    margin: 0;
}

.sidebar-group.open .sidebar-group-content {
    display: block;
}

.sidebar-group.nested-group {
    margin: 4px 0 0 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-group.nested-group > .sidebar-group-header {
    padding: 10px 12px 10px 14px;
}

.sidebar-group.nested-group .sidebar-group-content {
    margin: 0 0 0 8px;
    background: rgba(255, 255, 255, 0.03);
}

/* ========================================
   Mobile View (Tablet & Phones)
   ======================================== */
@media (max-width: 992px) {
    .navbar {
        display: flex; /* Shown only on mobile/tablet */
    }

    /* Bottom Navigation Bar */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: 65px;
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--glass-border);
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 2000;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        transition: transform 0.3s ease-in-out;
        will-change: transform;
    }

    .mobile-bottom-nav.nav-hidden {
        transform: translateY(100%);
    }

    .mobile-nav-item {
        flex: 1; display: flex; flex-direction: column;
        align-items: center; justify-content: center;
        color: var(--text-secondary); text-decoration: none;
        font-size: 10px; font-weight: 600; gap: 4px;
        position: relative; transition: all 0.3s ease; height: 100%;
    }

    .mobile-nav-item.active { color: var(--accent-cyan); }
    .mobile-nav-item i { font-size: 20px; transition: transform 0.3s ease; }
    .mobile-nav-item.active i { transform: translateY(-2px); text-shadow: var(--glow-cyan); }

    .mobile-nav-item .badge {
        position: absolute; top: 8px; right: 50%; transform: translateX(120%);
        background: var(--primary-gradient); color: white; font-size: 10px;
        padding: 2px 6px; border-radius: 10px; min-width: 16px; text-align: center;
        border: 2px solid var(--dark-bg); font-weight: 700;
    }

    /* Top Navbar Adjustments - Fixing Button Visibility */
    .navbar .nav-center,
    .navbar .search-box,
    .navbar .nav-right:not(:has(.btn)) { 
        display: none !important; 
    }

    .navbar .mobile-menu-btn {
        display: flex !important;
        flex-direction: column;
        gap: 5px;
        cursor: pointer;
        padding: 8px;
        border: 1px solid var(--glass-border);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.05);
        width: 42px; height: 42px;
        align-items: center; justify-content: center;
        z-index: 2700; /* Stays above sliding panel */
    }

    .mobile-menu-btn span {
        display: block; width: 20px; height: 2px;
        background: var(--primary-gradient);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Hamburger Active Animation */
    .mobile-menu-btn.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .mobile-menu-btn.active span:nth-child(2) { opacity: 0; transform: translateX(-10px); }
    .mobile-menu-btn.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* Sliding Left Panel */
    .mobile-menu-dropdown {
        position: fixed;
        top: 0; left: 0;
        width: 280px; 
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        background: var(--bg-main);
        background-image: none;
        backdrop-filter: blur(30px);
        -webkit-backdrop-filter: blur(30px);
        border-right: 1px solid var(--glass-border);
        display: block !important; /* Changed to block for better scroll reliability */
        z-index: 2500;
        transform: translateX(-100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 60px rgba(0, 0, 0, 0.8);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch; /* Smooth inertia scrolling for iOS */
        visibility: hidden;
        padding: 0 0 160px 0; /* Increased padding to ensure absolute bottom links are visible on all screen heights */
    }

    .mobile-menu-dropdown.show {
        transform: translateX(0);
        visibility: visible;
    }

    /* Tighten Group Spacing for Mobile Panel */
    .mobile-menu-dropdown .sidebar-group {
        margin-bottom: 0;
    }

    .mobile-menu-dropdown .sidebar-group-header {
        padding: 10px 24px;
    }

    .mobile-menu-dropdown .sidebar-group-header span { font-size: 12px; }

    /* Custom scrollbar for the side panel so users know they can scroll */
    .mobile-menu-dropdown::-webkit-scrollbar {
        width: 5px;
    }

    .mobile-menu-dropdown::-webkit-scrollbar-thumb {
        background: var(--primary-gradient);
        border-radius: 10px;
    }

    /* Menu Header / Profile Section - Fixing "Massive Avatar" */
    .mobile-profile-item {
        padding: 80px 24px 15px; /* Room for toggle button at top */
        background: linear-gradient(to bottom, rgba(0, 212, 255, 0.1), transparent);
        border-bottom: 1px solid var(--glass-border);
        margin-bottom: 0;
        display: flex; align-items: center; gap: 15px;
    }

    .mobile-profile-item .sidebar-avatar-wrapper {
        width: 48px !important; height: 48px !important;
        min-width: 48px;
        border-radius: 50%;
        overflow: hidden;
    }

    .mobile-profile-item .avatar-img {
        width: 48px !important; height: 48px !important;
        border: 2px solid var(--accent-cyan);
        border-radius: 50% !important;
        object-fit: cover !important;
    }

    .mobile-profile-item span {
        font-size: 18px; font-weight: 700; color: var(--text-color);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }

    /* Menu Links - Fixing Layout */
    .mobile-nav-link {
        display: flex; align-items: center; gap: 15px;
        padding: 12px 24px; color: var(--text-secondary);
        font-size: 15px; font-weight: 500;
        text-decoration: none; transition: 0.2s;
        border: none !important; background: transparent !important;
    }

    .mobile-nav-link.active, .mobile-nav-link:hover {
        background: rgba(255, 255, 255, 0.05) !important;
        color: var(--accent-cyan);
    }

    .mobile-nav-link i {
        width: 24px; text-align: center; font-size: 18px;
        color: var(--accent-purple);
    }

    .mobile-nav-link .badge {
        margin-left: auto; background: var(--primary-gradient);
        font-size: 9px;
        font-weight: 800;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-menu-dropdown hr {
        margin: 5px 24px; border: none; border-top: 1px solid var(--glass-border);
        opacity: 0.3;
    }
    
    body {
        padding-bottom: 70px !important;
    }

    /* Specific styling for the profile avatar in the messenger mobile nav */
    .mobile-bottom-nav.msg-custom-nav .mobile-nav-item.profile-nav-link .nav-profile-tron .avatar-img {
        width: 20px;
        height: 20px;
        border-radius: 50%; /* Ensure it remains circular */
        object-fit: cover; /* Ensure the image covers the area without distortion */
    }
}

/* ========================================
   Desktop Navigation & Sidebars
   ======================================== */
@media (min-width: 993px) {
    /* Themed scrollbar for sidebars */
    .left-sidebar::-webkit-scrollbar,
    .right-sidebar::-webkit-scrollbar {
        width: 8px;
    }

    .left-sidebar::-webkit-scrollbar-thumb,
    .right-sidebar::-webkit-scrollbar-thumb {
        background: var(--primary-gradient);
        border-radius: 10px;
    }

    .mobile-bottom-nav {
        display: none;
    }
    /* Sidebar Logo logic for Desktop */
    .sidebar-logo-link {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        margin-bottom: 0;
    }

    .sidebar-logo-link .logo-text {
        font-size: 19px;
        font-weight: 800;
        background: var(--primary-gradient);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        line-height: 1;
    }

    /* Sidebar Menu Styling */
    .sidebar-menu {
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        border: 1px solid var(--glass-border);
        border-radius: 16px;
        padding: 12px 12px 30px 12px; /* Added bottom padding inside the card */
        box-shadow: var(--glass-shadow);
    }

    .sidebar-menu a {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 12px 16px;
        border-radius: 12px;
        color: var(--text-color);
        transition: all 0.3s ease;
        font-size: 15px;
    }

    .sidebar-menu a:hover {
        background: var(--bg-hover);
        transform: translateX(4px);
    }

    .sidebar-menu a i {
        font-size: 18px;
        background: var(--primary-gradient);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        width: 24px;
        text-align: center;
    }

    /* Sidebar Profile Tron Layout */
    .sidebar-tron-profile {
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        border-radius: 12px;
        color: var(--text-color);
        transition: all 0.3s ease;
        border: 1px solid transparent;
        margin-bottom: 5px;
    }

    .sidebar-tron-profile:hover {
        background: var(--bg-hover);
        border-color: var(--glass-border);
        transform: translateX(4px);
        box-shadow: var(--glass-shadow);
    }

    .sidebar-profile-name {
        font-size: 15px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }

    /* Enforce circular avatars in the sidebar */
    .profile-tron-rings .avatar-img {
        width: 32px !important;
        height: 32px !important;
        border-radius: 50% !important;
        object-fit: cover !important;
    }
}