@extends('admin.layouts.app')
@section('title','News Ticker')
@section('styles')
<style>
:root{--m:#be123c;--mg:#e11d48;}
.mod-hero{background:linear-gradient(135deg,#881337,#be123c,#f43f5e);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(136,19,55,.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,#881337,#f43f5e);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:#fda4af;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:#fff1f2;color:#64748b;font-size:11px;font-weight:800;padding:10px 16px;text-transform:uppercase;letter-spacing:.5px;border-bottom:2px solid #fecdd3;white-space:nowrap;}
.pt tbody tr{border-bottom:1px solid #fff8f9;transition:background .15s;}
.pt tbody tr:hover{background:#fff1f2;}
.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:#fff1f2;color:#be123c;}
.act-ed:hover{background:#fecdd3;}
.act-del{background:#fef2f2;color:#dc2626;}
.act-del:hover{background:#fee2e2;}
.ticker-preview{background:linear-gradient(90deg,#881337,#f43f5e);border-radius:10px;padding:10px 16px;font-size:.82rem;font-weight:700;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:340px;}
.btn-new{display:inline-flex;align-items:center;gap:8px;padding:11px 22px;background:linear-gradient(135deg,#fda4af,#fb7185);color:#881337;border-radius:14px;font-weight:800;font-size:.88rem;text-decoration:none;box-shadow:0 4px 16px rgba(251,113,133,.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-megaphone-fill" style="color:#fda4af;font-size:18px;"></i>
            </div>
            News Ticker
        </h1>
        <p>Mensajes en la barra deslizante de la página principal</p>
    </div>
    <div style="display:flex;gap:12px;align-items:center;">
        <div class="hero-pill">{{ $items->count() }} ítems</div>
        <a href="{{ route('admin.ticker.create') }}" class="btn-new"><i class="bi bi-plus-lg"></i> Nuevo Ítem</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 Ítems del Ticker</span>
        <small>{{ $items->count() }} registros</small>
    </div>
    <div style="overflow-x:auto;">
        <table class="pt">
            <thead><tr><th>#</th><th>Texto</th><th>URL</th><th>Orden</th><th>Estado</th><th style="text-align:center;">Acciones</th></tr></thead>
            <tbody>
                @forelse($items as $item)
                <tr>
                    <td><span style="font-size:11px;color:#94a3b8;font-weight:700;">{{ $item->id }}</span></td>
                    <td>
                        <div class="ticker-preview">📢 {{ $item->texto }}</div>
                    </td>
                    <td>
                        @if($item->url)
                        <a href="{{ $item->url }}" target="_blank" style="color:#be123c;font-size:.83rem;display:flex;align-items:center;gap:4px;">
                            <i class="bi bi-box-arrow-up-right"></i>{{ Str::limit($item->url, 35) }}
                        </a>
                        @else<span style="color:#cbd5e1;font-size:.83rem;">—</span>@endif
                    </td>
                    <td><span style="font-weight:700;color:#be123c;background:#fff1f2;padding:3px 10px;border-radius:50px;font-size:.82rem;">{{ $item->orden }}</span></td>
                    <td><span class="ab {{ $item->activo ? 'ab-ok' : 'ab-no' }}"><i class="bi {{ $item->activo ? 'bi-check-circle-fill' : 'bi-x-circle-fill' }}"></i>{{ $item->activo ? 'Activo' : 'Inactivo' }}</span></td>
                    <td>
                        <div style="display:flex;gap:6px;justify-content:center;">
                            <a href="{{ route('admin.ticker.edit', $item) }}" class="act-btn act-ed" title="Editar"><i class="bi bi-pencil-fill"></i></a>
                            <form action="{{ route('admin.ticker.destroy', $item) }}" method="POST" class="form-delete" data-item-name="{{ Str::limit($item->texto, 40) }}">@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="6" style="padding:64px;text-align:center;"><i class="bi bi-megaphone" style="font-size:52px;color:#fda4af;display:block;margin-bottom:12px;"></i><strong style="color:#334155;display:block;">Sin ítems en el ticker</strong><a href="{{ route('admin.ticker.create') }}" class="btn-new" style="margin:12px auto 0;display:inline-flex;">Crear primero</a></td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection
