/* --- NAVIGATION --- */
#nav-placeholder {
    position: relative;
    width: 100%;
    min-height: 74px;
    margin: 15px auto;
    margin-top: 0px;
    box-sizing: border-box;
    max-width: none;
    z-index: 10000;
}

#nav-placeholder > header {
    position: relative;
    width: 100%; 
    max-width: none;
    min-height: 72px;
    background: var(--card-bg);
    padding: 10px 20px; 
    border-radius: 50px;
    box-shadow: 0 4px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
    box-sizing: border-box;
    transition: background 0.3s ease;
    flex-shrink: 0;
    backdrop-filter: blur(16px);
    z-index: 10000;
}

@media (min-width: 1063px) {
    body > #nav-placeholder {
        width: calc(100% - 40px);
    }
}

#nav-placeholder > header nav {
    min-height: 50px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 15px;
}

.nav-left-group {
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-right-group {
    min-height: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.nav-center-links {
    display: none;
}

@media (min-width: 1063px) {
    .nav-center-links {
        display: flex;
        align-items: center;
        gap: 5px;
    }
}

.nav-shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 700;
    color: var(--nav-text-color);
    transition: all 0.2s ease;
}

.nav-shortcut:hover {
    background-color: var(--nav-hover-bg);
    color: var(--nav-hover-text);
}

.nav-shortcut .nav-icon {
    width: 20px;
    height: 20px;
    margin: 0;
}


/* --- DROPDOWNS --- */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-button {
    background: none;
    border: 2px solid var(--nav-text-color);
    color: var(--nav-text-color);
    padding: 0.5em 1.1em;
    font-size: 1em;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    transition: all 0.3s ease;
}

.dropdown-button:hover {
    background-color: var(--nav-text-color);
    color: var(--header-bg);
}

.dropdown-menu {
    display: none;
    position: fixed;
    background: var(--menu-bg, var(--card-bg));
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px var(--shadow-color);
    border: 2px solid #2b2028;
    border-radius: 15px;
    z-index: 20000;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    color: var(--nav-text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    font-weight: 700;
    transition: all 0.2s ease;
}

.dropdown-menu a:hover {
    background-color: var(--nav-hover-bg);
    color: var(--nav-hover-text);
}

.dropdown-menu a.active {
    background-color: var(--nav-hover-bg);
    color: var(--nav-hover-text);
    font-weight: bold;
}

.profile-menu-toggle {
    width: calc(100% - 16px);
    margin: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--nav-text-color);
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 0.92rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.profile-menu-toggle:hover {
    background: var(--nav-hover-bg);
    color: var(--nav-hover-text);
}

.profile-menu-switch {
    position: relative;
    flex: 0 0 auto;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: rgba(127, 127, 127, 0.38);
    box-shadow: inset 0 0 0 1px var(--border-color);
}

.profile-menu-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
    transition: transform 0.18s ease;
}

.profile-menu-toggle.is-active .profile-menu-switch {
    background: var(--accent-pink);
}

.profile-menu-toggle.is-active .profile-menu-switch::after {
    transform: translateX(16px);
}

.dropdown-menu a.admin-only {
    display: none;
}

.dropdown-menu a.admin-nav-link {
    margin: 8px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-yellow));
    color: #241423 !important;
    font-weight: 900;
    text-align: center;
}

.dropdown-menu a.admin-nav-link:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.dropdown-menu a.admin-tool-link {
    margin: 6px 8px;
    border-radius: 11px;
    border: 1px solid color-mix(in srgb, var(--accent-pink) 42%, var(--border-color));
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent-pink) 18%, transparent), color-mix(in srgb, var(--accent-yellow) 16%, transparent)),
        color-mix(in srgb, var(--card-bg) 90%, var(--accent-pink));
    color: var(--accent-pink) !important;
    font-weight: 900;
    letter-spacing: 0.02em;
}

.dropdown-menu a.admin-tool-link::before {
    content: 'ADMIN';
    margin-right: 8px;
    border-radius: 999px;
    padding: 2px 6px;
    background: color-mix(in srgb, var(--accent-yellow) 82%, #ffffff);
    color: #2a1724;
    font-size: 0.62rem;
    line-height: 1;
}

.dropdown-menu a.admin-tool-link:hover {
    border-color: var(--accent-pink);
    filter: brightness(1.04);
    transform: translateY(-1px);
}

.nav-separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 12px;
}


/* --- NAV ICONS & BUTTONS --- */
.nav-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 8px;
    margin-top: -2px;
}

