@extends('layouts.default')

@section('content')
<div class="container-fluid">
    <div class="row page-titles mx-0">
        <div class="col-sm-6 p-md-0">
            <div class="welcome-text">
                <h4>{{ $notification->title }}</h4>
                <span>Bildirim detayı</span>
            </div>
        </div>
        <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
            <a href="{{ route('admin.notifications.index') }}" class="btn btn-secondary btn-sm">Bildirimlere Dön</a>
        </div>
    </div>

    <div class="card">
        <div class="card-header">
            <div>
                <span class="badge {{ $notification->badgeClass() }}">{{ $notification->label() }}</span>
                <span class="badge badge-light ml-2">{{ ucfirst($notification->category) }}</span>
            </div>
        </div>
        <div class="card-body">
            <p class="lead">{{ $notification->message }}</p>

            <div class="row mb-4">
                <div class="col-md-3"><strong>Müşteri:</strong><br>{{ optional($notification->client)->name ?? '-' }}</div>
                <div class="col-md-3"><strong>Kaynak:</strong><br>{{ $notification->source_type ?? '-' }} #{{ $notification->source_id ?? '-' }}</div>
                <div class="col-md-3"><strong>Oluşturulma:</strong><br>{{ optional($notification->created_at)->format('d.m.Y H:i') }}</div>
                <div class="col-md-3"><strong>Okunma:</strong><br>{{ optional($notification->read_at)->format('d.m.Y H:i') ?? '-' }}</div>
            </div>

            @if($notification->action_url)
                <a href="{{ $notification->action_url }}" class="btn btn-primary">{{ $notification->action_label ?: 'İlgili Ekrana Git' }}</a>
            @endif

            <form method="POST" action="{{ route('admin.notifications.dismiss', $notification) }}" class="d-inline">
                @csrf
                <button class="btn btn-outline-danger">Bildirim Gizle</button>
            </form>

            @if($notification->payload)
                <hr>
                <h5>Teknik Detay</h5>
                <pre class="bg-light p-3" style="white-space: pre-wrap;">{{ json_encode($notification->payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) }}</pre>
            @endif
        </div>
    </div>
</div>
@endsection
