---
import { authService } from '@/lib/authService';

// Инициализация клиента PocketBase
const pb = authService.createClientFromRequest(Astro.request);

// Получение данных из PocketBase
const requirementsData = await pb.collection('candidate_requirements').getFirstListItem('');
const requirementItems = await pb.collection('candidate_requirement_items').getList(1, 50, {
  filter: `parent_requirement = "${requirementsData.id}"`,
  sort: 'order'
});
---

<!-- Candidate Requirements Component -->
<section class="py-20 bg-gradient-to-br from-slate-50 to-white">
    <div class="max-w-4xl mx-auto px-6">
        <div class="text-center mb-16">
            <h2 class="text-3xl md:text-4xl font-bold text-gray-900 mb-4">
                {requirementsData.title}
            </h2>
            <div class="w-24 h-1 bg-amber-500 mx-auto mb-6"></div>
            <p class="text-gray-600 max-w-2xl mx-auto">
                {requirementsData.subtitle}
            </p>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
            {requirementItems.items.map((req) => (
                <div class="flex items-start p-6 bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300 group">
                    <div class="flex-shrink-0 w-12 h-12 rounded-full bg-amber-100 flex items-center justify-center group-hover:bg-amber-500 transition-colors duration-300">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-amber-600 group-hover:text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
                        </svg>
                    </div>
                    <div class="ml-4">
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">{req.requirement_title}</h3>
                        <p class="text-gray-600">{req.requirement_description}</p>
                    </div>
                </div>
            ))}
        </div>

        <div class="mt-16 bg-gradient-to-r from-amber-50 to-slate-50 rounded-2xl p-8 border border-amber-100">
            <div class="max-w-3xl mx-auto text-center">
                <div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-amber-100 text-amber-600 mb-6">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
                    </svg>
                </div>
                <h3 class="text-2xl font-bold text-gray-800 mb-4">Unser Versprechen</h3>
                <p class="text-gray-700 text-lg italic">
                    &ldquo;{requirementsData.quote}&rdquo;
                </p>
            </div>
        </div>
    </div>
</section>