/* 顶部导航栏公共样式 */

.top-nav {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo-link {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 40px;
    width: auto;
}

.nav-title {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    padding-left: 20px;
    border-left: 2px solid #e0e0e0;
}

.nav-right nav {
    height: 100%;
}

.nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px;
    height: 100%;
    align-items: center;
}

.nav-links li {
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-links a {
    padding: 10px 20px;
    color: #666;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s;
    border-radius: 6px;
    position: relative;
    display: inline-block;
}

.nav-links a:hover {
    color: #667eea;
    background: #f5f5f5;
}

.nav-links a.active {
    color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

/* 用户菜单样式 */
.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-menu {
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f5f5f5;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
}

.user-info:hover {
    background: #e8e8e8;
}

.user-avatar {
    display: flex;
    align-items: center;
    color: #667eea;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    font-size: 10px;
    color: #999;
    transition: transform 0.3s;
}

.user-info:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 180px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1001;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-item:hover {
    background: #f5f5f5;
    color: #667eea;
}

.dropdown-item svg {
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
}

.dropdown-item.logout {
    color: #ff4d4f;
}

.dropdown-item.logout:hover {
    background: #fff1f0;
    color: #ff4d4f;
}

/* 登录/注册按钮 */
.auth-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-login, .btn-register {
    padding: 8px 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 20px;
    transition: all 0.3s;
}

.btn-login {
    color: #667eea;
    background: transparent;
    border: 1px solid #667eea;
}

.btn-login:hover {
    background: #667eea;
    color: white;
}

.btn-register {
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.btn-register:hover {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 页面标题区域 */
.page-header {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 20px 20px;
    text-align: center;
}

.page-header h1 {
    font-size: 36px;
    font-weight: 600;
    color: #333;
    margin: 0 0 15px 0;
}

.page-header p {
    font-size: 18px;
    color: #666;
    margin: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .top-nav {
        width: 100%;
        overflow-x: hidden; /* 防止导航栏造成横向滚动 */
    }
    
    .nav-container {
        height: auto;
        padding: 15px 20px;
        flex-direction: column;
        gap: 15px;
        width: 100%;
        max-width: 100vw; /* 确保不超过视口宽度 */
        box-sizing: border-box; /* 包含padding在宽度内 */
    }

    .nav-left {
        width: 100%;
        justify-content: space-between;
    }

    .nav-title {
        font-size: 18px;
        padding-left: 15px;
    }

    .nav-right {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    /* 导航菜单横向滚动 */
    .nav-right nav {
        width: 100%;
        max-width: 100%; /* 限制最大宽度 */
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }

    /* 隐藏滚动条 */
    .nav-right nav::-webkit-scrollbar {
        display: none;
    }

    .nav-links {
        justify-content: flex-start;
        width: auto;
        gap: 2px;
        flex-wrap: nowrap; /* 不换行 */
    }

    .nav-links li {
        flex-shrink: 0; /* 防止菜单项收缩 */
    }

    .nav-links a {
        padding: 8px 12px;
        font-size: 14px;
        white-space: nowrap; /* 防止文字换行 */
    }

    .user-menu {
        width: 100%;
    }

    .user-info {
        justify-content: center;
        width: 100%;
    }

    .auth-buttons {
        width: 100%;
        justify-content: center;
    }

    .user-dropdown {
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(-10px);
    }

    .user-dropdown.show {
        transform: translateX(-50%) translateY(0);
    }

    .page-header {
        padding: 30px 20px 20px;
    }

    .page-header h1 {
        font-size: 28px;
    }

    .page-header p {
        font-size: 16px;
    }

    .logo-img {
        height: 32px;
    }
}
