@extends('layouts.admin')

@section('title', 'Manage Testimonials')

@section('content')
<div class="container mx-auto max-w-6xl">
    <div class="flex justify-between items-center mb-6">
        <h1 class="text-2xl font-bold text-slate-900">Manage Testimonials</h1>
        <a href="{{ route('admin.testimonials.create') }}" class="bg-brand-primary hover:bg-brand-accent text-white font-bold py-2.5 px-5 rounded-lg shadow-md shadow-brand-primary/20 transition flex items-center gap-2 text-sm">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path></svg>
            Add Testimonial
        </a>
    </div>

    <div class="bg-white shadow-sm rounded-xl border border-slate-100 overflow-hidden">
        <div class="overflow-x-auto">
            <table class="min-w-full leading-normal">
                <thead>
                    <tr>
                        <th class="px-5 py-4 border-b-2 border-slate-100/80 bg-slate-50 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">Client Name</th>
                        <th class="px-5 py-4 border-b-2 border-slate-100/80 bg-slate-50 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">Role</th>
                        <th class="px-5 py-4 border-b-2 border-slate-100/80 bg-slate-50 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">Content</th>
                        <th class="px-5 py-4 border-b-2 border-slate-100/80 bg-slate-50 text-right text-xs font-bold text-slate-500 uppercase tracking-wider">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-100">
                    @forelse ($testimonials as $testimonial)
                    <tr class="hover:bg-slate-50/50 transition duration-150 group">
                        <td class="px-5 py-5 bg-transparent text-sm">
                            <p class="text-slate-900 font-bold">{{ $testimonial->client_name }}</p>
                        </td>
                        <td class="px-5 py-5 bg-transparent text-sm">
                            <p class="text-slate-500">{{ $testimonial->client_role ?? '—' }}</p>
                        </td>
                        <td class="px-5 py-5 bg-transparent text-sm">
                            <p class="text-slate-600 truncate max-w-xs">{{ $testimonial->content }}</p>
                        </td>
                        <td class="px-5 py-5 bg-transparent text-sm text-right">
                            <div class="flex items-center justify-end gap-3 opacity-100 lg:opacity-0 group-hover:opacity-100 transition-opacity">
                                <a href="{{ route('admin.testimonials.edit', $testimonial) }}" class="p-2 text-slate-400 hover:text-brand-primary bg-slate-50 hover:bg-brand-light rounded-lg transition" title="Edit">
                                    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path></svg>
                                </a>
                                <form method="POST" action="{{ route('admin.testimonials.destroy', $testimonial) }}" class="inline" onsubmit="return confirm('Are you sure you want to delete this testimonial?');">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" class="p-2 text-slate-400 hover:text-red-500 bg-slate-50 hover:bg-red-50 rounded-lg transition" title="Delete">
                                        <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>
                                    </button>
                                </form>
                            </div>
                        </td>
                    </tr>
                    @empty
                    <tr>
                        <td colspan="4" class="px-5 py-10 text-center text-slate-500 bg-white">
                            <div class="flex flex-col items-center justify-center">
                                <svg class="w-12 h-12 text-slate-300 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"></path></svg>
                                <p class="text-lg font-medium text-slate-900 mb-1">No testimonials yet</p>
                                <p class="text-sm">Get started by adding client feedback.</p>
                            </div>
                        </td>
                    </tr>
                    @endforelse
                </tbody>
            </table>
        </div>
    </div>
</div>
@endsection
