/* 导航栏样式 */
.header {
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    min-width: 0;
    gap: 10px;
    width: 100%;
}

.logo {
    flex-shrink: 0;
    white-space: nowrap;
    order: 1;
    text-align: left;
}

.logo h1 {
    font-size: 10px;
    color: #4CAF50;
    margin: 0;
}

.logo img {
    max-height: 40px;
    vertical-align: middle;
    height: auto;
    width: auto;
}

.logo a {
    text-decoration: none;
    color: inherit;
}

.nav {
    flex: 1;
    margin: 0 10px;
    min-width: 0;
    overflow: visible;
    order: 2;
    display: flex;
    justify-content: flex-end;
}

.nav ul {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    padding: 0;
    margin: 0;
    list-style: none;
    position: relative;
    justify-content: flex-end;
    overflow: visible;
}

/* 隐藏Chrome/Safari/Opera的滚动条 */
.nav ul::-webkit-scrollbar {
    display: none;
}

.nav a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.3s ease;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

/* 导航栏分隔符样式 */
.nav-separator {
    color: #ccc;
    font-weight: normal;
    padding: 8px 5px;
    user-select: none;
    cursor: default;
    display: flex;
    align-items: center;
    font-size: 18px;
}

.nav a:hover {
    color: #4CAF50;
    background-color: rgba(76, 175, 80, 0.1);
}

/* 搜索功能样式 */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    order: 3;
    flex: 0 0 auto;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    order: 1;
    margin: 0;
}

.search-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    color: #333;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #4CAF50;
}

