/* 统一导航栏样式 */
:root {
    /* 导航栏专用变量 */
    --navbar-height: 60px;
    --navbar-padding-desktop: 15px 30px;
    --navbar-padding-mobile: 10px 20px;
    --navbar-gap-desktop: 30px;
    --navbar-gap-mobile: 15px;
    --navbar-brand-gap: 10px;
    --navbar-brand-margin-desktop: 50px;
    --navbar-brand-margin-mobile: 20px;
    
    /* 间距系统 */
    --spacing-xs: 5px;
    --spacing-sm: 8px;
    --spacing-md: 10px;
    --spacing-lg: 15px;
    --spacing-xl: 20px;
    --spacing-2xl: 25px;
    --spacing-3xl: 30px;
}

/* 浅色主题（默认） */
:root,
:root.theme-light {
    /* 导航栏颜色变量 */
    --navbar-bg: #ffffff;
    --navbar-border: #e9ecef;
    --navbar-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --navbar-text: #6c757d;
    --navbar-text-hover: #4285f4;
    --navbar-text-active: #4285f4;
    --navbar-active-bg: #e3f2fd;
    --navbar-hover-bg: #f8f9fa;
}

/* 导航栏主容器 */
.unified-navbar {
    background: var(--navbar-bg);
    padding: var(--navbar-padding-desktop);
    border-bottom: 1px solid var(--navbar-border);
    box-shadow: var(--navbar-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

/* 非常驻导航栏（子页面使用） */
.unified-navbar.navbar-not-sticky {
    position: relative;
    top: auto;
}

/* 导航栏内容容器 */
.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    gap: var(--spacing-lg);
}

/* 品牌区域 */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--navbar-brand-gap);
    margin-right: var(--navbar-brand-margin-desktop);
    text-decoration: none;
    color: #333;
    font-size: 1.2em;
    font-weight: 600;
    transition: opacity 0.3s ease;
    flex-shrink: 0;
}

.navbar-brand:hover {
    opacity: 0.8;
    text-decoration: none;
    color: #333;
}

.navbar-brand-icon {
    font-size: 1.4em;
    line-height: 1;
}

.navbar-brand-text {
    white-space: nowrap;
}

/* 导航链接容器 */
.navbar-nav {
    display: flex;
    align-items: center;
    gap: var(--navbar-gap-desktop);
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* 导航链接 */
.nav-link {
    color: var(--navbar-text);
    text-decoration: none;
    font-weight: 500;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--spacing-sm);
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
    display: block;
}

.nav-link:hover {
    color: var(--navbar-text-hover);
    background: var(--navbar-hover-bg);
    text-decoration: none;
}

.nav-link.active {
    color: var(--navbar-text-active);
    background: var(--navbar-active-bg);
    font-weight: 600;
}

.nav-link.active:hover {
    background: var(--navbar-active-bg);
    color: var(--navbar-text-active);
}

.nav-link.disabled {
    color: #adb5bd;
    cursor: not-allowed;
    opacity: 0.6;
}

.nav-link.disabled:hover {
    background: transparent;
    color: #adb5bd;
}

/* 徽章样式 */
.nav-badge {
    background: #28a745;
    color: #ffffff;
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: var(--spacing-xs);
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 右侧导航链接 */
.navbar-right-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-right: var(--spacing-lg);
}

