@extends('layouts.app')
@section('title', $plan->title)
@section('page_title', 'Yearly Plan')
@section('breadcrumbs')
    <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">Home</a></li>
    <li class="breadcrumb-item"><a href="{{ route('yearly-plans.index') }}">Yearly Planner</a></li>
    <li class="breadcrumb-item active">{{ \Illuminate\Support\Str::limit($plan->title, 30) }}</li>
@endsection
@section('page_actions')
    @can('academics.update')<a href="{{ route('yearly-plans.edit', $plan) }}" class="btn btn-outline-primary btn-sm"><i class="bi bi-pencil me-1"></i>Edit</a>@endcan
@endsection

@section('content')
    <div class="row g-3">
        <div class="col-lg-8">
            <div class="card">
                <div class="card-body">
                    <h4 class="mb-1">{{ $plan->title }}</h4>
                    <div class="mb-3">
                        <span class="badge bg-soft-primary">{{ $plan->schoolClass?->name }}{{ $plan->section ? ' / '.$plan->section->name : ' (whole class)' }}</span>
                        <span class="badge bg-soft-secondary">{{ $plan->subject?->name }}</span>
                        @if($plan->period)<span class="badge bg-soft-info">{{ $plan->period }}</span>@endif
                        @if($plan->academicSession)<span class="badge bg-soft-success">{{ $plan->academicSession->name }}</span>@endif
                    </div>

                    @if($plan->description)
                        <h6 class="text-muted small text-uppercase">Plan Details</h6>
                        <p style="white-space:pre-line">{{ $plan->description }}</p>
                    @endif
                </div>
            </div>
        </div>
        <div class="col-lg-4">
            <div class="card">
                <div class="card-header"><i class="bi bi-image me-1"></i>Plan Image</div>
                <div class="card-body text-center">
                    @if($plan->image_url)
                        <a href="{{ $plan->image_url }}" target="_blank"><img src="{{ $plan->image_url }}" class="img-fluid rounded border"></a>
                    @else
                        <div class="text-muted py-4"><i class="bi bi-image fs-1 d-block mb-2"></i>No image uploaded.</div>
                    @endif
                </div>
                <div class="card-footer bg-white small text-muted">
                    Added by {{ $plan->creator?->name ?? '—' }} · {{ $plan->created_at?->format('d M Y') }}
                </div>
            </div>
        </div>
    </div>
@endsection
