/*
 * GLOBAL TOP BAR STANDARD
 * Reuse rules:
 * - Mount with #globalTopbarMount and configure using data-topbar-* attributes.
 * - Variants: homepage | workspace | auth
 * - Auth modes: guest | auto | required
 * - Keep product links, account actions, theme toggle and mobile drawer trigger here.
 * - Page-specific content must not restyle header structure inline in HTML.
 */

:root {
    --global-topbar-height: 64px;
}

/*
 * Fixed top bar layout rule:
 * - #globalTopbarMount reserves header space in normal flow
 * - .global-topbar is the actual fixed layer pinned to viewport top
 * This keeps page content/sidebar offsets stable across pages.
 */
#globalTopbarMount {
    display: block;
    height: var(--global-topbar-height);
}

.global-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 60;
    height: var(--global-topbar-height);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid rgba(229, 231, 235, 1);
    backdrop-filter: blur(16px);
}

html.dark .global-topbar {
    background: rgba(2, 6, 23, 0.94);
    border-bottom-color: rgba(31, 41, 55, 1);
}

.global-topbar__container {
    max-width: 1440px;
    margin: 0 auto;
    height: 100%;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.global-topbar__left,
.global-topbar__right,
.global-topbar__nav {
    display: flex;
    align-items: center;
}

.global-topbar__left,
.global-topbar__right {
    gap: 12px;
}

.global-topbar__nav {
    gap: 2px;
}

.global-topbar__sidebar-btn,
.global-topbar__icon-btn {
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}

.global-topbar__icon-btn {
    display: inline-flex;
}

.global-topbar__sidebar-btn {
    display: none;
}

html.dark .global-topbar__sidebar-btn,
html.dark .global-topbar__icon-btn {
    color: rgba(229, 231, 235, 0.88);
}

.global-topbar__sidebar-btn:hover,
.global-topbar__icon-btn:hover {
    background: rgba(243, 244, 246, 0.9);
}

html.dark .global-topbar__sidebar-btn:hover,
html.dark .global-topbar__icon-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.global-topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.global-topbar__brand img {
    display: block;
    height: 44px;
    width: auto;
}

.global-topbar__brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.global-topbar__brand-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #111827;
}

.global-topbar__brand-subtitle {
    font-size: 0.76rem;
    color: #6b7280;
}

html.dark .global-topbar__brand-title {
    color: #f9fafb;
}

html.dark .global-topbar__brand-subtitle {
    color: rgba(229, 231, 235, 0.66);
}

.global-topbar__link,
.global-topbar__dropdown-toggle {
    min-height: 42px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

html.dark .global-topbar__link,
html.dark .global-topbar__dropdown-toggle {
    color: rgba(229, 231, 235, 0.76);
}

.global-topbar__link:hover,
.global-topbar__dropdown-toggle:hover,
.global-topbar__link.is-active,
.global-topbar__dropdown.is-open .global-topbar__dropdown-toggle {
    color: #7c3aed;
}

html.dark .global-topbar__link:hover,
html.dark .global-topbar__dropdown-toggle:hover,
html.dark .global-topbar__link.is-active,
html.dark .global-topbar__dropdown.is-open .global-topbar__dropdown-toggle {
    color: #c4b5fd;
}

.global-topbar__dropdown {
    position: relative;
}

.global-topbar__dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 280px;
    padding: 12px;
    border-radius: 20px;
    border: 1px solid rgba(229, 231, 235, 1);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
    display: none;
}

html.dark .global-topbar__dropdown-menu {
    background: rgba(15, 23, 42, 0.98);
    border-color: rgba(31, 41, 55, 1);
    box-shadow: none;
}

.global-topbar__dropdown.is-open .global-topbar__dropdown-menu {
    display: block;
}

.global-topbar__dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    border-radius: 14px;
    text-decoration: none;
    color: #6b7280;
}

html.dark .global-topbar__dropdown-item {
    color: rgba(229, 231, 235, 0.82);
}

.global-topbar__dropdown-item:hover,
.global-topbar__dropdown-item.is-active {
    background: rgba(243, 244, 246, 0.95);
}

html.dark .global-topbar__dropdown-item:hover,
html.dark .global-topbar__dropdown-item.is-active {
    background: rgba(255, 255, 255, 0.05);
}

.global-topbar__dropdown-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: linear-gradient(135deg, rgba(127, 104, 255, 0.16), rgba(255, 111, 88, 0.16));
}

.global-topbar__dropdown-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.global-topbar__dropdown-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #111827;
}

.global-topbar__dropdown-desc {
    font-size: 0.76rem;
    color: #6b7280;
}

html.dark .global-topbar__dropdown-title {
    color: #f9fafb;
}

html.dark .global-topbar__dropdown-desc {
    color: rgba(229, 231, 235, 0.6);
}

.global-topbar__account {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(249, 250, 251, 0.95);
    border: 1px solid rgba(229, 231, 235, 1);
}

html.dark .global-topbar__account {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(31, 41, 55, 1);
}

.global-topbar__avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #7f68ff, #ff6f58);
}

.global-topbar__account-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.1;
}

.global-topbar__account-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #111827;
}

.global-topbar__account-plan {
    font-size: 0.72rem;
    color: #6b7280;
}

html.dark .global-topbar__account-name {
    color: #f9fafb;
}

html.dark .global-topbar__account-plan {
    color: rgba(229, 231, 235, 0.62);
}

.global-topbar__cta,
.global-topbar__ghost,
.global-topbar__logout {
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid rgba(229, 231, 235, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    background: #fff;
    color: #374151;
    cursor: pointer;
}

html.dark .global-topbar__ghost,
html.dark .global-topbar__logout {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(31, 41, 55, 1);
    color: #e5e7eb;
}

.global-topbar__cta {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, #7f68ff, #ff6f58);
    box-shadow: 0 12px 30px rgba(127, 104, 255, 0.22);
}

.global-topbar__guest-actions,
.global-topbar__auth-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.global-topbar__lang {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border-radius: 999px;
    border: 1px solid rgba(229, 231, 235, 1);
    background: rgba(249, 250, 251, 0.95);
}

html.dark .global-topbar__lang {
    border-color: rgba(31, 41, 55, 1);
    background: rgba(255, 255, 255, 0.04);
}

.global-topbar__lang-btn {
    min-width: 54px;
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #6b7280;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}

html.dark .global-topbar__lang-btn {
    color: rgba(229, 231, 235, 0.76);
}

.global-topbar__lang-btn.is-active {
    color: #111827;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

html.dark .global-topbar__lang-btn.is-active {
    color: #f9fafb;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

@media (max-width: 1024px) {
    .global-topbar__sidebar-btn {
        display: inline-flex;
    }

    .global-topbar__nav,
    .global-topbar__account,
    .global-topbar__auth-actions .global-topbar__ghost,
    .global-topbar__auth-actions .global-topbar__logout,
    .global-topbar__guest-actions .global-topbar__ghost,
    .global-topbar__lang {
        display: none;
    }

    .global-topbar__brand-subtitle {
        display: none;
    }

    .global-topbar__container {
        padding: 0 12px;
    }
}
