<template>
	<view class="plan-container">
		<!-- 训练计划列表 -->
		<view class="plan-list-section">
			<view class="section-header">
				<text class="section-title">我的训练计划</text>
				<text class="plan-count">{{ trainingPlans.length }}个计划</text>
			</view>

			<!-- 计划列表 -->
			<view class="plan-list">
				<view v-for="(plan, index) in trainingPlans" :key="plan.id" class="plan-card">
					<!-- 计划信息 -->
					<view class="plan-info">
						<view class="plan-icon">
							<view class="icon-circle">
								<u-icon name="calendar" size="24" color="#fff"></u-icon>
							</view>
						</view>
						<view class="plan-detail">
							<text class="plan-name">{{ plan.name }}</text>
							<view class="plan-meta">
								<view class="meta-tag">
									<text class="tag-text">{{ plan.laps }}圈</text>
								</view>
								<view class="meta-tag">
									<text class="tag-text">混氧</text>
								</view>
							</view>
						</view>
					</view>

					<!-- 删除按钮 -->
					<view class="delete-btn">
						<u-icon name="trash" size="20" color="#ff4d4f"></u-icon>
					</view>
				</view>

				<!-- 空状态 -->
				<view v-if="trainingPlans.length === 0" class="empty-state">
					<view class="empty-icon">
						<u-icon name="calendar" size="80" color="#d9d9d9"></u-icon>
					</view>
					<text class="empty-text">暂无训练计划</text>
					<text class="empty-desc">点击下方按钮添加第一个训练计划</text>
				</view>
			</view>
		</view>

		<!-- 底部添加计划按钮 -->
		<view class="bottom-section">
			<view class="add-plan-btn" @click="Service.GoPage('/pages/userFunc/addplan')">
				<u-icon name="plus" size="24" color="#fff"></u-icon>
				<text class="add-btn-text">添加训练计划</text>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue'
	import { Service } from '@/Service/Service'

	interface TrainingPlan {
		id : string
		name : string
		laps : string
	}

	const trainingPlans = ref<TrainingPlan[]>([
		{
			id: '1',
			name: '自由泳500米基础训练',
			laps: '10'
		},
		{
			id: '2',
			name: '蛙泳200米进阶训练',
			laps: '4'
		},
		{
			id: '3',
			name: '混合泳1000米挑战',
			laps: '20'
		},
		{
			id: '4',
			name: '蝶泳400米专项训练',
			laps: '8'
		}
	])



</script>

