<script setup lang="ts">
import { useLeadForm } from '~/composables/useLeadForm'
const { form, loading, success, error, submit } = useLeadForm('download')
</script>

<template>
  <div class="max-w-sm mx-auto">
    <form v-if="!success" @submit.prevent="submit" class="space-y-4">
      <div>
        <label class="block text-sm font-medium mb-1 text-left">姓名 <span class="text-red-500">*</span></label>
        <input v-model="form.name" class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-primary focus:ring-2 focus:ring-primary-50 outline-none" placeholder="您的姓名" />
      </div>
      <div>
        <label class="block text-sm font-medium mb-1 text-left">单位名称 <span class="text-red-500">*</span></label>
        <input v-model="form.orgName" class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-primary focus:ring-2 focus:ring-primary-50 outline-none" placeholder="您所在的单位" />
      </div>
      <div>
        <label class="block text-sm font-medium mb-1 text-left">手机号 <span class="text-red-500">*</span></label>
        <input v-model="form.phone" type="tel" class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-primary focus:ring-2 focus:ring-primary-50 outline-none" placeholder="您的手机号" />
      </div>
      <p v-if="error" class="text-red-500 text-sm">{{ error }}</p>
      <button type="submit" :disabled="loading"
        class="w-full px-6 py-3 bg-primary text-white rounded-xl font-semibold hover:bg-primary-700 transition-colors disabled:opacity-50">
        {{ loading ? '提交中...' : '获取方案资料' }}
      </button>
    </form>
    <div v-else class="text-center py-8">
      <p class="text-xl font-bold mb-2">📥 资料已提交获取申请</p>
      <p class="text-sm text-text-secondary">我们将尽快将方案资料发送给您。</p>
    </div>
  </div>
</template>
