@extends('layouts.app')

@section('title', 'تفاصيل هيكل الراتب')

@section('content')
<div class="min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 py-8 px-4 md:px-8">
    <div class="max-w-4xl mx-auto">
        <div class="mb-8 flex items-center justify-between">
            <div>
                <h1 class="text-3xl font-bold text-gray-900 mb-2">تفاصيل هيكل الراتب</h1>
                <p class="text-gray-600">عرض معلومات الهيكل وتوزيع النسب</p>
            </div>
            <div class="flex gap-2">
                <a href="{{ route('salary-structures.index') }}" class="inline-flex items-center px-4 py-2 bg-white border border-gray-300 rounded-lg text-gray-700 font-medium hover:bg-gray-50 transition-all duration-200 shadow-sm">
                    <i class="fas fa-arrow-right ml-2"></i>
                    <span>العودة للقائمة</span>
                </a>
                @can('salary-structures.edit')
                <a href="{{ route('salary-structures.edit', $salaryStructure) }}" class="inline-flex items-center px-4 py-2 bg-amber-500 text-white rounded-lg font-medium hover:bg-amber-600 transition-all duration-200 shadow-sm">
                    <i class="fas fa-edit ml-2"></i>
                    <span>تعديل</span>
                </a>
                @endcan
            </div>
        </div>

        <div class="bg-white rounded-2xl shadow-xl overflow-hidden border border-gray-100 mb-8">
            <div class="p-8 border-b border-gray-100 bg-gray-50/50">
                <div class="flex justify-between items-start">
                    <div>
                        <h2 class="text-2xl font-bold text-gray-900 mb-2">{{ $salaryStructure->name }}</h2>
                        @if($salaryStructure->is_default)
                        <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-700">
                            <i class="fas fa-check-circle ml-1"></i>
                            هيكل افتراضي
                        </span>
                        @endif
                    </div>
                    <div class="text-right">
                        <span class="text-sm text-gray-500 block mb-1">تاريخ الإنشاء</span>
                        <span class="font-medium text-gray-900">{{ $salaryStructure->created_at->format('Y-m-d') }}</span>
                    </div>
                </div>
            </div>

            <div class="p-8">
                <div class="mb-8">
                    <h3 class="text-lg font-bold text-gray-800 mb-4 flex items-center">
                        <i class="fas fa-info-circle ml-2 text-blue-500"></i>
                        الوصف
                    </h3>
                    <div class="bg-gray-50 p-4 rounded-xl border border-gray-100 text-gray-700">
                        {{ $salaryStructure->description ?: 'لا يوجد وصف متاح' }}
                    </div>
                </div>

                <div>
                    <h3 class="text-lg font-bold text-gray-800 mb-4 flex items-center">
                        <i class="fas fa-chart-pie ml-2 text-blue-500"></i>
                        توزيع النسب المئوية
                    </h3>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="flex items-center justify-between p-4 bg-white border border-gray-100 rounded-xl shadow-sm">
                            <span class="text-gray-600">الراتب الأساسي</span>
                            <span class="text-2xl font-bold text-blue-600">{{ $salaryStructure->basic_salary_percentage }}%</span>
                        </div>
                        
                        <div class="flex items-center justify-between p-4 bg-white border border-gray-100 rounded-xl shadow-sm">
                            <span class="text-gray-600">بدل السكن</span>
                            <span class="text-2xl font-bold text-blue-600">{{ $salaryStructure->housing_allowance_percentage }}%</span>
                        </div>
                        
                        <div class="flex items-center justify-between p-4 bg-white border border-gray-100 rounded-xl shadow-sm">
                            <span class="text-gray-600">بدل المواصلات</span>
                            <span class="text-2xl font-bold text-blue-600">{{ $salaryStructure->transportation_allowance_percentage }}%</span>
                        </div>
                        
                        <div class="flex items-center justify-between p-4 bg-white border border-gray-100 rounded-xl shadow-sm">
                            <span class="text-gray-600">بدلات أخرى</span>
                            <span class="text-2xl font-bold text-blue-600">{{ $salaryStructure->other_allowances_percentage }}%</span>
                        </div>
                    </div>

                    <div class="mt-8 p-6 bg-blue-600 rounded-2xl text-white shadow-lg shadow-blue-200 flex items-center justify-between">
                        <div class="flex items-center">
                            <div class="w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center ml-4">
                                <i class="fas fa-check-double text-xl"></i>
                            </div>
                            <div>
                                <span class="text-blue-100 text-sm block">إجمالي النسب</span>
                                <span class="text-xl font-bold">مكتمل بنسبة 100%</span>
                            </div>
                        </div>
                        <div class="text-3xl font-black">100%</div>
                    </div>
                </div>
            </div>
        </div>

        {{-- 
        <div class="bg-white rounded-2xl shadow-xl overflow-hidden border border-gray-100 p-8">
            <h3 class="text-lg font-bold text-gray-800 mb-6 flex items-center">
                <i class="fas fa-users ml-2 text-blue-500"></i>
                الموظفون المرتبطون بهذا الهيكل ({{ $salaryStructure->employees->count() }})
            </h3>

            @if($salaryStructure->employees->count() > 0)
            <div class="overflow-x-auto">
                <table class="w-full text-right">
                    <thead class="bg-gray-50 text-gray-600 border-b border-gray-100">
                        <tr>
                            <th class="px-4 py-3 font-semibold text-sm">الموظف</th>
                            <th class="px-4 py-3 font-semibold text-sm">المسمى الوظيفي</th>
                            <th class="px-4 py-3 font-semibold text-sm">الحالة</th>
                            <th class="px-4 py-3 text-center font-semibold text-sm">الإجراءات</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-100">
                        @foreach($salaryStructure->employees as $employee)
                        <tr>
                            <td class="px-4 py-4 font-medium text-gray-900">{{ $employee->user->name }}</td>
                            <td class="px-4 py-4 text-gray-600 text-sm">{{ $employee->job_title }}</td>
                            <td class="px-4 py-4">
                                @if($employee->status == 'active')
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">نشط</span>
                                @else
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">{{ $employee->status }}</span>
                                @endif
                            </td>
                            <td class="px-4 py-4 text-center">
                                <a href="{{ route('employees.show', $employee) }}" class="text-blue-600 hover:text-blue-800 font-medium text-sm">
                                    عرض الملف
                                </a>
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
            @else
            <div class="text-center py-8 bg-gray-50 rounded-xl border border-dashed border-gray-300">
                <p class="text-gray-500">لا يوجد موظفون مرتبطون بهذا الهيكل حالياً</p>
            </div>
            @endif
        </div>
        --}}
    </div>
</div>
@endsection
