@extends('layouts.admin')

@section('title', 'Car Makes')
@section('page-title', 'Car Makes')

@section('content')
<div class="flex gap-4 mb-6">
    <a href="{{ route('admin.car-makes.index') }}" class="bg-gray-800 text-white px-4 py-2 rounded-lg text-sm">Car Makes</a>
    <a href="{{ route('admin.car-models.index') }}" class="bg-white text-gray-700 px-4 py-2 rounded-lg text-sm border hover:bg-gray-50">Car Models</a>
</div>

<div class="bg-white rounded-xl shadow-sm p-6">
    <div class="flex justify-end mb-4">
        <a href="{{ route('admin.car-makes.create') }}" class="bg-red-600 text-white px-4 py-2 rounded-lg text-sm hover:bg-red-700">+ Add Car Make</a>
    </div>
    <table class="w-full text-sm">
        <thead>
            <tr class="text-gray-500 border-b bg-gray-50">
                <th class="text-left p-3">Make</th>
                <th class="text-left p-3">Models</th>
                <th class="text-left p-3">Status</th>
                <th class="text-left p-3">Actions</th>
            </tr>
        </thead>
        <tbody>
            @foreach($makes as $make)
            <tr class="border-b hover:bg-gray-50">
                <td class="p-3 font-medium">{{ $make->name }}</td>
                <td class="p-3">{{ $make->models_count }}</td>
                <td class="p-3">
                    <span class="px-2 py-0.5 rounded-full text-xs {{ $make->is_active ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-600' }}">
                        {{ $make->is_active ? 'Active' : 'Inactive' }}
                    </span>
                </td>
                <td class="p-3 flex gap-2">
                    <a href="{{ route('admin.car-makes.edit', $make->id) }}" class="text-xs bg-blue-600 text-white px-2 py-1 rounded hover:bg-blue-700">Edit</a>
                    <form action="{{ route('admin.car-makes.destroy', $make->id) }}" method="POST" onsubmit="return confirm('Delete?')">
                        @csrf @method('DELETE')
                        <button class="text-xs bg-red-600 text-white px-2 py-1 rounded hover:bg-red-700">Delete</button>
                    </form>
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>
    <div class="mt-4">{{ $makes->links() }}</div>
</div>
@endsection
