html {
    overflow-x: clip; /* Modern way to prevent horizontal scroll without breaking sticky */
}

body {
    overflow-x: clip;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    min-height: 100vh;
}

* {
    box-sizing: inherit;
}

.mobile-only, .mobile-nav-drawer, .drawer-overlay { display: none !important; }
.desktop-only { } /* Don't specify display here, let it be flex/block naturally */

@media (max-width: 768px) {
    .mobile-only { display: block !important; }
    .desktop-only { display: none !important; }
}

.nav-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.75rem;
    border: 1px solid rgba(0,0,0,0.1);
}

.nav-avatar-text {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    margin-right: 0.75rem;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.logo-icon-img {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: contain;
    flex-shrink: 0;
}

.logo-text-bold {
    font-weight: bold;
}

.chevron-small {
    font-size: 0.7rem;
}

.main-footer {
    padding: 2rem 0;
    margin-top: auto;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .main-footer {
        display: none !important;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-nav-toggle {
        display: block;
        background: transparent;
        border: none;
        font-size: 1.5rem;
        color: var(--text-main);
        cursor: pointer;
        padding: 0.5rem;
        position: relative;
        z-index: 10200 !important; /* Above everything */
    }

    /* Mobile Drawer */
    .mobile-nav-drawer {
        position: fixed;
        top: 0;
        right: -300px;
        width: 300px;
        height: 100%;
        background: var(--bg-card);
        backdrop-filter: blur(15px);
        box-shadow: -5px 0 15px rgba(0,0,0,0.1);
        z-index: 10500 !important; /* Drawer above both navbar and toggle */
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important;
        flex-direction: column;
    }

    .mobile-nav-drawer.active {
        right: 0;
    }

    .drawer-header {
        padding: 1.5rem;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .drawer-close {
        background: transparent;
        border: none;
        font-size: 2rem;
        color: var(--text-muted);
        cursor: pointer;
    }

    .drawer-content {
        flex: 1;
        overflow-y: auto;
        padding: 1.5rem;
    }

    .drawer-links {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .drawer-links a {
        padding: 0.75rem 1rem;
        text-decoration: none;
        color: var(--text-main);
        font-weight: 500;
        border-radius: 8px;
        display: flex;
        align-items: center;
        gap: 1rem;
        transition: background 0.2s;
    }

    .drawer-links a:hover {
        background: var(--primary-alpha-15);
        color: var(--primary-color);
    }

    .drawer-group {
        margin-top: 1rem;
        border-top: 1px solid var(--border-color);
        padding-top: 1rem;
    }

    .group-label {
        padding: 0 1rem 0.5rem;
        font-size: 0.75rem;
        text-transform: uppercase;
        color: var(--text-muted);
        font-weight: 700;
        letter-spacing: 0.05em;
    }

    .drawer-profile {
        margin-top: 2rem;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border-color);
    }

    .profile-info {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .logout-link {
        font-size: 0.875rem;
        color: var(--danger) !important;
    }

    .btn-drawer-login {
        margin-top: 1rem;
        background: var(--primary);
        color: white !important;
        text-align: center;
        justify-content: center;
    }

    .drawer-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        backdrop-filter: blur(4px);
        z-index: 10450 !important; /* Just below drawer */
        display: none;
        opacity: 0;
        transition: opacity 0.3s;
    }

    .drawer-overlay.active {
        display: block !important;
        opacity: 1;
    }
}
