/* ========== GLOBAL HEADER ========== */

.global-header {
    position: sticky;
    top: 0;
    z-index: 2000;
    background: rgba(18, 18, 18, 0.92);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid rgba(138, 43, 226, 0.3);
    height: auto;
    min-height: 48px;
    display: flex;
    align-items: center;
}

.global-header .gh-inner {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.global-header .gh-logo {
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    text-decoration: none;
    letter-spacing: -0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.global-header .gh-logo:hover {
    color: #ff69b4;
}

.global-header .gh-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    flex-grow: 1;
    /* Allow nav to take available space */
}

.global-header .gh-nav::-webkit-scrollbar {
    display: none;
}

.global-header .gh-nav a {
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.global-header .gh-nav a:hover {
    color: #fff;
    background: rgba(138, 43, 226, 0.25);
}

.global-header .gh-nav a.active {
    color: #ff69b4;
    background: rgba(138, 43, 226, 0.2);
}

/* Language Selector Styles */
.global-header .gh-lang {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    /* Push to the right before auth */
    flex-shrink: 0;
}

.global-header .gh-lang .lang-btn {
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.global-header .gh-lang .lang-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.global-header .gh-lang .lang-btn.active {
    color: #ff69b4;
    border-color: rgba(255, 105, 180, 0.3);
    background: rgba(255, 105, 180, 0.1);
}

.global-header .gh-auth {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* Override auth-ui positioning so it sits inside the header */
.global-header #auth-container {
    position: static !important;
}

.global-header .auth-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.global-header .auth-icon {
    display: none;
}

.global-header .auth-controls,
.global-header .user-info {
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: row !important;
    align-items: center !important;
    min-width: unset !important;
}

.global-header .auth-controls::before,
.global-header .user-info::before {
    display: none !important;
}

.global-header .auth-button {
    padding: 4px 10px;
    font-size: 12px;
    background: rgba(138, 43, 226, 0.3);
    border: 1px solid rgba(138, 43, 226, 0.5);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
    white-space: nowrap;
    width: auto !important;
}

.global-header .auth-button:hover {
    background: rgba(138, 43, 226, 0.6);
}

.global-header .user-info {
    align-items: center;
    gap: 6px;
}

.global-header .user-info[style*="display: block"],
.global-header .user-info[style*="display:block"] {
    display: flex !important;
}

.global-header .username-display {
    color: #ff69b4;
    font-size: 12px;
    font-weight: 600;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modals stay fixed to viewport */
.global-header .auth-modals .modal {
    position: fixed;
}

/* Performance mode: body is flex column with overflow:hidden, sticky won't work */
body.performance-mode .global-header {
    position: relative;
    flex-shrink: 0;
}

/* Shader editor: header is position:fixed so it doesn't affect the flex layout */
body.shader-page .global-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    flex-shrink: 0;
}

/* View toggle in header support */
.global-header .view-toggle-fullscreen.in-header {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 10px !important;
    padding: 0 !important;
    gap: 4px !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
}

.global-header .view-toggle-fullscreen.in-header .view-btn {
    font-size: 11px !important;
    padding: 3px 10px !important;
    height: 26px !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.8) !important;
    transition: all 0.2s ease !important;
}

.global-header .view-toggle-fullscreen.in-header .view-btn:hover {
    background: rgba(138, 43, 226, 0.3) !important;
    color: #fff !important;
}

.global-header .view-toggle-fullscreen.in-header .view-btn.active {
    background: var(--primary-color, #ff69b4) !important;
    color: #fff !important;
    border-color: var(--primary-color, #ff69b4) !important;
    box-shadow: 0 0 10px rgba(255, 105, 180, 0.3) !important;
}

body.shader-page {
    padding-top: 48px !important;
}

/* Admin page: body needs to be a column so admin-container fills below header */
body:has(.admin-container) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 0 !important;
    overflow: hidden !important;
}

body:has(.admin-container) .global-header {
    flex-shrink: 0;
}

/* Admin container height fix - account for 48px header */
body:has(.admin-container) .admin-container {
    height: calc(100vh - 48px);
    max-width: 100%;
    margin: 0;
    flex: 1;
}

/* Mobile override: let admin scroll naturally */
@media (max-width: 768px) {
    body:has(.admin-container) {
        overflow: auto !important;
        display: block !important;
    }

    body:has(.admin-container) .global-header {
        position: sticky;
        top: 0;
    }

    body:has(.admin-container) .admin-container {
        height: auto !important;
        min-height: 100vh;
        overflow-y: auto;
        padding: 10px !important;
    }
}

/* User page: needs to scroll */
body:has(.user-container) {
    display: block !important;
    overflow-y: auto !important;
    padding: 0 !important;
    align-items: unset !important;
    justify-content: unset !important;
}

/* Gifs/Studio/Profile pages: body needs to scroll */
body.gifs-body,
body.studio-body {
    display: block !important;
    overflow-y: auto !important;
    padding: 0 !important;
    align-items: unset !important;
    justify-content: unset !important;
}

/* Admin badge */
.global-header .gh-nav a.gh-admin {
    color: rgba(255, 200, 50, 0.8);
}

.global-header .gh-nav a.gh-admin:hover {
    color: #ffc832;
    background: rgba(255, 200, 50, 0.1);
}

@media (max-width: 768px) {
    .global-header {
        height: auto;
        min-height: 48px;
        flex-wrap: nowrap;
        padding: 0;
    }

    .global-header .gh-inner {
        flex-wrap: wrap;
        gap: 8px;
    }

    .global-header .gh-logo {
        flex: 1;
        font-size: 14px;
    }

    .global-header .gh-lang {
        margin-left: 0;
    }

    .global-header .gh-nav {
        order: 3;
        width: 100%;
        margin-top: 5px;
        padding-bottom: 5px;
    }

    .global-header .gh-nav a {
        font-size: 12px;
        padding: 5px 8px;
    }

    .global-header .gh-lang .lang-btn {
        padding: 3px 6px;
        font-size: 10px;
    }

    .global-header .auth-button {
        font-size: 10px;
        padding: 3px 6px;
    }

    .global-header .username-display {
        max-width: 60px;
        font-size: 10px;
    }

    .global-header .gh-nav {
        gap: 2px;
    }

    .global-header .gh-nav a {
        font-size: 11px;
        padding: 4px 6px;
    }

    .global-header .gh-logo {
        font-size: 13px;
    }
}