.search-popup {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 10px;
    z-index: 1000;
    width: 280px;
    display: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.search-popup.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.search-popup form {
    display: flex;
    gap: 5px;
    width: 100%;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.search-button {
    padding: 8px 15px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.search-button:hover {
    background-color: #45a049;
}

.search-button:active {
    background-color: #3e8e41;
    transform: translateY(1px);
}

/* 添加点击外部关闭搜索框的功能 */
.search-popup::before {
    content: '';
    position: absolute;
    top: -10px;
    right: 15px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid white;
    z-index: -1;
}

/* 导航栏分隔符样式 */
.nav-separator {
    color: #ccc;
    font-weight: normal;
    padding: 8px 0;
    user-select: none;
    cursor: default;
}

/* 响应式设计 - 搜索弹窗样式 */
@media (max-width: 768px) {
    /* 移动端搜索弹窗样式 */
    .search-popup {
        right: 0;
        transform: translateY(-10px);
        width: calc(100vw - 40px);
        max-width: 300px;
    }
    
    .search-popup.active {
        transform: translateY(0);
    }
    
    .search-popup::before {
        right: 15px;
    }
}

/* 导航样式 */
.nav ul {
    display: flex;
    list-style: none;
    gap: 5px;
    justify-content: flex-end;
    margin: 0;
    padding: 0;
}

.nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    font-size: 16px;
    transition: var(--transition);
    padding: 6px 10px;
    border-radius: var(--border-radius);
}

.nav a:hover {
    color: var(--primary-color);
    background-color: rgba(76, 175, 80, 0.1);
}

/* 移动端导航切换按钮 */
.mobile-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
    margin-left: 10px;
}

.mobile-nav-toggle .bar {
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 10px;
    transition: all 0.3s ease;
}

/* 移动端导航激活状态 */
.mobile-nav-toggle.active .bar:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-nav-toggle.active .bar:nth-child(2) {
    opacity: 0;
}

.mobile-nav-toggle.active .bar:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* 调整头部元素顺序 */
.logo {
    order: 1;
    text-align: left;
    flex: 0 0 auto;
}

.nav {
    order: 2;
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.header-actions {
    order: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.search-container {
    order: 1;
    margin-left: 10px;
    flex: 0 0 auto;
}

/* 移动端导航菜单 */
@media (max-width: 768px) {
    /* 确保容器在移动端占满宽度 */
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0 15px;
    }
    
    /* 显示汉堡菜单 */
    .mobile-nav-toggle {
        display: flex;
        order: 3;
        margin: 0;
        flex: 0 0 auto;
    }
    
    /* 不隐藏整个导航容器，只隐藏桌面导航菜单 */
    .nav {
        display: block; /* 确保导航容器可见 */
    }
    
    /* 桌面导航菜单默认隐藏 */
    .nav ul {
        display: none; /* 桌面端默认隐藏 */
    }
    
    /* 移动端导航菜单样式 - 使用固定定位，靠右显示，实现视觉分层 */
    .nav ul.active {
        position: fixed;
        top: 60px;
        right: 0; /* 从右侧滑入 */
        flex-direction: column;
        background-color: rgba(255, 255, 255, 0.95); /* 半透明白色背景，增强层次感 */
        width: 45%; /* 减小宽度，大约6个文字的宽度 */
        max-width: 200px; /* 减小最大宽度限制 */
        text-align: right; /* 文字靠右对齐 */
        transition: all 0.3s ease;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2); /* 增强左侧阴影，提升分层效果 */
        padding: 20px;
        gap: 15px;
        z-index: 100;
        margin: 0;
        display: flex; /* 激活时显示 */
        border-radius: 0 0 0 10px; /* 左下角圆角 */
        transform-origin: top right; /* 从右上角开始变换 */
    }
    
    /* 导航菜单项样式优化 */
    .nav ul.active li {
        display: block;
        width: 100%;
        text-align: right;
    }
    
    /* 导航链接样式优化 */
    .nav ul.active a {
        font-size: 16px;
        padding: 10px 15px;
        display: block;
        margin: 0;
        border-radius: 4px;
        transition: all 0.2s ease;
        text-align: right;
        color: #333;
    }
    
    /* 导航链接悬停效果优化 */
    .nav ul.active a:hover {
        background-color: rgba(76, 175, 80, 0.15);
        padding-right: 20px;
        color: #4CAF50;
    }
    
    .nav a {
        font-size: 15px;
        padding: 8px 16px;
        display: block;
        margin: 0 10px;
        border-radius: 4px;
    }
    
    /* 优化移动端导航栏布局 */
    .header-content {
        align-items: center;
        justify-content: space-between; /* 两端对齐 */
        gap: 10px;
        flex-wrap: nowrap;
        flex-direction: row;
        width: 100%;
    }
    
    /* Logo在左侧 */
    .logo {
        flex: 0 0 auto;
        text-align: left;
        order: 1;
        margin: 0;
    }
    
    .logo img {
        max-height: 40px !important;
    }
    
    /* 确保导航容器可见，但默认隐藏里面的导航菜单 */
    .nav {
        display: block; /* 确保导航容器可见，这样里面的ul.active才能显示 */
        order: 2;
        flex: 0 0 auto;
        width: auto;
        height: auto;
        overflow: visible;
    }
    
    /* 确保导航菜单默认隐藏，只有添加active类时才显示 */
    .nav ul {
        display: none !important;
    }
    
    /* 当添加active类时，显示导航菜单 */
    .nav ul.active {
        display: flex !important;
    }
    
    /* 右侧操作区 - 包含搜索按钮和汉堡菜单，确保始终显示 */
    .header-actions {
        order: 3;
        display: flex !important;
        align-items: center;
        gap: 10px;
        flex: 0 0 auto;
        margin-left: auto; /* 关键：将操作区推到最右边 */
        z-index: 101;
    }
    
    /* 搜索按钮样式 - 确保始终显示 */
    .search-container {
        margin: 0;
        flex: 0 0 auto;
        display: flex;
    }
    
    /* 汉堡菜单按钮 - 确保始终显示 */
    .mobile-nav-toggle {
        display: flex !important;
        order: 3;
        margin: 0;
        flex: 0 0 auto;
    }
}