@extends('admin.layouts.app')
@section('title','Estadísticas')
@section('styles')
<style>
:root{--m:#0d47a1;--mg:#1565c0;--ma:#e3f2fd;}
.mod-hero{background:linear-gradient(135deg,#0a2e6e,#1565c0,#0288d1);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(13,71,161,.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,var(--m),#0288d1);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:#fff;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:#f0f7ff;color:#64748b;font-size:11px;font-weight:800;padding:10px 16px;text-transform:uppercase;letter-spacing:.5px;border-bottom:2px solid #dbeafe;white-space:nowrap;}
.pt tbody tr{border-bottom:1px solid #f8faff;transition:background .15s;}
.pt tbody tr:hover{background:#f0f7ff;}
.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:#eff6ff;color:#1d4ed8;}
.act-ed:hover{background:#dbeafe;}
.act-del{background:#fef2f2;color:#dc2626;}
.act-del:hover{background:#fee2e2;}
.empty-row td{padding:64px 20px;text-align:center;}
.empty-row .ei{font-size:52px;color:#bfdbfe;display:block;margin-bottom:12px;}
.btn-new{display:inline-flex;align-items:center;gap:8px;padding:11px 22px;background:linear-gradient(135deg,#ffe082,#ffca28);color:#0d47a1;border-radius:14px;font-weight:800;font-size:.88rem;text-decoration:none;box-shadow:0 4px 16px rgba(255,202,40,.3);transition:all .2s;}
.btn-new:hover{transform:translateY(-2px);}
.btn-back{display:inline-flex;align-items:center;gap:7px;padding:10px 18px;background:rgba(255,255,255,.12);border:1.5px solid rgba(255,255,255,.3);color:#fff;border-radius:12px;font-weight:700;font-size:.85rem;text-decoration:none;transition:all .2s;}
.btn-back:hover{background:rgba(255,255,255,.22);}
</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-bar-chart-fill" style="color:#ffe082;font-size:18px;"></i>
            </div>
            Estadísticas
        </h1>
        <p>Contadores animados que aparecen en la página pública</p>
    </div>
    <div style="display:flex;gap:12px;align-items:center;">
        <div class="hero-pill">{{ $estadisticas->count() }} registros</div>
        <a href="{{ route('admin.estadisticas.create') }}" class="btn-new">
            <i class="bi bi-plus-lg"></i> Nueva Estadística
        </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 Contadores</span>
        <small>{{ $estadisticas->count() }} registros</small>
    </div>
    <div style="overflow-x:auto;">
        <table class="pt">
            <thead>
                <tr>
                    <th>#</th><th>Ícono</th><th>Etiqueta</th><th>Valor</th><th>Sufijo</th><th>Color</th><th>Orden</th><th>Estado</th><th style="text-align:center;">Acciones</th>
                </tr>
            </thead>
            <tbody>
                @forelse($estadisticas as $e)
                <tr>
                    <td><span style="font-size:11px;color:#94a3b8;font-weight:700;">{{ $e->id }}</span></td>
                    <td>
                        <div style="width:42px;height:42px;border-radius:12px;background:{{ $e->color ?? '#3b82f6' }}18;display:flex;align-items:center;justify-content:center;">
                            <i class="bi {{ $e->icono ?? 'bi-bar-chart' }}" style="font-size:20px;color:{{ $e->color ?? '#3b82f6' }};"></i>
                        </div>
                    </td>
                    <td><strong style="color:#1e293b;">{{ $e->etiqueta }}</strong></td>
                    <td><span style="font-family:'Outfit',sans-serif;font-weight:900;font-size:1.3rem;color:{{ $e->color ?? '#3b82f6' }};">{{ number_format($e->valor) }}</span></td>
                    <td><span style="font-size:13px;color:#64748b;font-weight:600;">{{ $e->sufijo }}</span></td>
                    <td>
                        <div style="display:flex;align-items:center;gap:8px;">
                            <span style="width:26px;height:26px;border-radius:8px;background:{{ $e->color ?? '#3b82f6' }};display:inline-block;box-shadow:0 2px 8px {{ $e->color ?? '#3b82f6' }}55;"></span>
                            <span style="font-size:11px;color:#94a3b8;font-weight:700;">{{ $e->color ?? '#3b82f6' }}</span>
                        </div>
                    </td>
                    <td><span style="font-weight:700;color:#334155;">{{ $e->orden ?? 0 }}</span></td>
                    <td><span class="ab {{ $e->activo ? 'ab-ok' : 'ab-no' }}"><i class="bi {{ $e->activo ? 'bi-check-circle-fill' : 'bi-x-circle-fill' }}"></i>{{ $e->activo ? 'Activo' : 'Inactivo' }}</span></td>
                    <td>
                        <div style="display:flex;gap:6px;justify-content:center;">
                            <a href="{{ route('admin.estadisticas.edit', $e) }}" class="act-btn act-ed" title="Editar"><i class="bi bi-pencil-fill"></i></a>
                            <form action="{{ route('admin.estadisticas.destroy', $e) }}" method="POST" class="form-delete" data-item-name="{{ $e->etiqueta }}">@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 class="empty-row"><td colspan="9"><i class="ei bi bi-bar-chart"></i><strong style="color:#334155;display:block;margin-bottom:6px;">Sin estadísticas</strong><a href="{{ route('admin.estadisticas.create') }}" class="btn-new" style="margin:0 auto;">Crear primera</a></td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection
