<template>
    <div class="search-overview">
        <div class="header">
            <div class="title">搜索的使用次数</div>
            <div class="subtitle">2024-06-01至2024-06-25</div>
        </div>

        <div class="content">
            <!-- Stats -->
            <div class="stats-section">
                <div class="stat-item">
                    <div class="label">今日</div>
                    <div class="value">369次</div>
                    <div class="compare down">对比昨日 59% ↓</div>
                </div>
                <div class="stat-item">
                    <div class="label">合计</div>
                    <div class="value">36009次</div>
                </div>
                <div class="stat-item">
                    <div class="label">人均搜索次数</div>
                    <div class="value">3600次</div>
                </div>
            </div>

            <!-- Chart -->
            <div class="chart-section">
                <base-chart :option="chartOption" />
            </div>
        </div>
    </div>
</template>

<script setup>
    import { computed } from 'vue';
    import BaseChart from '@/components/Chart/BaseChart.vue';

    const chartOption = computed(() => ({
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            top: '10%',
            bottom: '10%',
            left: '3%',
            right: '4%',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            data: ['1日', '2日', '3日', '4日', '5日'],
            axisTick: { alignWithLabel: true }
        },
        yAxis: {
            type: 'value',
            splitLine: { lineStyle: { type: 'dashed' } }
        },
        series: [
            {
                name: '搜索总次数',
                type: 'line',
                smooth: true,
                data: [100, 140, 230, 100, 130],
                itemStyle: { color: '#5b8ff9' },
                areaStyle: {
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [
                            { offset: 0, color: 'rgba(91, 143, 249, 0.2)' },
                            { offset: 1, color: 'rgba(91, 143, 249, 0)' }
                        ]
                    }
                }
            }
        ]
    }));
</script>

<style scoped lang="scss">
    .search-overview {
        background-color: #f5f5f5;
        padding: 20px;
        border-radius: 8px;
        margin-bottom: 20px;
    }

    .header {
        margin-bottom: 20px;
        .title {
            font-size: 16px;
            font-weight: bold;
            color: #333;
        }
        .subtitle {
            font-size: 12px;
            color: #999;
            margin-top: 5px;
        }
    }

    .content {
        display: flex;
        align-items: center;

        .stats-section {
            flex: 0 0 40%;
            display: flex;
            justify-content: space-around;

            .stat-item {
                text-align: center;

                .label {
                    font-size: 14px;
                    color: #666;
                    margin-bottom: 10px;
                }

                .value {
                    font-size: 24px;
                    font-weight: bold;
                    color: #333;
                    margin-bottom: 5px;
                }

                .compare {
                    font-size: 12px;
                    &.down {
                        color: #52c41a; // Green for down usually means good? Or red? In finance Green is down (CN) or Up (US).
                        // Design shows green arrow down. Let's use green.
                    }
                }
            }
        }

        .chart-section {
            flex: 1;
            height: 200px;
        }
    }
</style>
