<template>
	<div class="info-card">
		<div class="color-bar" :style="{ backgroundColor: color }"></div>
		<div class="card-content">
			<div class="title-section">
				<div class="main-title">{{ title }}</div>
				<div class="sub-title">{{ subtitle }}</div>
			</div>
			<div class="description">{{ description }}</div>
			<div v-if="quantity > 0" class="quantity" :style="{ color: color }" @click.stop="handleClickNum(title)">
				{{ quantity }}{{ unit || "个" }}
				<div class="quantity-title-des" v-if="desMap[title]">
					<img class="info-icon" :src="infoIcon" alt="" />
					{{ desMap[title] }}
				</div>
			</div>
		</div>
	</div>
</template>

<script setup>
import infoIcon from "../assets/icons/info-icon.png";
import { useRouter } from "vue-router";
const router = useRouter()
const emits = defineEmits(['num-click'])

const handleClickNum = (item) => {
	if (item === '实体清单') {
		const route = router.resolve({
			path: "/dataLibrary/dataEntityList",
			query: {
				isCnEntityOnly: true
			}
		});
		window.open(route.href, "_blank");
	} else if (item === '商业管制清单') {
		const route = router.resolve({
			path: "/dataLibrary/dataCommerceControlList",
		});
		window.open(route.href, "_blank");
	}
}


defineProps({
	title: {
		type: String,
		default: "标题"
	},
	subtitle: {
		type: String,
		default: "Subtitle"
	},
	description: {
		type: String,
		default: "描述信息"
	},
	quantity: {
		type: [Number, String],
		default: 0
	},
	unit: {
		type: String,
		default: ""
	},
	color: {
		type: String,
		default: "#409EFF"
	}
});
const desMap = {
	实体清单: "中国实体数量",
	商业管制清单: "受管制物项数量",
	关键与新兴技术清单: "关键与新兴技术数量"
};
</script>

<style scoped lang="scss">
.info-card {
	flex: 1;
	// max-width: 388px;
	min-width: 200px;
	height: 150px;
	border-radius: 12px;
	background-color: white;
	display: flex;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	position: relative;
	overflow: hidden;
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	cursor: pointer;
}

.info-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.color-bar {
	width: 6px;
	height: 120px;
	flex-shrink: 0;
	margin-top: 15px;
}

.card-content {
	flex: 1;
	padding: 20px;
	display: flex;
	flex-direction: column;
	position: relative;
}

.title-section {
	margin-bottom: 12px;
}

.main-title {
	font-family: $base-font-family;
	font-size: 24px;
	font-weight: 700;
	color: #1f2937;
	line-height: 1.2;
	max-width: 70%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.sub-title {
	font-size: 16px;
	font-weight: 700;
	line-height: 1.2;
	color: #6b7280;
	margin-top: 2px;
}

.description {
	font-size: 16px;
	font-weight: 400;
	color: rgba(95, 101, 108, 1);
	line-height: 1.4;
	flex: 1;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.quantity {
	position: absolute;
	top: 15px;
	right: 20px;
	font-size: 32px;
	font-weight: 700;
	width: 150px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	&:hover{
		text-decoration: underline;
		background: var(--color-primary-2);
	}


	.quantity-title-des {
		display: flex;
		align-items: center;
		font-family: Source Han Sans CN;
		font-size: 14px;
		font-weight: 400;
		color: rgba(95, 101, 108, 1);
		line-height: 1.4;

		.info-icon {
			width: 16px;
			height: 16px;
			margin-right: 4px;
		}
	}
}
</style>
