@extends('admin.layouts.app')
@section('title','Sliders / Carrusel')
@section('styles')
<style>
:root{--m:#7c3aed;--mg:#8b5cf6;}
.mod-hero{background:linear-gradient(135deg,#4c1d95,#7c3aed,#8b5cf6);border-radius:20px;padding:22px 28px;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:16px;margin-bottom:22px;box-shadow:0 8px 32px rgba(76,29,149,.28);}
.mod-hero h1{font-size:1.3rem;font-weight:800;color:#fff;margin:0;display:flex;align-items:center;gap:10px;}
.mod-hero p{color:rgba(255,255,255,.5);margin:0;font-size:.82rem;}
.hero-pill{background:rgba(255,255,255,.12);border:1.5px solid rgba(255,255,255,.22);border-radius:50px;padding:7px 18px;color:#fff;font-weight:800;font-size:.9rem;}
.mod-card{background:#fff;border-radius:18px;box-shadow:0 2px 16px rgba(0,0,0,.06);overflow:hidden;}
.mod-card-hd{background:linear-gradient(135deg,#4c1d95,#8b5cf6);padding:13px 22px;display:flex;align-items:center;gap:10px;}
.mod-card-hd .hd-ic{width:32px;height:32px;border-radius:9px;background:rgba(255,255,255,.15);display:flex;align-items:center;justify-content:center;}
.mod-card-hd .hd-ic i{color:#ddd6fe;font-size:15px;}
.mod-card-hd span{color:#fff;font-weight:800;font-size:.92rem;}
.mod-card-hd small{color:rgba(255,255,255,.5);font-size:.75rem;font-weight:600;margin-left:auto;}
.pt{width:100%;border-collapse:collapse;font-size:13.5px;}
.pt thead th{background:#f5f3ff;color:#64748b;font-size:11px;font-weight:800;padding:10px 16px;text-transform:uppercase;letter-spacing:.5px;border-bottom:2px solid #ddd6fe;white-space:nowrap;}
.pt tbody tr{border-bottom:1px solid #fafafa;transition:background .15s;}
.pt tbody tr:hover{background:#f5f3ff;}
.pt td{padding:11px 16px;vertical-align:middle;}
.ab{padding:4px 10px;border-radius:50px;font-size:11px;font-weight:800;display:inline-flex;align-items:center;gap:4px;}
.ab-ok{background:#dcfce7;color:#15803d;}
.ab-no{background:#fee2e2;color:#dc2626;}
.act-btn{width:34px;height:34px;border-radius:9px;border:none;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;font-size:14px;transition:all .2s;text-decoration:none;}
.act-ed{background:#f5f3ff;color:#7c3aed;}
.act-ed:hover{background:#ede9fe;}
.act-del{background:#fef2f2;color:#dc2626;}
.act-del:hover{background:#fee2e2;}
.thumb{width:80px;height:48px;border-radius:10px;overflow:hidden;background:#f5f3ff;display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.thumb img{width:80px;height:48px;object-fit:cover;}
.btn-new{display:inline-flex;align-items:center;gap:8px;padding:11px 22px;background:linear-gradient(135deg,#c4b5fd,#a78bfa);color:#4c1d95;border-radius:14px;font-weight:800;font-size:.88rem;text-decoration:none;box-shadow:0 4px 16px rgba(167,139,250,.3);transition:all .2s;}
.btn-new:hover{transform:translateY(-2px);}
</style>
@endsection
@section('content')
<div class="mod-hero">
    <div>
        <h1>
            <div style="width:38px;height:38px;border-radius:12px;background:rgba(255,255,255,.15);border:1.5px solid rgba(255,255,255,.25);display:flex;align-items:center;justify-content:center;">
                <i class="bi bi-images" style="color:#c4b5fd;font-size:18px;"></i>
            </div>
            Sliders / Carrusel
        </h1>
        <p>Imágenes del carrusel principal de la página de inicio</p>
    </div>
    <div style="display:flex;gap:12px;align-items:center;">
        <div class="hero-pill">{{ $sliders->count() }} sliders</div>
        <a href="{{ route('admin.sliders.create') }}" class="btn-new"><i class="bi bi-plus-lg"></i> Nuevo Slider</a>
    </div>
</div>
<div class="mod-card">
    <div class="mod-card-hd">
        <div class="hd-ic"><i class="bi bi-list-ul"></i></div>
        <span>Todos los Sliders</span>
        <small>{{ $sliders->count() }} registros</small>
    </div>
    <div style="overflow-x:auto;">
        <table class="pt">
            <thead><tr><th>#</th><th>Imagen</th><th>Título</th><th>Subtítulo</th><th>Orden</th><th>Estado</th><th style="text-align:center;">Acciones</th></tr></thead>
            <tbody>
                @forelse($sliders as $slider)
                <tr>
                    <td><span style="font-size:11px;color:#94a3b8;font-weight:700;">{{ $slider->id }}</span></td>
                    <td>
                        <div class="thumb">
                            @if($slider->imagen)<img src="{{ asset('storage/'.$slider->imagen) }}" alt="{{ $slider->titulo }}">
                            @else<i class="bi bi-image" style="font-size:22px;color:#8b5cf6;"></i>@endif
                        </div>
                    </td>
                    <td><strong style="color:#1e293b;">{{ $slider->titulo }}</strong></td>
                    <td style="color:#64748b;font-size:.84rem;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{ $slider->subtitulo ?? '—' }}</td>
                    <td><span style="font-weight:700;color:#7c3aed;background:#f5f3ff;padding:3px 10px;border-radius:50px;font-size:.82rem;">{{ $slider->orden }}</span></td>
                    <td><span class="ab {{ $slider->activo ? 'ab-ok' : 'ab-no' }}"><i class="bi {{ $slider->activo ? 'bi-check-circle-fill' : 'bi-x-circle-fill' }}"></i>{{ $slider->activo ? 'Activo' : 'Inactivo' }}</span></td>
                    <td>
                        <div style="display:flex;gap:6px;justify-content:center;">
                            <a href="{{ route('admin.sliders.edit', $slider) }}" class="act-btn act-ed" title="Editar"><i class="bi bi-pencil-fill"></i></a>
                            <form action="{{ route('admin.sliders.destroy', $slider) }}" method="POST" class="form-delete" data-item-name="{{ $slider->titulo ?? 'este slider' }}">@csrf @method('DELETE')
                                <button type="submit" class="act-btn act-del" title="Eliminar"><i class="bi bi-trash-fill"></i></button>
                            </form>
                        </div>
                    </td>
                </tr>
                @empty
                <tr><td colspan="7" style="padding:64px;text-align:center;"><i class="bi bi-images" style="font-size:52px;color:#c4b5fd;display:block;margin-bottom:12px;"></i><strong style="color:#334155;display:block;">Sin sliders</strong><a href="{{ route('admin.sliders.create') }}" class="btn-new" style="margin:12px auto 0;display:inline-flex;">Crear primero</a></td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection
