@extends('admin.layouts.app')
@section('title', 'Features')
@section('content')
<div class="action-bar">
    <span>{{ $features->total() }} features</span>
    <a href="{{ route('admin.features.create') }}" class="btn btn-primary">+ New Feature</a>
</div>
<div class="card">
    <table>
        <tr><th>Image</th><th>Title</th><th>Icon</th><th>Order</th><th>Active</th><th>Actions</th></tr>
        @foreach($features as $feature)
        <tr>
            <td>
                @if($feature->image)
                    <img src="{{ asset('storage/'.$feature->image) }}" style="width:40px;height:auto;border-radius:4px" alt="{{ $feature->title }}">
                @elseif($feature->icon)
                    <span style="font-size:1.5rem">{{ $feature->icon }}</span>
                @else
                    <span class="text-muted">—</span>
                @endif
            </td>
            <td><strong>{{ $feature->title }}</strong></td>
            <td class="text-muted">{{ $feature->icon ?? '—' }}</td>
            <td>{{ $feature->order }}</td>
            <td>{!! $feature->is_active ? '<span style="color:#6fcf97">Yes</span>' : '<span style="color:#e74c3c">No</span>' !!}</td>
            <td class="inline-flex">
                <a href="{{ route('admin.features.edit', $feature) }}" class="btn btn-primary btn-sm">Edit</a>
                <form action="{{ route('admin.features.destroy', $feature) }}" method="POST" onsubmit="return confirm('Delete this feature?')">
                    @csrf @method('DELETE')
                    <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                </form>
            </td>
        </tr>
        @endforeach
    </table>
    <div class="pagination">{{ $features->links() }}</div>
</div>
@endsection