.nav-link-right {
    color: var(--navbar-text);
    text-decoration: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.nav-link-right:hover {
    color: var(--navbar-text-hover);
    background: var(--navbar-hover-bg);
    text-decoration: none;
}

.nav-link-right.active {
    color: var(--navbar-text-active);
    background: var(--navbar-active-bg);
    font-weight: 600;
}

.nav-link-right.active:hover {
    background: var(--navbar-active-bg);
    color: var(--navbar-text-active);
}

.nav-link-right.disabled {
    color: #adb5bd;
    cursor: not-allowed;
    opacity: 0.6;
}

.nav-link-right.disabled:hover {
    background: transparent;
    color: #adb5bd;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .unified-navbar {
        padding: var(--navbar-padding-mobile);
    }

    .navbar-container {
        flex-wrap: nowrap;
        gap: var(--spacing-sm);
        justify-content: flex-start;
        align-items: center;
    }

    .navbar-brand {
        display: none; /* 在移动端完全隐藏品牌区域 */
    }

    .navbar-brand-text {
        display: none; /* 在小屏幕上隐藏文字，只显示图标 */
    }

    .navbar-nav {
        gap: var(--navbar-gap-mobile);
        flex: 1;
        justify-content: flex-start;
    }

    .nav-link {
        padding: var(--spacing-xs) var(--spacing-md);
        font-size: 0.9em;
    }

    .navbar-right-links {
        gap: var(--spacing-sm);
        margin-right: var(--spacing-sm);
    }

    .nav-link-right {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.85em;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .unified-navbar {
        padding: 8px 15px;
    }
    
    .navbar-brand {
        margin-right: 15px;
    }
    
    .navbar-nav {
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .nav-link {
        padding: 6px 10px;
        font-size: 0.85em;
    }
    
    /* 在超小屏幕上，导航可能需要换行 */
    .navbar-container {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: var(--spacing-sm);
    }
    
    .navbar-nav {
        width: 100%;
        justify-content: space-around;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .nav-link {
        border: 1px solid transparent;
    }
    
    .nav-link:hover {
        border-color: var(--navbar-text-hover);
    }
    
    .nav-link.active {
        border-color: var(--navbar-text-active);
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .nav-link,
    .navbar-brand {
        transition: none;
    }
}

/* 暗色主题支持 - 通过主题切换器控制 */
:root.theme-dark {
    --navbar-bg: #1a1a1a;
    --navbar-border: #333;
    --navbar-shadow: 0 2px 4px rgba(0,0,0,0.3);
    --navbar-text: #ccc;
    --navbar-text-hover: #5a9fd4;
    --navbar-text-active: #5a9fd4;
    --navbar-active-bg: #2d3748;
    --navbar-hover-bg: #2d3748;
}

.theme-dark .navbar-brand {
    color: #fff;
}

.theme-dark .navbar-brand:hover {
    color: #fff;
}

/* 导航栏操作区域 */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

/* 主题切换按钮 */
.theme-toggle-btn {
    background: transparent;
    border: none;
    padding: var(--spacing-sm);
    border-radius: var(--spacing-sm);
    cursor: pointer;
    color: var(--navbar-text);
    transition: all 0.3s ease;
    font-size: 1.2em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
}

.theme-toggle-btn:hover {
    background: var(--navbar-hover-bg);
    color: var(--navbar-text-hover);
    transform: scale(1.1);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-icon {
    display: block;
    transition: transform 0.3s ease;
}

/* 焦点可见性 */
.nav-link:focus-visible {
    outline: 2px solid var(--navbar-text-active);
    outline-offset: 2px;
}

.navbar-brand:focus-visible {
    outline: 2px solid var(--navbar-text-active);
    outline-offset: 2px;
}

.theme-toggle-btn:focus-visible {
    outline: 2px solid var(--navbar-text-active);
    outline-offset: 2px;
}

/* ========================================
   汉堡菜单样式
   ======================================== */

/* 汉堡按钮 - 默认隐藏 */
.hamburger-btn {
    display: none;
    background: transparent;
    border: none;
    padding: var(--spacing-sm);
    cursor: pointer;
    z-index: 102;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.hamburger-icon {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--navbar-text);
    position: relative;
    transition: background 0.3s ease;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 24px;
    height: 2px;
    background: var(--navbar-text);
    transition: all 0.3s ease;
}

.hamburger-icon::before {
    top: -8px;
}

.hamburger-icon::after {
    top: 8px;
}

/* 汉堡按钮打开状态 - X 图标 */
.hamburger-btn.open .hamburger-icon {
    background: transparent;
}

.hamburger-btn.open .hamburger-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.hamburger-btn.open .hamburger-icon::after {
    top: 0;
    transform: rotate(-45deg);
}

/* 移动端菜单遮罩层 */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.open {
    display: block;
    opacity: 1;
}

/* 移动端菜单 */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background: var(--navbar-bg);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
    overflow-y: auto;
    padding: 80px 20px 20px;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.mobile-menu.open {
    right: 0;
}

/* 移动端菜单链接 */
.mobile-menu-link {
    display: block;
    padding: var(--spacing-lg) var(--spacing-xl);
    color: var(--navbar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 1em;
    border-radius: var(--spacing-sm);
    transition: all 0.3s ease;
}

.mobile-menu-link:hover {
    background: var(--navbar-hover-bg);
    color: var(--navbar-text-hover);
}

.mobile-menu-link.active {
    background: var(--navbar-active-bg);
    color: var(--navbar-text-active);
    font-weight: 600;
}

/* 始终可见的链接（功能建议） - 默认在桌面端隐藏 */
.nav-link-always-visible {
    color: var(--navbar-text);
    text-decoration: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: none;
    align-items: center;
    gap: var(--spacing-xs);
}

.nav-link-always-visible:hover {
    color: var(--navbar-text-hover);
    background: var(--navbar-hover-bg);
    text-decoration: none;
}

/* 桌面端显示类 */
.desktop-only {
    display: flex;
}

/* 移动端汉堡菜单 - 显示汉堡菜单，隐藏桌面导航 */
@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
    }

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

    .navbar-brand {
        display: none;
    }

    .navbar-container {
        flex-wrap: nowrap;
        gap: var(--spacing-sm);
        justify-content: flex-start;
        align-items: center;
    }

    .navbar-actions {
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
        margin-left: auto;
        justify-content: flex-end;
        width: auto;
        flex-shrink: 0;
    }

    .hamburger-btn {
        margin-right: var(--spacing-sm);
    }

    .nav-link-always-visible {
        display: flex;
        font-size: 0.85em;
        padding: var(--spacing-xs) var(--spacing-sm);
        white-space: nowrap;
        flex-shrink: 0;
    }

    .theme-toggle-btn {
        font-size: 1.1em;
        min-width: 36px;
        min-height: 36px;
        padding: var(--spacing-xs);
        flex-shrink: 0;
    }
}