<style lang="scss" scoped>
	page {
		background-color: #f5f5f5;
	}

	.plan-container {
		min-height: 100vh;
		background-color: #f5f5f5;
		padding-bottom: 180rpx;
	}

	/* 计划列表区域 */
	.plan-list-section {
		padding: 20rpx;
	}

	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;
		padding: 0 8rpx;
	}

	.section-title {
		font-size: 34rpx;
		font-weight: 700;
		color: #333;
		position: relative;
		padding-left: 16rpx;

		/* 标题左侧装饰条 */
		&::before {
			content: '';
			position: absolute;
			left: 0;
			top: 50%;
			transform: translateY(-50%);
			width: 6rpx;
			height: 32rpx;
			background: linear-gradient(180deg, #1890ff 0%, #096dd9 100%);
			border-radius: 3rpx;
		}
	}

	.plan-count {
		font-size: 26rpx;
		color: #1890ff;
		font-weight: 600;
		background: linear-gradient(135deg, rgba(24, 144, 255, 0.1) 0%, rgba(24, 144, 255, 0.05) 100%);
		padding: 8rpx 20rpx;
		border-radius: 20rpx;
	}

	/* 计划列表 */
	.plan-list {
		display: flex;
		flex-direction: column;
		gap: 20rpx;
	}

	/* 单个计划卡片 - 美化版 */
	.plan-card {
		background: linear-gradient(135deg, #fff 0%, #fafbfc 100%);
		border-radius: 28rpx;
		padding: 28rpx 24rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08), 0 0 0 1rpx rgba(0, 0, 0, 0.04) inset;
		transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
		position: relative;
		overflow: hidden;

		/* 卡片背景装饰 */
		&::before {
			content: '';
			position: absolute;
			top: 0;
			right: 0;
			width: 120rpx;
			height: 120rpx;
			background: radial-gradient(circle, rgba(24, 144, 255, 0.08) 0%, transparent 70%);
			pointer-events: none;
		}

		&:active {
			transform: scale(0.98) translateY(2rpx);
			box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
		}
	}

	/* 左侧序号 */
	.plan-index {
		flex-shrink: 0;
		width: 56rpx;
		height: 56rpx;
		border-radius: 50%;
		background: linear-gradient(135deg, #1890ff 0%, #40a9ff 100%);
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 20rpx;
		box-shadow: 0 4rpx 12rpx rgba(24, 144, 255, 0.3);
	}

	.index-text {
		font-size: 26rpx;
		font-weight: 700;
		color: #fff;
	}

	/* 计划信息区域 */
	.plan-info {
		display: flex;
		align-items: center;
		gap: 20rpx;
		flex: 1;
		min-width: 0;
	}

	.plan-icon {
		flex-shrink: 0;
	}

	.icon-circle {
		width: 80rpx;
		height: 80rpx;
		border-radius: 20rpx;
		background: linear-gradient(135deg, #1890ff 0%, #40a9ff 50%, #096dd9 100%);
		display: flex;
		align-items: center;
		justify-content: center;
		box-shadow: 0 8rpx 20rpx rgba(24, 144, 255, 0.25);
		transition: all 0.3s ease;
		position: relative;
		overflow: hidden;

		&::after {
			content: '';
			position: absolute;
			top: 8rpx;
			right: 8rpx;
			width: 16rpx;
			height: 16rpx;
			background: rgba(255, 255, 255, 0.3);
			border-radius: 50%;
		}
	}

	.plan-detail {
		flex: 1;
		min-width: 0;
		display: flex;
		flex-direction: column;
		gap: 12rpx;
	}

	.plan-name {
		font-size: 32rpx;
		font-weight: 700;
		color: #333;
		line-height: 1.3;
		background: linear-gradient(135deg, #333 0%, #666 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
		background-clip: text;
	}

	.plan-meta {
		display: flex;
		align-items: center;
		gap: 12rpx;
	}

	.meta-tag {
		display: flex;
		align-items: center;
		gap: 8rpx;
		padding: 8rpx 16rpx;
		background: linear-gradient(135deg, rgba(24, 144, 255, 0.1) 0%, rgba(24, 144, 255, 0.05) 100%);
		border-radius: 16rpx;
		border: 1rpx solid rgba(24, 144, 255, 0.2);
	}

	.tag-text {
		font-size: 24rpx;
		color: #1890ff;
		font-weight: 600;
	}

	/* 删除按钮 - 美化版 */
	.delete-btn {
		width: 72rpx;
		height: 72rpx;
		border-radius: 50%;
		background: linear-gradient(135deg, rgba(255, 77, 79, 0.1) 0%, rgba(255, 77, 79, 0.05) 100%);
		display: flex;
		align-items: center;
		justify-content: center;
		transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
		flex-shrink: 0;
		border: 2rpx solid rgba(255, 77, 79, 0.2);

		&:active {
			background: linear-gradient(135deg, #ff4d4f 0%, #d9363e 100%);
			transform: scale(0.9);
			box-shadow: 0 4rpx 12rpx rgba(255, 77, 79, 0.4);
			border-color: transparent;

			u-icon {
				color: #fff;
			}
		}
	}

	/* 空状态 */
	.empty-state {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 140rpx 40rpx;
		gap: 24rpx;
	}

	.empty-icon {
		margin-bottom: 20rpx;
		opacity: 0.6;
	}

	.empty-text {
		font-size: 32rpx;
		color: #8c8c8c;
		font-weight: 600;
	}

	.empty-desc {
		font-size: 26rpx;
		color: #bfbfbf;
	}

	/* 底部添加计划按钮 */
	.bottom-section {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		background: linear-gradient(180deg, transparent 0%, rgba(245, 245, 245, 0.95) 20%, #f5f5f5 100%);
		padding: 24rpx 20rpx 40rpx;
		padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
		z-index: 100;
	}

	.add-plan-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 16rpx;
		width: 100%;
		height: 100rpx;
		background: linear-gradient(135deg, #1890ff 0%, #40a9ff 50%, #36cfc9 100%);
		background-size: 200% 200%;
		border-radius: 24rpx;
		box-shadow: 0 12rpx 32rpx rgba(24, 144, 255, 0.35), 0 0 0 1rpx rgba(255, 255, 255, 0.5) inset;
		transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
		position: relative;
		overflow: hidden;

		/* 光泽效果 */
		&::before {
			content: '';
			position: absolute;
			top: 0;
			left: -100%;
			width: 100%;
			height: 100%;
			background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
			animation: shimmer 3s infinite;
		}

		&:active {
			transform: scale(0.96);
			box-shadow: 0 6rpx 20rpx rgba(24, 144, 255, 0.25);
		}
	}

	.add-btn-text {
		font-size: 34rpx;
		color: #fff;
		font-weight: 700;
		letter-spacing: 2rpx;
		position: relative;
		z-index: 1;
	}


</style>