@extends('layouts.app')

@section('title', '영업실적 상세')

@section('content')
<div class="max-w-2xl mx-auto">
    <!-- 페이지 헤더 -->
    <div class="mb-6 flex justify-between items-start">
        <div>
            <a href="{{ route('sales.records.index') }}" class="text-gray-500 hover:text-gray-700 text-sm mb-2 inline-flex items-center">
                <svg class="w-4 h-4 mr-1" 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>
            <h1 class="text-2xl font-bold text-gray-800">영업실적 상세</h1>
        </div>
        <a href="{{ route('sales.records.edit', $record->id) }}"
           class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg transition">
            수정
        </a>
    </div>

    <!-- 상세 정보 -->
    <div class="bg-white rounded-lg shadow-sm p-6 space-y-6">
        <div class="flex items-center justify-between">
            <span class="px-3 py-1 text-sm font-medium rounded-full {{ $record->status_color }}">
                {{ $record->status_label }}
            </span>
            <span class="text-gray-500">{{ $record->record_date->format('Y년 m월 d일') }}</span>
        </div>

        <div class="grid grid-cols-2 gap-6">
            <div class="bg-blue-50 rounded-lg p-4 text-center">
                <div class="text-2xl font-bold text-blue-800">{{ number_format($record->amount) }}원</div>
                <div class="text-sm text-blue-600">실적 금액</div>
            </div>
            <div class="bg-green-50 rounded-lg p-4 text-center">
                <div class="text-2xl font-bold text-green-800">{{ number_format($record->commission) }}원</div>
                <div class="text-sm text-green-600">수수료</div>
            </div>
        </div>

        <dl class="space-y-4 border-t pt-6">
            <div class="flex justify-between">
                <dt class="text-gray-500">실적 유형</dt>
                <dd class="font-medium text-gray-900">{{ $record->record_type }}</dd>
            </div>
            <div class="flex justify-between">
                <dt class="text-gray-500">담당자</dt>
                <dd class="font-medium text-gray-900">
                    @if($record->manager)
                    <a href="{{ route('sales.managers.show', $record->manager->id) }}" class="text-blue-600 hover:underline">
                        {{ $record->manager->name }}
                    </a>
                    @else
                    -
                    @endif
                </dd>
            </div>
            <div class="flex justify-between">
                <dt class="text-gray-500">가망고객</dt>
                <dd class="font-medium text-gray-900">
                    @if($record->prospect)
                    <a href="{{ route('sales.prospects.show', $record->prospect->id) }}" class="text-blue-600 hover:underline">
                        {{ $record->prospect->company_name }}
                    </a>
                    @else
                    -
                    @endif
                </dd>
            </div>
            <div class="flex justify-between">
                <dt class="text-gray-500">등록일</dt>
                <dd class="font-medium text-gray-900">{{ $record->created_at->format('Y-m-d H:i') }}</dd>
            </div>
            <div class="flex justify-between">
                <dt class="text-gray-500">수정일</dt>
                <dd class="font-medium text-gray-900">{{ $record->updated_at->format('Y-m-d H:i') }}</dd>
            </div>
        </dl>

        @if($record->description)
        <div class="border-t pt-6">
            <h3 class="text-sm font-medium text-gray-700 mb-2">설명</h3>
            <p class="text-gray-900 whitespace-pre-line">{{ $record->description }}</p>
        </div>
        @endif
    </div>
</div>
@endsection
