<template>
	<view class="matchmaker-message">
		<!-- 顶部导航栏 -->
		<view class="header">
			<view class="back-btn" @click="goBack"></view>
			<text class="header-title">消息</text>
			<view class="placeholder"></view>
		</view>

		<scroll-view scroll-y class="content">
			<!-- 系统通知 -->
			<view class="message-item system-notification active">
				<text class="message-type">系统通知</text>
				<text class="message-time">刚刚</text>
				<text class="message-content">您的线索审核已通过，获得20积分奖励，当前积分可兑换【资源查看权限】x1</text>
				<text class="message-footer">完成线索采集，积分+20 (距黄金级还差72分)</text>
			</view>

			<!-- 撮合成功通知 -->
			<view class="message-item match-success">
				<view class="message-icon heart"></view>
				<view class="message-body">
					<text class="message-type">撮合成功通知</text>
					<text class="message-content">您推荐的王先生和刘女士已成功匹配，获得50积分+100元现金奖励</text>
				</view>
				<text class="message-time">10分钟前</text>
			</view>

			<!-- 今天分组 -->
			<view class="time-group">
				<text class="time-label">今天</text>
			</view>

			<!-- 魏先生消息 -->
			<view class="message-item user-message">
				<view class="message-avatar">魏</view>
				<view class="message-body">
					<text class="message-type">魏先生</text>
					<text class="message-content">您好，想了解一下李女士的详细情况，方便沟通吗？</text>
				</view>
				<text class="message-time">1小时前</text>
			</view>

			<!-- 昨日分组 -->
			<view class="time-group">
				<text class="time-label">昨日</text>
			</view>

			<!-- 张先生消息 -->
			<view class="message-item user-message">
				<view class="message-avatar">张</view>
				<view class="message-body">
					<text class="message-type">张先生</text>
					<text class="message-content">您好，想了解一下王女士的详细情况，方便沟通吗？</text>
				</view>
				<text class="message-time">1小时前</text>
			</view>

			<!-- 更早分组 -->
			<view class="time-group">
				<text class="time-label">更早</text>
			</view>

			<!-- 高先生消息 -->
			<view class="message-item user-message">
				<view class="message-avatar">高</view>
				<view class="message-body">
					<text class="message-type">高先生</text>
					<text class="message-content">您好，想了解一下陈女士的详细情况，方便沟通吗？</text>
				</view>
				<text class="message-time">1小时前</text>
			</view>
		</scroll-view>

		<!-- 底部导航 -->
		<view class="tabbar">
			<view class="tabbar-item" @click="navigateToWorkbench">
				<text class="tab-icon">🏠</text>
				<text class="tab-text">工作台</text>
			</view>
			<view class="tabbar-item" @click="navigateToMyResources">
				<text class="tab-icon">📋</text>
				<text class="tab-text">我的资源</text>
			</view>
			<view class="tabbar-item" @click="navigateToRanking">
				<text class="tab-icon">🏆</text>
				<text class="tab-text">排行榜</text>
			</view>
			<view class="tabbar-item active" @click="navigateToMessage">
				<view class="tab-icon-wrapper">
					<text class="tab-icon">💬</text>
					<view class="badge">3</view>
				</view>
				<text class="tab-text">消息</text>
			</view>
			<view class="tabbar-item" @click="navigateToMine">
				<text class="tab-icon">👤</text>
				<text class="tab-text">我的</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				messages: [
					{
						id: 1,
						type: 'system',
						title: '系统通知',
						content: '您的线索审核已通过，获得20积分奖励，当前积分可兑换【资源查看权限】x1',
						footer: '完成线索采集，积分+20 (距黄金级还差72分)',
						time: '刚刚',
						isNew: true
					},
					{
						id: 2,
						type: 'matchSuccess',
						title: '撮合成功通知',
						content: '您推荐的王先生和刘女士已成功匹配，获得50积分+100元现金奖励',
						time: '10分钟前',
						isNew: false
					},
					{
						id: 3,
						type: 'user',
						title: '魏先生',
						content: '您好，想了解一下李女士的详细情况，方便沟通吗？',
						time: '1小时前',
						isNew: false
					},
					{
						id: 4,
						type: 'user',
						title: '张先生',
						content: '您好，想了解一下王女士的详细情况，方便沟通吗？',
						time: '1小时前',
						isNew: false
					},
					{
						id: 5,
						type: 'user',
						title: '高先生',
						content: '您好，想了解一下陈女士的详细情况，方便沟通吗？',
						time: '1小时前',
						isNew: false
					}
				]
			}
		},
		methods: {
			// 返回上一页
			goBack() {
				uni.navigateBack()
			},
			// 导航到工作台
			navigateToWorkbench() {
				uni.redirectTo({
					url: '/pages/matchmaker-workbench/index'
				})
			},
			// 导航到我的资源
			navigateToMyResources() {
				uni.redirectTo({
					url: '/pages/matchmaker-workbench/my-resources'
				})
			},
			// 导航到排行榜
			navigateToRanking() {
				uni.redirectTo({
					url: '/pages/matchmaker-workbench/ranking'
				})
			},
			// 导航到消息
			navigateToMessage() {
				// 已在消息页面，无需跳转
			},
			// 导航到我的
			navigateToMine() {
				uni.redirectTo({
					url: '/pages/matchmaker-workbench/mine'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.matchmaker-message {
		min-height: 100vh;
		background: #FFF9F9;
		display: flex;
		flex-direction: column;
	}

	/* 顶部导航栏 */
	.header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 25rpx 30rpx;
		padding-top: calc(25rpx + env(safe-area-inset-top));
		background: #FFF9F9;
		border-bottom: 1rpx solid #F0F0F0;

		.back-btn {
			width: 70rpx;
			height: 70rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background: rgba(240, 240, 240, 0.5);
			border-radius: 50%;
			background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23333"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>');
			background-size: 40rpx 40rpx;
			background-repeat: no-repeat;
			background-position: center;
		}

		.header-title {
			font-size: 38rpx;
			font-weight: bold;
			color: #333;
		}

		.placeholder {
			width: 70rpx;
		}
	}

	.content {
		flex: 1;
		padding: 20rpx 20rpx 120rpx;
	}

	/* 消息项 */
	.message-item {
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 25rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
		position: relative;

		&.system-notification {
			background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
			border: 2rpx solid #F8BBD0;

			&.active {
				border-color: #E91E63;
			}

			.message-type {
				display: block;
				font-size: 32rpx;
				font-weight: bold;
				color: #333;
				margin-bottom: 15rpx;
			}

			.message-time {
				display: block;
				font-size: 24rpx;
				color: #999;
				margin-bottom: 15rpx;
				text-align: right;
			}

			.message-content {
				display: block;
				font-size: 28rpx;
				color: #333;
				line-height: 1.5;
				margin-bottom: 15rpx;
			}

			.message-footer {
				display: block;
				font-size: 24rpx;
				color: #666;
				line-height: 1.4;
			}
		}

		&.match-success {
			display: flex;
			background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 100%);
			border: 2rpx solid #D1C4E9;

			.message-icon {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				margin-right: 20rpx;
				background-size: 40rpx 40rpx;
				background-repeat: no-repeat;
				background-position: center;
			}

			.message-icon.heart {
				background-color: #F8BBD0;
				background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23E91E63"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>');
			}

			.message-body {
				flex: 1;
			}

			.message-type {
				display: block;
				font-size: 30rpx;
				font-weight: bold;
				color: #333;
				margin-bottom: 10rpx;
			}

			.message-content {
				display: block;
				font-size: 26rpx;
				color: #666;
				line-height: 1.4;
			}

			.message-time {
				font-size: 24rpx;
				color: #999;
				margin-top: auto;
			}
		}

		&.user-message {
			display: flex;
			background: #FFFFFF;
			border: 2rpx solid #E0E0E0;

			.message-avatar {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				background: linear-gradient(135deg, #9C27B0 0%, #BA68C8 100%);
				color: #FFFFFF;
				font-size: 28rpx;
				font-weight: bold;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-right: 20rpx;
			}

			.message-body {
				flex: 1;
			}

			.message-type {
				display: block;
				font-size: 30rpx;
				font-weight: bold;
				color: #333;
				margin-bottom: 10rpx;
			}

			.message-content {
				display: block;
				font-size: 26rpx;
				color: #666;
				line-height: 1.4;
			}

			.message-time {
				font-size: 24rpx;
				color: #999;
				margin-top: auto;
			}
		}
	}

	/* 时间分组 */
	.time-group {
		display: flex;
		justify-content: center;
		margin: 20rpx 0;

		.time-label {
			display: inline-block;
			background: #FFF3E0;
			color: #FF9800;
			font-size: 24rpx;
			padding: 8rpx 20rpx;
			border-radius: 20rpx;
			font-weight: bold;
		}
	}

	/* 底部导航 */
	.tabbar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 110rpx;
		background: #FFFFFF;
		border-top: 1rpx solid #F0F0F0;
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding-bottom: env(safe-area-inset-bottom);

		.tabbar-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			gap: 6rpx;
			padding: 10rpx 0;

			.tab-icon-wrapper {
				position: relative;

				.badge {
					position: absolute;
					top: -8rpx;
					right: -12rpx;
					background: #FF4444;
					color: #FFFFFF;
					font-size: 18rpx;
					font-weight: bold;
					min-width: 28rpx;
					height: 28rpx;
					padding: 0 6rpx;
					border-radius: 14rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}

			.tab-icon {
				font-size: 36rpx;
			}

			.tab-text {
				font-size: 20rpx;
				color: #999;
			}

			&.active {
				.tab-text {
					color: #9C27B0;
					font-weight: bold;
				}
			}
		}
	}
</style>