@extends('layouts.app', ['title' => 'Detail Maintenance', 'heading' => 'Detail Histori Maintenance'])

@section('content')
<div class="row">
    <div class="col-md-6">
        <div class="card mb-4">
            <h5 class="card-header">Informasi Maintenance</h5>
            <div class="card-body">
                <div class="row mb-3">
                    <label class="col-sm-4 fw-bold">Objek</label>
                    <div class="col-sm-8">
                        {{ $log->maintainable?->name ?? 'Objek terhapus' }}
                        <span class="badge bg-label-secondary ms-2">{{ class_basename($log->maintainable_type) }}</span>
                    </div>
                </div>
                <div class="row mb-3">
                    <label class="col-sm-4 fw-bold">Petugas</label>
                    <div class="col-sm-8">{{ $log->submitter_name }}</div>
                </div>
                <div class="row mb-3">
                    <label class="col-sm-4 fw-bold">Tanggal</label>
                    <div class="col-sm-8">{{ $log->performed_at?->translatedFormat('l, d F Y H:i') }}</div>
                </div>
                <div class="row mb-3">
                    <label class="col-sm-4 fw-bold">Kondisi</label>
                    <div class="col-sm-8">
                        @if($log->condition === 'good')
                            <span class="badge bg-label-success">BAIK</span>
                        @elseif($log->condition === 'minor')
                            <span class="badge bg-label-warning">RUSAK RINGAN</span>
                        @else
                            <span class="badge bg-label-danger">RUSAK BERAT</span>
                        @endif
                    </div>
                </div>
                <div class="row mb-3">
                    <label class="col-sm-4 fw-bold">Sumber</label>
                    <div class="col-sm-8"><span class="badge bg-label-secondary">{{ $log->source }}</span></div>
                </div>
                <div class="row mb-3">
                    <label class="col-sm-4 fw-bold">Catatan Lokasi</label>
                    <div class="col-sm-8">{{ $log->location_note ?: '-' }}</div>
                </div>
                <div class="row mb-3">
                    <label class="col-sm-4 fw-bold">Catatan Maintenance</label>
                    <div class="col-sm-8">{{ $log->notes ?: '-' }}</div>
                </div>
            </div>
            <div class="card-footer border-top">
                <a href="{{ route('maintenance.index') }}" class="btn btn-label-secondary waves-effect">Kembali</a>
                <a href="{{ route('maintenance.edit', $log->id) }}" class="btn btn-warning waves-effect waves-light">Edit</a>
            </div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="card">
            <h5 class="card-header">Foto Bukti</h5>
            <div class="card-body text-center">
                @if ($log->photo_path)
                    <img src="{{ \Illuminate\Support\Facades\Storage::url($log->photo_path) }}" alt="Foto Bukti" class="img-fluid rounded shadow-sm" style="max-height: 400px;">
                @else
                    <div class="py-5 text-muted">
                        <i class="ti tabler-photo-off d-block fs-1 mb-2"></i>
                        Tidak ada foto bukti.
                    </div>
                @endif
            </div>
        </div>
    </div>
</div>
@endsection