.nav-cta-button {
    background-color: var(--button-bg);
    color: white !important;
    font-size: 1em;
    padding: 0.5em 1.1em;
    border-radius: 30px;
    transition: transform 0.2s ease, background-color 0.2s ease;
    border: none;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    text-decoration: none;
}

.nav-cta-button.secondary {
    background-color: var(--button-secondary-bg);
    color: var(--button-secondary-text) !important;
}

.nav-cta-button.discord-button {
    background-color: #5865f2;
}

.nav-cta-button:hover {
    background-color: var(--button-bg-hover);
    transform: scale(1.05);
}

.nav-cta-button.secondary:hover {
    background-color: var(--button-secondary-bg-hover);
}

.nav-cta-button.discord-button:hover {
    background-color: #4752c4;
}

.nav-cta-button.pink-button {
    background-color: var(--accent-pink);
}

.nav-cta-button.pink-button:hover {
    background-color: var(--button-bg-hover);
}

.nav-cta-button:disabled {
    background-color: #7f8c8d !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
    transform: none !important;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--nav-text-color);
    color: var(--nav-text-color);
    padding: 0.5em 1.1em;
    font-size: 1em;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-theme-toggle {
    display: none;
    min-height: 40px;
    padding: 6px 12px;
    font-size: 0.9rem;
    line-height: 1;
    white-space: nowrap;
}

.nav-theme-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    margin: 0;
}

@media (min-width: 1063px) {
    .nav-theme-toggle {
        display: inline-flex;
    }
}

.theme-toggle:hover {
    background-color: var(--nav-text-color);
    color: var(--header-bg);
}

.nav-right-group .twitch-button {
    background-color: #9146FF;
    color: white;
}

.nav-right-group .twitch-button:hover {
    background-color: #772ce8;
}

.nav-button-text {
    display: inline;
}

.icon-only {
    display: none;
}

.theme-toggle .icon-only img,
.twitch-button .icon-only img {
    width: 28px;
    height: 28px;
    vertical-align: middle;
    margin: -4px;
}

.light-icon { display: block; }
.dark-icon { display: none; }
html.dark-mode .light-icon { display: none; }
html.dark-mode .dark-icon { display: block; }

.login-icon {
    display: block;
}

#jbucks-display img {
    width: 18px;
    height: 18px;
}


/* --- JBUCKS DISPLAY --- */
.nav-jbucks-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(255, 215, 0, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    font-weight: 800;
    color: var(--text-color);
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

html.dark-mode .nav-jbucks-container {
    background-color: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.4);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.nav-jbucks-container:hover {
    background-color: rgba(255, 215, 0, 0.2);
    transform: translateY(-2px);
}

.nav-jbucks-icon {
    width: 20px;
    height: 20px;
}

#nav-jbucks-balance {
    font-family: 'Nunito', sans-serif;
    letter-spacing: 0.5px;
}

/* --- DISK USAGE --- */
.disk-usage-display {
    font-size: 0.8em;
    font-weight: 700;
    color: var(--nav-text-color);
    background-color: rgba(0, 0, 0, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

html.dark-mode .disk-usage-display {
    background-color: rgba(255, 255, 255, 0.1);
}

.disk-usage-percentage {
    display: inline;
}

.disk-usage-tooltip {
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8em;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.disk-usage-display:hover .disk-usage-tooltip {
    opacity: 1;
    visibility: visible;
}

/* --- PROFILE AVATAR & NOTIFICATIONS --- */
#profile-dropdown-container {
    display: none;
    position: relative;
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
}

/* 1. Logged-In Profile Menu (Standard Width) */
#profile-dropdown-menu {
    position: absolute !important;
    left: auto !important;
    right: 0 !important;
    top: 100% !important;
    margin-top: 10px;
    transform: none !important;
    min-width: 200px; /* Standard width */
    z-index: 2000;
}

/* 2. Login Menu (Wider for Google Button) */
#login-dropdown-container .dropdown-menu {
    position: absolute !important;
    left: auto !important;
    right: 0 !important;
    top: 100% !important;
    margin-top: 10px;
    transform: none !important;
    min-width: 300px; /* Wider for Google/Twitch buttons */
    z-index: 2000;
}

