<template>
	<view class="home">
		<!-- 顶部统计卡片 -->
		<view class="hero">
			<view class="hero-top">
				<text class="brand">五金配件管家</text>
				<view class="cta">
					<text class="cta-text">咨询</text>
				</view>
			</view>
			<view class="kpi">
				<view class="kpi-item">
					<text class="kpi-label">今日销售额</text>
					<text class="kpi-value">{{ todayAmount }}</text>
				</view>
				<view class="kpi-item">
					<text class="kpi-label">本月利润</text>
					<text class="kpi-value">{{ monthProfit }}</text>
				</view>
				<view class="kpi-item">
					<text class="kpi-label">库存数量</text>
					<text class="kpi-value">{{ stockQty }}</text>
				</view>
			</view>
		</view>

		<!-- 功能九宫格 -->
		<view class="grid">
			<view class="grid-item" v-for="item in features" :key="item.key" @click="onFeatureTap(item)">
				<view class="icon" :style="{ backgroundColor: item.color }">
					<text class="icon-text">{{ item.icon }}</text>
				</view>
				<text class="grid-title">{{ item.title }}</text>
			</view>
		</view>

		<!-- 底部操作条 -->
		<view class="bottom-bar">
			<view class="tab" :class="{ active: activeTab==='home' }" @click="activeTab='home'">
				<text>首页</text>
			</view>
			<view class="tab primary" @click="onCreateOrder">
				<text>开单</text>
			</view>
			<view class="tab" :class="{ active: activeTab==='detail' }" @click="activeTab='detail'">
				<text>明细</text>
			</view>
			<view class="tab" :class="{ active: activeTab==='me' }" @click="activeTab='me'">
				<text>我的</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				todayAmount: '0.00',
				monthProfit: '0.00',
				stockQty: '0.00',
				activeTab: 'home',
				features: [
					{ key: 'customer', title: '客户', icon: '👥', color: '#3EC1D3' },
					{ key: 'sale', title: '销售', icon: '💰', color: '#00C2A8' },
					{ key: 'account', title: '账户', icon: '💳', color: '#21BA45' },
					{ key: 'supplier', title: '供应商', icon: '🚚', color: '#FF8C66' },
					{ key: 'purchase', title: '进货', icon: '🛒', color: '#F5A623' },
					{ key: 'otherPay', title: '其他支出', icon: '💸', color: '#F5C451' },
					{ key: 'vip', title: 'VIP会员', icon: '👑', color: '#FF9F43' },
					{ key: 'report', title: '报表', icon: '📊', color: '#6C7BFF' },
					{ key: 'more', title: '更多', icon: '⋯', color: '#BCAAA4' }
				]
			}
		},
		methods: {
			onFeatureTap(item) {
				uni.showToast({ title: item.title + '（开发中）', icon: 'none' })
			},
			onCreateOrder() {
				uni.showToast({ title: '开单（开发中）', icon: 'none' })
			}
		}
	}
</script>

<style>
	.home {
		padding-bottom: 140rpx;
		/* 深色奢华背景：暗金晕光 + 碳素黑 */
		background: radial-gradient(120% 80% at 100% 0, rgba(214,175,85,0.10) 0, rgba(214,175,85,0.00) 40%), linear-gradient(180deg, #0b0c10 0%, #090b11 100%);
		min-height: 100vh;
	}

	/* 顶部渐变英雄区：深色石墨 + 金色高光，并叠加金属拉丝纹理 */
	.hero {
		margin: 24rpx;
		padding: 32rpx;
		border-radius: 24rpx;
		background: repeating-linear-gradient(135deg, rgba(255,255,255,0.04) 0rpx, rgba(255,255,255,0.04) 2rpx, rgba(0,0,0,0.0) 2rpx, rgba(0,0,0,0.0) 16rpx), linear-gradient(145deg, #16181e 0%, #0e1016 100%);
		color: #ffffff;
		border: 2rpx solid rgba(236, 203, 116, 0.6);
		box-shadow: 0 18rpx 36rpx rgba(0, 0, 0, 0.35), 0 0 0 2rpx rgba(236,203,116,0.25) inset;
	}

	.hero-top {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;
	}

	.brand {
		font-size: 40rpx;
		font-weight: 600;
		letter-spacing: 2rpx;
		color: #f2d58a;
	}

	.cta {
		padding: 8rpx 20rpx;
		border-radius: 999rpx;
		background: linear-gradient(135deg, rgba(0, 212, 255, 0.35), rgba(0, 153, 255, 0.25));
		border: 2rpx solid rgba(0, 187, 255, 0.4);
	}

	.cta-text { color: #ffffff; font-size: 26rpx; }

	.kpi { display: flex; }
	.kpi-item { flex: 1; }
	.kpi-label { opacity: 0.9; font-size: 24rpx; }
	.kpi-value { display: block; margin-top: 12rpx; font-size: 46rpx; font-weight: 700; color: #f2d58a; }

	/* 功能九宫格 */
	.grid {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		grid-row-gap: 48rpx;
		grid-column-gap: 28rpx;
		padding: 40rpx 28rpx 20rpx;
	}

	.grid-item { display: flex; flex-direction: column; align-items: center; }
	.icon {
		width: 120rpx;
		height: 120rpx;
		border-radius: 28rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		background: linear-gradient(145deg, #1a1d24 0%, #0f1218 100%);
		border: 2rpx solid rgba(236,203,116,0.55);
		box-shadow: 0 10rpx 22rpx rgba(0,0,0,0.26), 0 0 0 2rpx rgba(236,203,116,0.18) inset;
	}
	.icon-text { font-size: 46rpx; font-weight: 600; }
	.grid-title { margin-top: 18rpx; color: #e6e6e6; font-size: 28rpx; }

	/* 底部操作条 */
	.bottom-bar {
		position: fixed;
		left: 0; right: 0; bottom: 0;
		display: flex;
		align-items: center;
		justify-content: space-around;
		padding: 14rpx 18rpx calc(env(safe-area-inset-bottom) + 14rpx);
		background: rgba(12,14,20,0.92);
		box-shadow: 0 -6rpx 18rpx rgba(0,0,0,0.35);
		backdrop-filter: blur(8rpx);
	}

	.tab { flex: 1; text-align: center; color: #aaa; font-size: 26rpx; }
	.tab.active { color: #f2d58a; }
	.tab.primary {
		flex: 0 0 auto;
		min-width: 180rpx;
		margin: 0 18rpx;
		padding: 18rpx 32rpx;
		background: linear-gradient(135deg, #F6E27A 0%, #E6C65B 40%, #CBA63D 100%);
		color: #212121;
		border-radius: 999rpx;
		font-size: 30rpx;
		font-weight: 700;
		box-shadow: 0 10rpx 22rpx rgba(203,166,61,0.35), 0 0 0 2rpx rgba(255,255,255,0.45) inset;
	}
</style>
