<template>
    <div class="space-y-6">
        <div>
            <h1 class="text-2xl font-black text-[#4a3f3b]">Welcome back{{ user ? ', ' + user.name : '' }}</h1>
            <p class="text-[#89726c] mt-1">Your FuelAlert dashboard.</p>
        </div>

        <div class="grid sm:grid-cols-3 gap-4">
            <RouterLink
                v-for="item in quickLinks"
                :key="item.to"
                :to="item.to"
                class="p-6 bg-white rounded-2xl border border-[#e5ded7] hover:border-[#bb5b3e] transition-colors space-y-3"
            >
                <iconify-icon :icon="item.icon" class="text-[#bb5b3e] text-2xl"></iconify-icon>
                <p class="font-bold text-[#4a3f3b]">{{ item.label }}</p>
                <p class="text-sm text-[#89726c]">{{ item.description }}</p>
            </RouterLink>
        </div>

        <div class="p-6 bg-white rounded-2xl border border-[#e5ded7] space-y-2">
            <p class="text-sm font-bold uppercase tracking-widest text-[#89726c]">Your plan</p>
            <p class="text-xl font-black text-[#4a3f3b] capitalize">{{ userTier }}</p>
            <a v-if="userTier === 'free'" href="/pricing" class="inline-block text-sm font-bold text-[#bb5b3e] hover:underline">
                Upgrade for alerts + predictions →
            </a>
        </div>
    </div>
</template>

<script setup>
import { RouterLink } from 'vue-router'
import { useAuth } from '../../composables/useAuth.js'

const { user, userTier } = useAuth()

const quickLinks = [
    { to: '/dashboard/saved-stations', label: 'Saved Stations', icon: 'lucide:bookmark', description: 'Stations you\'ve bookmarked for quick access.' },
    { to: '/dashboard/preferences', label: 'Preferences', icon: 'lucide:settings', description: 'Set your default fuel type and postcode.' },
    { to: '/', label: 'Find Fuel', icon: 'lucide:search', description: 'Search live prices near you.' },
]
</script>
