{{-- admin/dashboard.blade.php --}}
@extends('admin.layouts.app')
@section('title','Dashboard')
@section('page-title','Dashboard')
@section('content')
<div class="row g-3 mb-4">
    <div class="col-lg-3 col-md-6">
        <div class="stat-card">
            <div class="d-flex justify-content-between align-items-start">
                <div>
                    <div class="stat-label mb-1">Total Enquiries</div>
                    <div class="stat-number">{{ $stats['enquiries'] }}</div>
                </div>
                <div style="width:42px;height:42px;background:#fff8f0;border-radius:8px;display:flex;align-items:center;justify-content:center">
                    <i class="bi bi-envelope" style="color:var(--brand);font-size:1.2rem"></i>
                </div>
            </div>
            @if($stats['new_enquiries'])<div class="mt-2"><span class="badge badge-new">{{ $stats['new_enquiries'] }} new</span></div>@endif
        </div>
    </div>
    <div class="col-lg-3 col-md-6">
        <div class="stat-card">
            <div class="d-flex justify-content-between align-items-start">
                <div>
                    <div class="stat-label mb-1">CV Applications</div>
                    <div class="stat-number">{{ $stats['applications'] }}</div>
                </div>
                <div style="width:42px;height:42px;background:#f0fdf4;border-radius:8px;display:flex;align-items:center;justify-content:center">
                    <i class="bi bi-file-person" style="color:#166534;font-size:1.2rem"></i>
                </div>
            </div>
            @if($stats['new_applications'])<div class="mt-2"><span class="badge" style="background:#f0fdf4;color:#166534">{{ $stats['new_applications'] }} new</span></div>@endif
        </div>
    </div>
    <div class="col-lg-3 col-md-6">
        <div class="stat-card">
            <div class="d-flex justify-content-between align-items-start">
                <div>
                    <div class="stat-label mb-1">Products</div>
                    <div class="stat-number">{{ $stats['products'] }}</div>
                </div>
                <div style="width:42px;height:42px;background:#eff6ff;border-radius:8px;display:flex;align-items:center;justify-content:center">
                    <i class="bi bi-box-seam" style="color:#1d4ed8;font-size:1.2rem"></i>
                </div>
            </div>
        </div>
    </div>
    <div class="col-lg-3 col-md-6">
        <div class="stat-card">
            <div class="d-flex justify-content-between align-items-start">
                <div>
                    <div class="stat-label mb-1">Active Jobs</div>
                    <div class="stat-number">{{ $stats['jobs'] }}</div>
                </div>
                <div style="width:42px;height:42px;background:#fef9c3;border-radius:8px;display:flex;align-items:center;justify-content:center">
                    <i class="bi bi-person-badge" style="color:#854d0e;font-size:1.2rem"></i>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row g-3">
    <div class="col-lg-7">
        <div class="card-admin p-3">
            <div class="d-flex justify-content-between align-items-center mb-3">
                <div class="fw-700" style="font-size:.9rem">Recent Enquiries</div>
                <a href="{{ route('admin.enquiries.index') }}" class="btn btn-sm" style="font-size:.78rem;border:1px solid #e2e8f0;color:#374151">View All</a>
            </div>
            <table class="table table-sm mb-0">
                <thead><tr><th>Name</th><th>Type</th><th>Date</th><th>Status</th></tr></thead>
                <tbody>
                    @forelse($recentEnquiries as $enq)
                    <tr>
                        <td><a href="{{ route('admin.enquiries.show', $enq->id) }}" class="text-decoration-none fw-600" style="color:var(--dark)">{{ $enq->name }}</a><div style="font-size:.73rem;color:#64748b">{{ $enq->email }}</div></td>
                        <td><span class="badge" style="background:#eff6ff;color:#1e40af;font-size:.7rem">{{ ucfirst(str_replace('_',' ',$enq->enquiry_type)) }}</span></td>
                        <td style="font-size:.78rem;color:#64748b">{{ $enq->created_at->format('d M') }}</td>
                        <td><span class="badge badge-status-{{ $enq->status }} px-2">{{ ucfirst($enq->status) }}</span></td>
                    </tr>
                    @empty
                    <tr><td colspan="4" class="text-center text-muted py-3">No enquiries yet.</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
    </div>
    <div class="col-lg-5">
        <div class="card-admin p-3">
            <div class="fw-700 mb-3" style="font-size:.9rem">Quick Actions</div>
            <div class="d-flex flex-column gap-2">
                <a href="{{ route('admin.products.create') }}" class="btn btn-sm d-flex align-items-center gap-2" style="background:#f8fafc;border:1px solid #e2e8f0;color:#374151;text-align:left"><i class="bi bi-plus-circle text-brand"></i> Add Product</a>
                <a href="{{ route('admin.solutions.create') }}" class="btn btn-sm d-flex align-items-center gap-2" style="background:#f8fafc;border:1px solid #e2e8f0;color:#374151;text-align:left"><i class="bi bi-plus-circle text-brand"></i> Add Solution</a>
                <a href="{{ route('admin.case-studies.create') }}" class="btn btn-sm d-flex align-items-center gap-2" style="background:#f8fafc;border:1px solid #e2e8f0;color:#374151;text-align:left"><i class="bi bi-plus-circle text-brand"></i> Add Case Study</a>
                <a href="{{ route('admin.jobs.create') }}" class="btn btn-sm d-flex align-items-center gap-2" style="background:#f8fafc;border:1px solid #e2e8f0;color:#374151;text-align:left"><i class="bi bi-plus-circle text-brand"></i> Post New Job</a>
                <a href="{{ route('admin.resources.create') }}" class="btn btn-sm d-flex align-items-center gap-2" style="background:#f8fafc;border:1px solid #e2e8f0;color:#374151;text-align:left"><i class="bi bi-plus-circle text-brand"></i> Add Resource</a>
            </div>
        </div>
    </div>
</div>
@endsection
