@extends('layouts.app')

@section('title', 'Brands')

@section('actions')
<a href="{{ route('settings.brands.create') }}" class="btn btn-primary">
    <i class="fas fa-plus-circle"></i> Add New Brand
</a>
@endsection

@section('content')
<div class="container-fluid">
    <div class="card">
        <div class="card-header">
            <h5 class="mb-0"><i class="fas fa-trademark me-2"></i>Brand List</h5>
        </div>
        <div class="card-body">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Logo</th>
                        <th>Name</th>
                        <th>Website</th>
                        <th>Models</th> <!-- Products count সরিয়ে দিলাম -->
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($brands as $brand)
                    <tr>
                        <td>{{ $brand->id }}</td>
                        <td>
                            @if($brand->logo)
                                <img src="{{ asset('storage/brands/'.$brand->logo) }}" alt="{{ $brand->name }}" style="max-height: 40px;">
                            @else
                                <span class="text-muted">No logo</span>
                            @endif
                        </td>
                        <td>{{ $brand->name }}</td>
                        <td>
                            @if($brand->website)
                                <a href="{{ $brand->website }}" target="_blank">{{ $brand->website }}</a>
                            @else
                                <span class="text-muted">-</span>
                            @endif
                        </td>
                        <td>
                            <span class="badge bg-info">{{ $brand->models_count ?? 0 }}</span>
                        </td>
                        <td>{!! $brand->status_badge !!}</td>
                        <td>
                            <a href="{{ route('settings.brands.edit', $brand) }}" class="btn btn-sm btn-info">
                                <i class="fas fa-edit"></i>
                            </a>
                            <form action="{{ route('settings.brands.destroy', $brand) }}" method="POST" class="d-inline">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?')">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </form>
                        </td>
                    </tr>
                    @empty
                    <tr>
                        <td colspan="7" class="text-center">No brands found.</td>
                    </tr>
                    @endforelse
                </tbody>
            </table>
            
            <div class="mt-3">
                {{ $brands->links() }}
            </div>
        </div>
    </div>
</div>
@endsection