@extends('admin.layouts.app')
@section('title', 'Testimonios')
@section('icon', 'people-fill')
@section('page-title', 'Testimonios / Comunidad')

@section('content')
<div class="page-header">
    <div class="page-header-left">
        <h1><i class="bi bi-people-fill"></i> Testimonios</h1>
        <div class="breadcrumb"><a href="{{ route('admin.dashboard') }}">Dashboard</a> <span class="breadcrumb-sep">/</span> <span>Testimonios</span></div>
    </div>
    <a href="{{ route('admin.testimonios.create') }}" class="btn btn-primary"><i class="bi bi-plus-lg"></i> Nuevo Testimonio</a>
</div>
<div class="card">
    <div class="table-responsive">
        <table class="admin-table">
            <thead><tr><th>#</th><th>Avatar</th><th>Nombre</th><th>Cargo / Empresa</th><th>Estrellas</th><th>Orden</th><th>Estado</th><th>Acciones</th></tr></thead>
            <tbody>
                @forelse($testimonios as $t)
                <tr>
                    <td>{{ $t->id }}</td>
                    <td>
                        <div style="width:40px;height:40px;border-radius:50%;background:linear-gradient(135deg,#2563eb,#8b5cf6);display:flex;align-items:center;justify-content:center;color:white;font-weight:700;overflow:hidden;">
                            @if($t->avatar)<img src="{{ asset('storage/'.$t->avatar) }}" style="width:100%;height:100%;object-fit:cover;">@else{{ strtoupper(substr($t->nombre,0,1)) }}@endif
                        </div>
                    </td>
                    <td><strong>{{ $t->nombre }}</strong></td>
                    <td>{{ $t->cargo }} — {{ $t->empresa }}</td>
                    <td>{{ str_repeat('⭐', $t->estrellas) }}</td>
                    <td>{{ $t->orden }}</td>
                    <td><span class="badge {{ $t->activo ? 'badge-success' : 'badge-danger' }}">{{ $t->activo ? 'Activo' : 'Inactivo' }}</span></td>
                    <td><div style="display:flex;gap:.5rem;">
                        <a href="{{ route('admin.testimonios.edit', $t) }}" class="btn btn-warning btn-sm"><i class="bi bi-pencil-fill"></i></a>
                        <form action="{{ route('admin.testimonios.destroy', $t) }}" method="POST" class="form-delete" data-item-name="{{ $t->nombre }}">@csrf @method('DELETE')<button type="submit" class="btn btn-danger btn-sm"><i class="bi bi-trash-fill"></i></button></form>
                    </div></td>
                </tr>
                @empty
                <tr><td colspan="8" style="text-align:center;padding:2rem;color:var(--gray-500);">No hay testimonios registrados.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection
