<template>
    <div class="article-page-wrapper">
        <div class="article-list-container">
            <div v-for="item in articleList" :key="item.id" class="article-card" @click="handleCardClick(item)">
                <!-- 卡片头部信息 -->
                <div class="card-header">
                    <div class="header-left">
                        <h2 class="article-title" :title="item.title">{{ item.title }}</h2>
                        <div v-if="item.isHot" class="hot-badge">
                            <img class="hot-icon" src="@/public/article/hot.png" alt="">
                        </div>
                    </div>

                    <div class="header-meta">
                        <div class="meta-item">
                            <img class="meta-icon" src="@/public/article/date.png" alt="">
                            <span>{{ item.date }}</span>
                        </div>
                        <div class="meta-item">
                            <img class="meta-icon" src="@/public/article/eye.png" alt="">
                            <span>{{ item.views }}</span>
                        </div>
                    </div>
                </div>

                <!-- 卡片主体内容 -->
                <div class="card-body">
                    <div class="cover-thumb">
                        <img v-if="item.cover" :src="item.cover" :alt="item.title" class="cover-img" />
                        <div v-else class="cover-placeholder"></div>
                    </div>

                    <div class="content-right">
                        <p class="article-desc">{{ item.description }}</p>
                        <div class="action-box">
                            <button class="detail-btn" @click.stop="handleDetail(item)">查看详情</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 底部警告说明组件 -->
        <WarningFooter />
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import WarningFooter from '@/components/common/WarningFooter.vue'

const router = useRouter()

// 依照效果图高保真模拟数据（支持接口数据列表直接替换）
const articleList = ref([
    {
        id: 1,
        title: '微商模拟神器',
        isHot: true,
        date: '2026-7-20',
        views: '11.5K',
        cover: '',
        description: '我们不做“假图”，我们做的是“比真图更真的模拟器”。无论是你需要一张转账截图、一套朋友圈互动记录，还是一整份零钱账单流水，这款模拟器都能帮你瞬间完成。我们不做“假图”，我们做的是“比真图更真的模拟器”。无论是你需要一张转账截图、一套朋友圈互动记录，还是一整份零钱账单流水，这款模拟器都能帮你瞬间完成。'
    },
    {
        id: 2,
        title: '微商模拟神器哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈好...',
        isHot: true,
        date: '2026-7-20',
        views: '11.5K',
        cover: '',
        description: '我们不做“假图”，我们做的是“比真图更真的模拟器”。无论是你需要一张转账截图、一套朋友圈互动记录，还是一整份零钱账单流水，这款模拟器都能帮你瞬间完成。哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈...'
    },
    {
        id: 1,
        title: '微商模拟神器',
        isHot: true,
        date: '2026-7-20',
        views: '11.5K',
        cover: '',
        description: '我们不做“假图”，我们做的是“比真图更真的模拟器”。无论是你需要一张转账截图、一套朋友圈互动记录，还是一整份零钱账单流水，这款模拟器都能帮你瞬间完成。'
    },
    {
        id: 2,
        title: '微商模拟神器哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈好哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈',
        isHot: true,
        date: '2026-7-20',
        views: '11.5K',
        cover: '',
        description: '我们不做“假图”，我们做的是“比真图更真的模拟器”。无论是你需要一张转账截图、一套朋友圈互动记录，还是一整份零钱账单流水，这款模拟器都能帮你瞬间完成。哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈...'
    }
])

function handleDetail(item) {
    router.push({
        path: '/article-detail',
        query: { id: item.id }
    })
}

function handleCardClick(item) {
    handleDetail(item)
}
</script>

<style lang="scss" scoped>
.article-page-wrapper {
    min-height: calc(100vh - 112px);
    background-color: #F8F9FB;
    padding: 40px 20px 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.article-list-container {
    width: 100%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.article-card {
    width: 800px;
    background: #FFFFFF;
    border-radius: 16px;
    padding: 34px;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.1);

    &:hover {
        box-shadow: 0 8px 15px rgba(0, 0, 0, 0.07);
        transform: scale(1.005);
    }
}

/* 卡片头部样式 */
.card-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    gap: 16px;
    margin-bottom: 20px;

    &::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 1px;
        background-color: #D8D8D8;
        transform: scaleY(0.5);

    }
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    /* 允许标题自适应缩减触发 ellipsis */
}

.article-title {
    max-width: 468px;
    margin: 0;
    font-weight: 700;
    font-size: 18px;
    color: #1A1A1A;
    line-height: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* HOT 标签样式 */
.hot-badge {
    width: 41px;
    height: 18px;

    img {
        width: 100%;
        height: 100%;
    }
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #999999;
    font-size: 14px;
    flex-shrink: 0;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 18px;
    color: #AAAAAA;
    line-height: 18px;

    .meta-icon {
        width: 20px;
        height: 20px;
    }
}

/* 卡片主体内容布局 */
.card-body {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.cover-thumb {
    width: 170px;
    height: 125px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;

    .cover-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .cover-placeholder {
        width: 100%;
        height: 100%;
        background-color: #D8D8D8;
    }
}

.content-right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    min-height: 125px;
}

.article-desc {
    margin: 0;
    font-weight: 400;
    font-size: 16px;
    color: #767676;
    line-height: 26px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-box {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.detail-btn {
    width: 100px;
    height: 36px;
    background: linear-gradient(215deg, #A679F4 7.14%, #778CF5 100%);
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(120, 84, 255, 0.25);

    &:hover {
        opacity: 0.92;
        box-shadow: 0 6px 16px rgba(120, 84, 255, 0.35);
    }

    &:active {
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .card-body {
        flex-direction: column;
    }

    .cover-thumb {
        width: 100%;
        height: 160px;
    }

    .content-right {
        min-height: auto;
    }
}
</style>