{{-- admin/pages/case-studies/index.blade.php --}}
@extends('admin.layouts.app')
@section('title','Case Studies')
@section('page-title','Case Studies')
@section('content')
<div class="d-flex justify-content-between align-items-center mb-3">
    <div style="font-size:.82rem;color:#64748b">{{ $caseStudies->count() }} case studies</div>
    <a href="{{ route('admin.case-studies.create') }}" class="btn btn-admin btn-sm px-3"><i class="bi bi-plus-lg me-1"></i>Add Case Study</a>
</div>
<div class="card-admin">
    <table class="table table-hover mb-0">
        <thead><tr><th>#</th><th>Title</th><th>Category</th><th>Status</th><th style="width:130px">Actions</th></tr></thead>
        <tbody>
            @forelse($caseStudies as $cs)
            <tr>
                <td class="text-muted">{{ $cs->id }}</td>
                <td>
                    <div class="fw-600" style="color:#0f172a">{{ $cs->title }}</div>
                    <div style="font-size:.74rem;color:#94a3b8">{{ Str::limit($cs->summary, 65) }}</div>
                </td>
                <td>@if($cs->category)<span class="badge" style="background:#eff6ff;color:#1e40af;font-size:.72rem">{{ $cs->category }}</span>@else <span class="text-muted">—</span>@endif</td>
                <td><span class="badge" style="background:{{ $cs->is_active ? '#f0fdf4' : '#fee2e2' }};color:{{ $cs->is_active ? '#166534' : '#991b1b' }};font-size:.72rem">{{ $cs->is_active ? 'Active' : 'Inactive' }}</span></td>
                <td>
                    <div class="d-flex gap-1">
                        <a href="{{ route('admin.case-studies.edit', $cs->id) }}" class="btn btn-sm" style="background:#eff6ff;color:#1d4ed8;border:none"><i class="bi bi-pencil"></i></a>
                        <a href="{{ route('case-study.show', $cs->slug) }}" target="_blank" class="btn btn-sm" style="background:#f0fdf4;color:#166634;border:none"><i class="bi bi-eye"></i></a>
                        <form method="POST" action="{{ route('admin.case-studies.destroy', $cs->id) }}" onsubmit="return confirm('Delete?')">@csrf @method('DELETE')
                            <button class="btn btn-sm" style="background:#fee2e2;color:#991b1b;border:none"><i class="bi bi-trash"></i></button>
                        </form>
                    </div>
                </td>
            </tr>
            @empty
            <tr><td colspan="5" class="text-center py-4 text-muted">No case studies yet.</td></tr>
            @endforelse
        </tbody>
    </table>
</div>
@endsection
