<template>
	<view class="job-search-page">
		<!-- 自定义导航栏 -->
		<view class="custom-navbar">
			<view class="navbar-content">
				<view class="nav-left" @click="goBack">
					<u-icon name="arrow-leftward" color="#333" size="42"></u-icon>
				</view>
				<view class="nav-title">职位搜索</view>
				<view class="nav-right"></view>
			</view>
		</view>
		
		<!-- 主要内容 -->
		<view class="main-content">
			<!-- 搜索框区域 -->
			<view class="search-section">
				<view class="search-container">
					<view class="search-input-container">
						<u-icon name="search" color="#999" size="36" class="search-icon"></u-icon>
						<input 
							class="search-input" 
							placeholder="搜索职位或公司" 
							v-model="searchKeyword"
						/>
					</view>
					<view class="search-btn" @click="handleSearch">
						<text class="search-btn-text">搜索</text>
					</view>
				</view>
			</view>
			
			<!-- 历史搜索 -->
			<view class="history-section">
				<view class="section-header">
					<text class="section-title">历史搜索</text>
					<image src="../../static/images/shanchu22.svg" style="width: 32rpx; height: 32rpx;" mode="aspectFit" @click="clearHistory"></image>
				</view>
				<view class="history-tags">
					<view 
						class="history-tag" 
						v-for="(item, index) in historyList" 
						:key="index"
						@click="selectHistory(item)"
					>
						{{ item }}
					</view>
				</view>
			</view>
			
			<!-- 近期热招 -->
			<view class="hot-jobs-section">
				<view class="section-header">
					<text class="section-title">近期热招</text>
					<image src="../../static/images/shanchu22.svg" style="width: 32rpx; height: 32rpx;" mode="aspectFit" @click="clearHotJobs"></image>
				</view>
				<view class="hot-jobs-grid">
					<view 
						class="hot-job-item" 
						v-for="(job, index) in hotJobsList" 
						:key="index"
						@click="selectHotJob(job)"
					>
						<text class="job-name">{{ job.name }}</text>
						<view class="hot-tag" v-if="job.isHot">
							<text class="hot-tag-text">Hot</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			searchKeyword: '',
			historyList: ['四海芯舟', '汉睿国际', '璀璨城邦'],
			hotJobsList: [
				{ name: '美国亚马逊运营', isHot: false },
				{ name: '采购经理', isHot: false },
				{ name: 'Tik Tok运营助理', isHot: true },
				{ name: 'Temu运营专员', isHot: false },
				{ name: '跨境电商运营助理', isHot: false },
				{ name: '产品开发经理', isHot: false },
				{ name: '海外仓管理经理', isHot: false },
				{ name: '人事经理', isHot: false }
			]
		}
	},
	methods: {
		goBack() {
			uni.navigateBack()
		},
		
		handleSearch() {
			if (this.searchKeyword.trim()) {
				console.log('搜索关键词:', this.searchKeyword)
				// 这里可以添加搜索逻辑
				uni.showToast({
					title: '搜索功能待实现',
					icon: 'none'
				})
			}
		},
		
		selectHistory(item) {
			this.searchKeyword = item
			this.handleSearch()
		},
		
		selectHotJob(job) {
			this.searchKeyword = job.name
			this.handleSearch()
		},
		
		clearHistory() {
			this.historyList = []
			uni.showToast({
				title: '历史搜索已清空',
				icon: 'success'
			})
		},
		
		clearHotJobs() {
			this.hotJobsList = []
			uni.showToast({
				title: '热招职位已清空',
				icon: 'success'
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.job-search-page {
	min-height: 100vh;
	background-color: #ffffff;
}

.custom-navbar {
	padding-top: 80rpx;
	background-color: #ffffff;
	z-index: 9999;
	
	.navbar-content {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 100%;
		padding: 0 40rpx;
		
		.nav-left, .nav-right {
			width: 60rpx;
			height: 60rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
		
		.nav-title {
			color: rgba(51, 51, 51, 1);
			font-family: DM Sans;
			font-size: 36rpx;
			font-weight: 700;
			line-height: 26px;
			letter-spacing: 0px;
			text-align: center;
		}
	}
}

.main-content {
	padding: 40rpx 40rpx 0 40rpx;
}

.search-section {
	margin-bottom: 60rpx;
	
	.search-container {
		display: flex;
		align-items: center;
		gap: 20rpx;
		
		.search-input-container {
			flex: 1;
			height: 70rpx;
			background: #F5F5F5;
			border-radius: 40rpx;
			display: flex;
			align-items: center;
			padding: 0 30rpx;
			
			.search-icon {
				margin-right: 20rpx;
			}
			
			.search-input {
                color: rgba(153, 153, 153, 1);
                font-family: DM Sans;
                font-size: 24rpx;
                font-weight: 500;
                line-height: 48rpx;
                text-align: left;
				
				&::placeholder {
					color: #999;
				}
			}
		}
		
		.search-btn {
			display: flex;
			align-items: center;
			justify-content: center;
			
			.search-btn-text {
                color: rgba(1, 107, 246, 1);
                font-family: DM Sans;
                font-size: 26rpx;
                font-weight: 500;
                line-height: 48rpx;
                letter-spacing: undefined;
                text-align: center;
			}
		}
	}
}

.history-section, .hot-jobs-section {
	margin-bottom: 60rpx;
	
	.section-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 30rpx;
		
		.section-title {
            color: rgba(34, 37, 42, 1);
            font-family: DM Sans;
            font-size: 28rpx;
            font-weight: 400;
            line-height: 48rpx;
            letter-spacing: 0px;
            text-align: left;
		}
	}
}

.history-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8rpx;
	
	.history-tag {
		padding: 8rpx;
		border-radius: 8rpx;
		background: rgba(153, 153, 153, 0.1);
		color: rgba(102, 102, 102, 1);
		font-family: DM Sans;
		font-size: 20rpx;
		font-weight: 400;
		line-height: 20rpx;
		text-align: left;
	}
}

.hot-jobs-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 8rpx;
	
	.hot-job-item {
		width: calc(50% - 4rpx);
		padding: 8rpx;
		background: #ffffff;
		border-radius: 12rpx;
		position: relative;
		
		.job-name {
			color: rgba(102, 102, 102, 1);
			font-family: DM Sans;
			font-size: 20rpx;
			font-weight: 400;
			line-height: 44rpx;
			letter-spacing: 0px;
			text-align: left;
		}
		
		.hot-tag {
			position: absolute;
			top: 8rpx;
			right: 10rpx;
			border-radius: 12rpx;
			background: rgba(237, 66, 69, 1);
			padding: 4rpx 12rpx;
			
			.hot-tag-text {
				color: rgba(255, 255, 255, 1);
				font-family: DM Sans;
				font-size: 16rpx;
				font-weight: 400;
				line-height: 32rpx;
				letter-spacing: 0.5%;
				text-align: center;
			}
		}
	}
}
</style>
