@extends('layouts.app')

@section('title', '로드맵 문서')

@section('content')
<!-- 페이지 헤더 -->
<div class="flex flex-col lg:flex-row lg:justify-between lg:items-center gap-4 mb-6">
    <h1 class="text-2xl font-bold text-gray-800 flex items-center gap-2">
        <svg class="w-6 h-6 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
        </svg>
        로드맵 문서
    </h1>
    <div class="flex flex-wrap items-center gap-2">
        <a href="{{ route('roadmap.index') }}" class="inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white hover:bg-gray-100 text-gray-700 rounded-lg border transition">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
            </svg>
            대시보드
        </a>
        <a href="{{ route('roadmap.plans.index') }}" class="inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white hover:bg-gray-100 text-gray-700 rounded-lg border transition">
            계획 목록
        </a>
    </div>
</div>

<!-- 소개 -->
<div class="bg-gradient-to-r from-indigo-50 to-blue-50 rounded-lg p-6 mb-8 border border-indigo-100">
    <h2 class="text-lg font-bold text-indigo-900 mb-2">SAM 중장기 계획 문서</h2>
    <p class="text-sm text-indigo-700">SAM 프로젝트의 비전, 로드맵, 제품 설계 문서를 한 곳에서 확인할 수 있습니다. 각 문서를 클릭하면 상세 내용을 볼 수 있습니다.</p>
</div>

<!-- 문서 카테고리별 목록 -->
@foreach($registry as $group)
<div class="mb-8">
    <h2 class="text-lg font-bold text-gray-800 flex items-center gap-2 mb-4">
        <i class="{{ $group['icon'] }} text-{{ $group['color'] }}-600"></i>
        {{ $group['category_label'] }}
    </h2>
    <div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
        @foreach($group['items'] as $item)
        <a href="{{ $item['exists'] ? route('roadmap.documents.show', $item['slug']) : '#' }}"
           class="block bg-white rounded-lg shadow-sm border border-gray-200 p-5 hover:shadow-md hover:border-{{ $group['color'] }}-300 transition group {{ !$item['exists'] ? 'opacity-50 cursor-not-allowed' : '' }}">
            <div class="flex items-start justify-between mb-3">
                <h3 class="text-sm font-bold text-gray-900 group-hover:text-{{ $group['color'] }}-700 transition leading-snug">{{ $item['title'] }}</h3>
                <span class="shrink-0 ml-2 px-2 py-0.5 text-xs rounded-full bg-{{ $group['color'] }}-100 text-{{ $group['color'] }}-700">{{ $item['badge'] }}</span>
            </div>
            <p class="text-xs text-gray-500 mb-3 leading-relaxed">{{ $item['description'] }}</p>
            <div class="flex items-center justify-between text-xs text-gray-400">
                <span>{{ $item['date'] }}</span>
                @if($item['exists'])
                <span class="flex items-center gap-1 text-{{ $group['color'] }}-500">
                    문서 보기
                    <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
                    </svg>
                </span>
                @else
                <span class="text-gray-300">파일 없음</span>
                @endif
            </div>
        </a>
        @endforeach
    </div>
</div>
@endforeach
@endsection
