@extends('admin.layout')

@section('title', 'Sponsors - Admin OnAPB')

@section('content')
<div class="mb-5 d-flex justify-content-between align-items-end">
    <div>
        <span class="text-primary fw-bold text-uppercase tracking-widest d-block mb-2">Alianzas Estratégicas</span>
        <h1 class="display-4 fw-bold font-header mb-0">Sponsors<span class="text-primary">.</span></h1>
    </div>
    <a href="{{ route('admin.sponsors.create') }}" class="btn-admin-primary">
        <i class="bi bi-plus-lg me-2"></i> NUEVO SPONSOR
    </a>
</div>

<div class="admin-card">
    @if($sponsors->isEmpty())
        <div class="text-center py-5">
            <i class="bi bi-star text-muted mb-3" style="font-size: 3rem;"></i>
            <p class="fs-5 text-muted">No hay sponsors registrados.</p>
        </div>
    @else
        <div class="table-responsive">
            <table class="kinetic-table">
                <thead>
                    <tr>
                        <th style="width: 80px;">Orden</th>
                        <th>Imagen</th>
                        <th>Nombre</th>
                        <th>Enlace</th>
                        <th>Estado</th>
                        <th class="text-end">Acciones</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($sponsors as $s)
                    <tr>
                        <td><span class="badge bg-light text-dark fw-bold border p-2">{{ $s->orden }}</span></td>
                        <td>
                            <div class="bg-white p-2 border" style="width: 100px; height: 50px; display: inline-flex; align-items: center; justify-content: center;">
                                <img src="{{ asset($s->imagen) }}" alt="{{ $s->nombre }}" style="max-width: 100%; max-height: 100%; object-fit: contain;">
                            </div>
                        </td>
                        <td><span class="fw-bold fs-5 text-uppercase">{{ $s->nombre }}</span></td>
                        <td>
                            @if($s->url)
                                <a href="{{ $s->url }}" target="_blank" class="small text-muted font-monospace">{{ Str::limit($s->url, 30) }}</a>
                            @else
                                <span class="text-muted small">SIN ENLACE</span>
                            @endif
                        </td>
                        <td>
                            @if($s->activo)
                                <span class="badge bg-success text-white text-uppercase px-2 py-1">ACTIVO</span>
                            @else
                                <span class="badge bg-light text-muted border text-uppercase px-2 py-1">OCULTO</span>
                            @endif
                        </td>
                        <td class="text-end">
                            <a href="{{ route('admin.sponsors.edit', $s->id_sponsor) }}" class="btn btn-sm btn-light border me-1">
                                <i class="bi bi-pencil"></i>
                            </a>
                            <form action="{{ route('admin.sponsors.destroy', $s->id_sponsor) }}" method="POST" class="d-inline delete-form confirm-submit" data-confirm-text="¿Eliminar este sponsor?">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn btn-sm btn-outline-danger">
                                    <i class="bi bi-trash"></i>
                                </button>
                            </form>
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    @endif
</div>
@endsection
