/* Header / Navbar Styles */

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px clamp(16px, 4vw, 60px);
    position: relative;
    z-index: 50;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 50px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: clamp(10px, 3vw, 50px);
    align-items: center;
}

/* Language Selector */
.language-selector {
    position: relative;
    z-index: 60;
    min-width: 140px;
}

.language-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 181, 51, 0.15);
    border: 1px solid rgba(255, 181, 51, 0.4);
    color: #fff;
    padding: 10px 12px;
    min-height: 44px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
}

.language-selected:hover {
    background: rgba(255, 181, 51, 0.25);
    border-color: rgba(255, 181, 51, 0.6);
}

.language-selector.open .language-selected {
    background: rgba(255, 181, 51, 0.3);
    border-color: #ffb533;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.language-selected .flag {
    width: 24px;
    height: 18px;
    border-radius: 3px;
    flex-shrink: 0;
}

.language-selected .lang-text {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.language-selected .dropdown-arrow {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
    opacity: 0.7;
}

.language-selector.open .dropdown-arrow {
    transform: rotate(180deg);
}

.language-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border: 1px solid #ffb533;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.language-selector.open .language-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #fff;
}

.language-option:hover {
    background: rgba(255, 181, 51, 0.2);
}

.language-option.active {
    background: rgba(255, 181, 51, 0.3);
    color: #ffb533;
}

.language-option .flag {
    width: 24px;
    height: 18px;
    border-radius: 3px;
    flex-shrink: 0;
}

.nav-links a {
    text-decoration: none;
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    font-style: italic;
    text-transform: uppercase;
    transition: color 0.3s ease;
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
}

.nav-links a:not(.discord-login-btn):hover::after,
.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 100%;
    height: 2px;
    background: #ffb533;
}

/* Login Button */
.discord-login-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffb533;
    color: #1a1a1a !important;
    padding: 12px 20px;
    min-height: 44px;
    border-radius: 8px;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background 0.3s ease, transform 0.2s ease;
    overflow: visible;
}

.discord-login-btn:hover {
    background: #e6a02e;
    transform: translateY(-2px);
}

.discord-login-btn img {
    height: 20px;
    width: auto;
}

/* Logout Button */
.logout-btn {
    background: rgba(255, 0, 0, 0.25);
    border: 1px solid rgba(255, 0, 0, 0.6);
    padding: 12px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.logout-btn:hover {
    background: rgba(255, 0, 0, 0.45);
    border-color: rgba(255, 0, 0, 0.9);
}

.logout-btn:hover::after {
    display: none !important;
}

.logout-btn img {
    height: 14px;
    width: auto;
    filter: brightness(0) invert(1);
}

/* Sub Menu Toggle & Current Page - hidden on desktop */
.sub-menu-toggle,
.sub-menu-current-page {
    display: none;
}

/* Nav Server Icon - hidden on desktop */
.nav-server-icon {
    display: none !important;
}

/* Responsive Header */
@media (max-width: 1024px) {
    .nav-links a {
        font-size: 14px;
    }

    .language-selector {
        min-width: 110px;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0;
        flex-direction: column;
        gap: 0;
    }

    .logo {
        width: 100%;
    }

    .logo img {
        content: url('/assets/thegrid-test-3x.svg');
        height: auto;
        width: 100%;
        display: block;
    }
    
    .nav-links {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        width: 100%;
        padding: 8px 10px 10px;
        row-gap: 8px;
        column-gap: 14px;
        gap: 8px 14px;
    }

    /* Force a line break: pseudo element with flex-basis 100% sits between
       the menu links (order 1) and the language/login row (order 3+). */
    .nav-links::before {
        content: "";
        order: 2;
        flex-basis: 100%;
        height: 0;
        margin: 0;
    }

    .nav-links > a:not(.discord-login-btn) {
        order: 1;
        font-size: 12px;
    }

    .nav-links .language-selector {
        order: 3;
        min-width: 0;
    }

    .nav-links .discord-login-btn {
        order: 4;
    }

    /* Smaller language selector on mobile */
    .language-selected {
        padding: 6px 10px;
        min-height: 32px;
        font-size: 12px;
        gap: 6px;
    }

    .language-selected .flag {
        width: 18px;
        height: 13px;
    }

    .language-selected .lang-text {
        font-size: 12px;
    }

    .language-selected .dropdown-arrow {
        width: 12px;
        height: 12px;
    }

    .language-option {
        padding: 8px 10px;
        font-size: 12px;
        gap: 8px;
    }

    .language-option .flag {
        width: 18px;
        height: 13px;
    }

    /* Smaller login button on mobile */
    .discord-login-btn {
        padding: 6px 12px;
        min-height: 32px;
        gap: 6px;
        letter-spacing: 0.5px;
        font-size: 12px;
    }

    .discord-login-btn img {
        height: 14px;
    }

    /* Hide server name, show server icon */
    #server-nav-name {
        display: none !important;
    }

    .nav-server-icon {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        border-radius: 6px;
        overflow: hidden;
        padding: 0;
        background: rgba(255, 255, 255, 0.15);
    }

    .nav-server-icon::after {
        display: none !important;
    }

    .nav-server-icon img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .nav-server-icon span {
        font-size: 12px;
        font-weight: 700;
        font-style: normal;
    }
    
    .logout-btn {
        padding: 4px 8px;
    }
    
    .logout-btn img {
        height: 10px;
    }

    /* Sub Menu Hamburger */
    .sub-menu {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 12px 15px;
        position: relative;
    }

    .sub-menu-current-page {
        display: block;
        color: #000;
        font-size: 14px;
        font-weight: 700;
        font-style: italic;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .sub-menu-toggle {
        position: absolute;
        right: 15px;
    }

    .sub-menu-container {
        display: none !important;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #ffb533;
        padding: 8px 0;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
        z-index: 100;
    }

    .sub-menu.open .sub-menu-container {
        display: flex !important;
    }

    .sub-menu-item {
        padding: 12px 24px;
        font-size: 14px;
        white-space: nowrap;
        text-align: left;
    }

    .sub-menu-item.active::after {
        bottom: 4px;
        width: 30px;
    }

    .sub-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 10px 4px;
    }

    .hamburger-line {
        display: block;
        width: 24px;
        height: 2px;
        background: #000;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    .sub-menu.open .hamburger-line:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .sub-menu.open .hamburger-line:nth-child(2) {
        opacity: 0;
    }

    .sub-menu.open .hamburger-line:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
}
