@extends('layouts.admin')

@section('title', $departman->name)
@section('page-title', $departman->name)
@section('page-subtitle', 'Departman Detayları')

@section('content')
<div class="mt-4 max-w-3xl space-y-5">

    {{-- Üst Aksiyon Butonları --}}
    <div class="flex items-center gap-3">
        <a href="{{ route('admin.departmanlar.edit', $departman) }}"
           class="bg-primary text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-orange-600 transition-colors flex items-center gap-2">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
            </svg>
            Düzenle
        </a>
        <form method="POST" action="{{ route('admin.departmanlar.destroy', $departman) }}"
              onsubmit="return confirm('Bu departmanı silmek istediğinizden emin misiniz?')">
            @csrf
            @method('DELETE')
            <button type="submit"
                    class="bg-red-50 text-red-600 border border-red-200 px-4 py-2 rounded-lg text-sm font-medium hover:bg-red-100 transition-colors flex items-center gap-2">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
                </svg>
                Sil
            </button>
        </form>
        <a href="{{ route('admin.departmanlar.index') }}"
           class="text-sm text-gray-500 hover:text-gray-700 ml-auto">← Listeye Dön</a>
    </div>

    {{-- Ana Kart --}}
    <div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
        @if($departman->cover_image)
        <img src="{{ Storage::url($departman->cover_image) }}" class="w-full h-48 object-cover">
        @endif

        <div class="p-6 space-y-5">
            {{-- Başlık & Slug --}}
            <div>
                <h2 class="text-xl font-semibold text-gray-800">{{ $departman->name }}</h2>
                <p class="text-sm text-gray-400 mt-0.5">Slug: <span class="font-mono">{{ $departman->slug }}</span></p>
            </div>

            {{-- Açıklama --}}
            @if($departman->description)
            <div>
                <p class="text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1">Açıklama</p>
                <p class="text-sm text-gray-700 leading-relaxed">{{ $departman->description }}</p>
            </div>
            @endif

            {{-- İstatistikler --}}
            <div class="grid grid-cols-2 gap-4">
                <div class="bg-orange-50 rounded-lg p-4 text-center">
                    <p class="text-2xl font-bold text-primary">{{ $departman->job_postings_count }}</p>
                    <p class="text-xs text-gray-500 mt-1">Aktif İlan</p>
                </div>
                <div class="bg-blue-50 rounded-lg p-4 text-center">
                    <p class="text-2xl font-bold text-blue-600">{{ $departman->applications_count }}</p>
                    <p class="text-xs text-gray-500 mt-1">Toplam Başvuru</p>
                </div>
            </div>

            {{-- Durum Bilgileri --}}
            <div class="border-t border-gray-100 pt-4 grid grid-cols-3 gap-4 text-center text-sm">
                <div>
                    <p class="text-xs text-gray-400 mb-1">Durum</p>
                    <span class="inline-block px-2 py-1 rounded-full text-xs font-medium
                        {{ $departman->is_active ? 'bg-blue-100 text-blue-700' : 'bg-red-100 text-red-500' }}">
                        {{ $departman->is_active ? 'Aktif' : 'Pasif' }}
                    </span>
                </div>
                <div>
                    <p class="text-xs text-gray-400 mb-1">Açık Başvuru</p>
                    <span class="inline-block px-2 py-1 rounded-full text-xs font-medium
                        {{ $departman->accepts_open_applications ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500' }}">
                        {{ $departman->accepts_open_applications ? 'Açık' : 'Kapalı' }}
                    </span>
                </div>
                <div>
                    <p class="text-xs text-gray-400 mb-1">Sıralama</p>
                    <span class="text-gray-700 font-medium">{{ $departman->sort_order }}</span>
                </div>
            </div>
        </div>
    </div>

</div>
@endsection