@extends('admin.layouts.app')

@section('title', 'مدیریت عضلات')

@section('content')
    <div class="flex items-center justify-between mb-6">
        <h1 class="text-xl font-bold">عضلات</h1>
        <a href="{{ route('admin.muscles.create') }}" class="bg-gray-900 text-white text-sm px-4 py-2 rounded-lg">+ عضله جدید</a>
    </div>

    <form method="GET" class="flex gap-2 mb-4">
        <input type="text" name="q" value="{{ request('q') }}" placeholder="جستجو..." class="border rounded-lg px-3 py-2 text-sm flex-1">
        <button class="bg-gray-100 px-4 py-2 rounded-lg text-sm">جستجو</button>
    </form>

    <div class="bg-white rounded-xl shadow-sm overflow-x-auto">
        <table class="w-full text-sm">
            <thead class="bg-gray-50 text-gray-500">
                <tr>
                    <th class="p-3 text-right">نام</th>
                    <th class="p-3 text-right">وضعیت</th>
                    <th class="p-3 text-right">عملیات</th>
                </tr>
            </thead>
            <tbody class="divide-y">
                @forelse($muscles as $muscle)
                    <tr>
                        <td class="p-3 font-medium">{{ $muscle->name }}</td>
                        <td class="p-3">
                            @if($muscle->is_active)
                                <span class="text-green-600 bg-green-50 px-2 py-1 rounded-full text-xs">فعال</span>
                            @else
                                <span class="text-gray-500 bg-gray-100 px-2 py-1 rounded-full text-xs">غیرفعال</span>
                            @endif
                        </td>
                        <td class="p-3 flex gap-3">
                            <a href="{{ route('admin.muscles.edit', $muscle) }}" class="text-blue-600 hover:underline">ویرایش</a>
                            <form method="POST" action="{{ route('admin.muscles.destroy', $muscle) }}" onsubmit="return confirm('حذف شود؟');">
                                @csrf @method('DELETE')
                                <button class="text-red-600 hover:underline">حذف</button>
                            </form>
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="3" class="p-6 text-center text-gray-400">عضله‌ای ثبت نشده است.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>

    <div class="mt-4">{{ $muscles->links() }}</div>
@endsection
