<template>
    <div class="phenology-track-item">
        <div class="track-axis">
            <span class="track-date-side">{{ date }}</span>
            <div class="track-line-wrap">
                <span class="track-dot"></span>
                <div class="track-line"></div>
            </div>
        </div>
        <div class="track-card">
            <div class="track-card-inner">
                <span class="track-badge">{{ date }}</span>
                <span class="track-content">{{ content }}</span>
            </div>
            <div v-if="hasImages" class="track-images">
                <img v-for="(src, i) in images" :key="i" class="track-thumb" :src="src" alt="" />
            </div>
        </div>
    </div>
</template>

<script setup>
import { computed } from "vue";

const props = defineProps({
    date: {
        type: String,
        default: "",
    },
    content: {
        type: String,
        default: "",
    },
    images: {
        type: Array,
        default: () => [],
    },
});

const hasImages = computed(
    () => Array.isArray(props.images) && props.images.length > 0
);
</script>

<style scoped lang="scss">
/* Grid：左侧时间轴整列与右侧卡片等高，竖线随卡片高度自适应 */
.phenology-track-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: stretch;

    .track-axis {
        display: flex;
        flex-direction: column;

        .track-date-side {
            color: #7e7e7e;
        }

        .track-line-wrap {
            display: flex;
            flex: 1;
            flex-direction: column;
            align-items: center;
            margin-top: 3px;

            .track-dot {
                width: 6px;
                height: 6px;
                border-radius: 50%;
                background: rgba(29, 33, 41, 0.2);
                z-index: 1;
            }

            .track-line {
                flex: 1;
                margin-top: 2px;
                border-left: 1px dashed rgba(29, 33, 41, 0.2);
            }
        }
    }

    .track-card {
        flex: 1;
        padding: 10px;
        border-radius: 6px;
        background: #f5f5f5;

        .track-card-inner {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 5px 8px;
            border-radius: 5px;
            background: #ffffff;

            .track-badge {
                padding: 2px 4px;
                border-radius: 2px;
                font-size: 13px;
                color: #ffffff;
                background: #2199f8;
            }

            .track-content {
                color: rgba(60, 60, 60, 0.5);
            }
        }

        .track-images {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            margin-top: 10px;

            .track-thumb {
                width: 56px;
                height: 56px;
                border-radius: 8px;
                object-fit: cover;
            }
        }
    }
}
</style>
