@extends('layouts.app')

@section('title', $document['title'])

@section('content')
<!-- 페이지 헤더 -->
<div class="flex flex-col lg:flex-row lg:justify-between lg:items-center gap-4 mb-6">
    <div class="flex items-center gap-4">
        <a href="{{ route('roadmap.documents.index') }}" class="text-gray-500 hover:text-gray-700">
            ← 로드맵 문서
        </a>
        <h1 class="text-2xl font-bold text-gray-800">{{ $document['title'] }}</h1>
    </div>
    <div class="flex items-center gap-2">
        <span class="px-3 py-1 text-sm rounded-full bg-{{ $document['color'] }}-100 text-{{ $document['color'] }}-700">{{ $document['category_label'] }}</span>
        <span class="px-3 py-1 text-sm rounded-full bg-gray-100 text-gray-600">{{ $document['badge'] }}</span>
        <span class="text-sm text-gray-400">{{ $document['date'] }}</span>
    </div>
</div>

@if($document['description'])
<p class="text-gray-500 mb-6">{{ $document['description'] }}</p>
@endif

<!-- 문서 본문 -->
@if($content)
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-8">
    <article class="markdown-body">
        {!! $content !!}
    </article>
</div>
@else
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-12 text-center">
    <svg class="w-16 h-16 mx-auto mb-4 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" 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>
    <p class="text-gray-500 mb-2">문서 파일을 찾을 수 없습니다.</p>
    <p class="text-sm text-gray-400">경로: <code class="bg-gray-100 px-2 py-0.5 rounded">docs/{{ $document['path'] }}</code></p>
</div>
@endif
@endsection

@push('styles')
<style>
    .markdown-body {
        font-size: 14px;
        line-height: 1.7;
        color: #1f2937;
        word-wrap: break-word;
    }

    /* 제목 */
    .markdown-body h1 {
        font-size: 1.75rem;
        font-weight: 700;
        color: #111827;
        border-bottom: 2px solid #e5e7eb;
        padding-bottom: 0.6rem;
        margin: 2rem 0 1.2rem;
    }
    .markdown-body h1:first-child { margin-top: 0; }

    .markdown-body h2 {
        font-size: 1.35rem;
        font-weight: 700;
        color: #1f2937;
        border-bottom: 1px solid #f3f4f6;
        padding-bottom: 0.4rem;
        margin: 2rem 0 1rem;
    }

    .markdown-body h3 {
        font-size: 1.1rem;
        font-weight: 600;
        color: #374151;
        margin: 1.5rem 0 0.6rem;
    }

    .markdown-body h4 {
        font-size: 1rem;
        font-weight: 600;
        color: #4b5563;
        margin: 1.2rem 0 0.5rem;
    }

    /* 단락 */
    .markdown-body p {
        margin: 0.6rem 0;
        color: #374151;
    }

    /* 강조 */
    .markdown-body strong { color: #111827; }

    /* 링크 */
    .markdown-body a {
        color: #4f46e5;
        text-decoration: none;
    }
    .markdown-body a:hover { text-decoration: underline; }

    /* 인라인 코드 */
    .markdown-body code {
        background: #f3f4f6;
        color: #7c3aed;
        padding: 0.15em 0.4em;
        border-radius: 4px;
        font-size: 0.85em;
        font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
    }

    /* 코드 블록 */
    .markdown-body pre {
        background: #1e293b;
        color: #e2e8f0;
        border-radius: 8px;
        padding: 1rem 1.2rem;
        overflow-x: auto;
        margin: 1rem 0;
        line-height: 1.5;
    }
    .markdown-body pre code {
        background: none;
        color: inherit;
        padding: 0;
        border-radius: 0;
        font-size: 0.82rem;
    }

    /* 테이블 */
    .markdown-body table {
        width: 100%;
        border-collapse: collapse;
        margin: 1rem 0;
        font-size: 0.85rem;
    }
    .markdown-body thead th {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        padding: 0.55rem 0.75rem;
        text-align: left;
        font-weight: 600;
        color: #334155;
        white-space: nowrap;
    }
    .markdown-body tbody td {
        border: 1px solid #e2e8f0;
        padding: 0.5rem 0.75rem;
        color: #475569;
    }
    .markdown-body tbody tr:hover { background: #f8fafc; }

    /* 인용 */
    .markdown-body blockquote {
        border-left: 4px solid #818cf8;
        background: #eef2ff;
        margin: 1rem 0;
        padding: 0.75rem 1rem;
        border-radius: 0 6px 6px 0;
        color: #3730a3;
    }
    .markdown-body blockquote p {
        color: #3730a3;
        margin: 0.3rem 0;
    }
    .markdown-body blockquote strong { color: #312e81; }

    /* 리스트 */
    .markdown-body ul, .markdown-body ol {
        padding-left: 1.5rem;
        margin: 0.5rem 0;
    }
    .markdown-body li {
        margin: 0.25rem 0;
        color: #374151;
    }
    .markdown-body ul li { list-style-type: disc; }
    .markdown-body ol li { list-style-type: decimal; }
    .markdown-body li > ul, .markdown-body li > ol { margin: 0.15rem 0; }

    /* 구분선 */
    .markdown-body hr {
        border: none;
        border-top: 1px solid #e5e7eb;
        margin: 2rem 0;
    }

    /* 이미지 */
    .markdown-body img {
        max-width: 100%;
        border-radius: 8px;
        margin: 1rem 0;
    }
</style>
@endpush
