@extends('admin.layouts.app')

@section('title', 'Dashboard')
@section('page_title', 'Dashboard')

@section('content')
<div class="page-shell">
    <div class="filter-card">
        <form method="GET" action="{{ route('admin.dashboard') }}">
            <label for="d">Filter by date</label>
            <div class="row">
                <div class="col">
                    <select name="d" id="d">
                        <option value="7" {{ $days === '7' ? 'selected' : '' }}>Last 7 days</option>
                        <option value="30" {{ $days === '30' ? 'selected' : '' }}>Last 30 days</option>
                        <option value="90" {{ $days === '90' ? 'selected' : '' }}>Last 90 days</option>
                        <option value="all" {{ $days === 'all' ? 'selected' : '' }}>All time</option>
                    </select>
                </div>
                <div class="col actions">
                    <button class="btn primary" type="submit">Apply</button>
                </div>
            </div>
        </form>
    </div>

    <div class="cards">
        <div class="card kpi"><div class="icon">🖨️</div><div class="meta"><div class="label">Total Sales</div><div class="value">৳ {{ number_format($totalSales, 2) }}</div></div></div>
        <div class="card kpi"><div class="icon">📈</div><div class="meta"><div class="label">Net</div><div class="value">৳ {{ number_format($net, 2) }}</div></div></div>
        <div class="card kpi"><div class="icon">🧾</div><div class="meta"><div class="label">Invoice Due</div><div class="value">৳ {{ number_format($invoiceDue, 2) }}</div></div></div>
        <div class="card kpi"><div class="icon">↩️</div><div class="meta"><div class="label">Total Sell Return</div><div class="value">৳ {{ number_format($totalSaleReturn, 2) }}</div></div></div>
        <div class="card kpi"><div class="icon">🛍️</div><div class="meta"><div class="label">Total Purchase</div><div class="value">৳ {{ number_format($totalPurchase, 2) }}</div></div></div>
        <div class="card kpi"><div class="icon">💸</div><div class="meta"><div class="label">Purchase Due</div><div class="value">৳ 0.00</div></div></div>
        <div class="card kpi"><div class="icon">↪️</div><div class="meta"><div class="label">Total Purchase Return</div><div class="value">৳ {{ number_format($totalSupplierReturn, 2) }}</div></div></div>
        <div class="card kpi"><div class="icon">💵</div><div class="meta"><div class="label">Expense ({{ $days === 'all' ? 'All Time' : 'Last '.$days.' Days' }})</div><div class="value">৳ {{ number_format($totalExpense, 2) }}</div></div></div>
    </div>

    <div class="card" style="min-height:420px;"></div>
</div>
@endsection