.nav-user-avatar-button {
    --avatar-ring-inset: 4px;
    /* Grow visually into the bar padding without changing its layout slot. */
    width: 72px;
    height: 72px;
    margin: -11px;
    box-sizing: border-box;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    padding: 4px;
    background: var(--profile-ring-color, #00BFFF);
    border: none;
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.nav-user-avatar-button.gradient-ring {
    background: linear-gradient(45deg, var(--profile-ring-color), var(--profile-ring-color2));
    background-size: 400% 400%;
    animation: gradient-animation 2s ease infinite;
}

.nav-user-avatar-button img {
    width: 100%;
    height: 100%;
    border-radius: 0;
    object-fit: cover;
    position: relative;
    z-index: 2;
    background: transparent;
    transform: scale(var(--profile-image-scale, 1));
    transform-origin: center;
    clip-path: circle(min(100%, calc(50% / var(--profile-image-scale, 1))) at center);
}

.nav-user-avatar-button::after {
    content: '';
    position: absolute;
    z-index: 1;
    inset: var(--avatar-ring-inset);
    border-radius: 50%;
    background: var(--profile-bg-color, #FFFFFF);
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.nav-user-avatar-button:has(> img.gradient-bg)::after {
    background: linear-gradient(45deg, var(--profile-bg-color), var(--profile-bg-color2));
    background-size: 400% 400%;
    animation: gradient-animation 3s ease infinite;
}

.nav-user-avatar-button img.gradient-bg {
    background: transparent;
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid var(--card-bg);
    z-index: 3;
}

.nav-user-avatar-button .notification-badge {
    top: 3px;
    right: 3px;
}

.notification-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-badge-inline {
    background-color: var(--danger-color);
    color: white;
    font-size: 0.8em;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    line-height: 1;
}


/* --- MOBILE NAV LAYOUT --- */
@media (max-width: 1062px) {
    .nav-button-text {
        display: none;
    }
    .icon-only {
        display: inline;
    }
    .dropdown-button:not(.nav-user-avatar-button), .theme-toggle, .twitch-button {
        padding: 8px 12px;
    }

    /* Force the avatar button to stay exactly as it is on desktop */
    .nav-user-avatar-button {
        padding: 4px !important;
        width: 72px !important;
        height: 72px !important;
        border: none !important;
    }
    #nav-placeholder {
        padding-left: 0;
        padding-right: 0;
    }
    #nav-placeholder > header {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Force the login button to be compact on mobile */
    #login-dropdown-container .dropdown-button {
        padding: 8px; /* Reduce padding */
        width: 40px;  /* Fixed width */
        height: 40px; /* Fixed height */
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    /* Ensure the icon fits */
    #login-dropdown-container .dropdown-button img {
        width: 24px;
        height: 24px;
        margin: 0;
    }
}

/* --- TACTILE BUTTONS --- */
.nav-shortcut, .dropdown-button, .nav-cta-button, .theme-toggle {
    transition: all 0.2s ease-out; /* Use a slightly snappier transition */
}

/* Add a "lift" effect on hover */
.nav-shortcut:hover, .dropdown-button:hover, .theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow-color);
}
.nav-cta-button:hover {
    transform: scale(1.05) translateY(-1px); /* Keep the scale effect but add a slight lift */
}

/* Add a "press down" effect when clicked */
.nav-shortcut:active, .dropdown-button:active, .theme-toggle:active, .nav-cta-button:active {
    transform: translateY(0px) scale(1);
    box-shadow: 0 2px 5px var(--shadow-color);
    transition-duration: 0.05s; /* Make the press down feel instant */
}

/* Notification Badge for WordMaxxing */
.nav-shortcut.wm-nav-link, 
.dropdown-menu a[href="/wordmaxxing.html"] {
    position: relative;
}

.nav-shortcut.wm-nav-link.has-new-game::after,
.dropdown-menu a[href="/wordmaxxing.html"].has-new-game::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 10px;
    height: 10px;
    background-color: #e74c3c; /* Red */
    border-radius: 50%;
    border: 2px solid var(--card-bg);
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.5);
    animation: pulse-badge 2s infinite;
}

/* Adjust position for the dropdown item specifically if needed */
.dropdown-menu a[href="/wordmaxxing.html"].has-new-game::after {
    top: 12px;
    right: 12px;
}

@keyframes pulse-badge {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 5px rgba(231, 76, 60, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

#twitch-login-btn:hover {
    transform: none !important;
}
/* Subscriber benefits use the workshop's lavender accent. */
#profile-dropdown-menu .sub-perks-link {
    background: #b7a2e4;
    color: #2b2028;
    border-radius: 4px;
    font-weight: 700;
}
#profile-dropdown-menu .sub-perks-link:hover {
    background: #c9b8ef;
}
