<?php $__env->startSection('content'); ?>
<?php if(session()->has('not_permitted')): ?>
    <div class="alert alert-danger alert-dismissible text-center">
        <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
        <?php echo e(session('not_permitted')); ?>

    </div>
<?php endif; ?>
<?php if(session()->has('message')): ?>
    <div class="alert alert-success alert-dismissible text-center">
        <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
        <?php echo e(session('message')); ?>

    </div>
<?php endif; ?>

<section class="curtain-dashboard">
    <div class="container-fluid">
        <div class="dashboard-heading">
            <div>
                <h3><?php echo e(trans('file.Curtain Shop Overview')); ?></h3>
                <p><?php echo e($periodLabel); ?></p>
            </div>
            <div class="dashboard-heading-actions">
                <nav class="period-filter" aria-label="<?php echo e(trans('file.Time Period')); ?>">
                    <a href="<?php echo e(url('dashboard')); ?>?period=day" class="<?php echo e($selectedPeriod === 'day' ? 'active' : ''); ?>"><?php echo e(trans('file.Today')); ?></a>
                    <a href="<?php echo e(url('dashboard')); ?>?period=week" class="<?php echo e($selectedPeriod === 'week' ? 'active' : ''); ?>"><?php echo e(trans('file.This Week')); ?></a>
                    <a href="<?php echo e(url('dashboard')); ?>?period=month" class="<?php echo e($selectedPeriod === 'month' ? 'active' : ''); ?>"><?php echo e(trans('file.This Month')); ?></a>
                    <a href="<?php echo e(url('dashboard')); ?>?period=year" class="<?php echo e($selectedPeriod === 'year' ? 'active' : ''); ?>"><?php echo e(trans('file.This Year')); ?></a>
                </nav>
                <a href="<?php echo e(route('tailoringproducts.create')); ?>" class="btn btn-success">
                    <i class="dripicons-plus"></i> <?php echo e(trans('file.add_order')); ?>

                </a>
            </div>
        </div>

        <div class="dashboard-section-title"><?php echo e(trans('file.Today Financial Summary')); ?></div>
        <div class="metric-grid today-financial-metrics">
            <div class="metric-card">
                <span class="metric-icon icon-in"><i class="dripicons-arrow-thin-down"></i></span>
                <span>
                    <strong><?php echo e(\App\Support\NumberFormatter::natural($todayIncome, config('decimal'))); ?></strong>
                    <small><?php echo e(trans('file.Today Income')); ?></small>
                </span>
            </div>
            <div class="metric-card">
                <span class="metric-icon icon-out"><i class="dripicons-arrow-thin-up"></i></span>
                <span>
                    <strong><?php echo e(\App\Support\NumberFormatter::natural($todayCashOut, config('decimal'))); ?></strong>
                    <small><?php echo e(trans('file.Today Cash Out')); ?></small>
                </span>
            </div>
            <div class="metric-card">
                <span class="metric-icon <?php echo e($todayNetCash >= 0 ? 'icon-in' : 'icon-out'); ?>"><i class="dripicons-pulse"></i></span>
                <span>
                    <strong class="<?php echo e($todayNetCash < 0 ? 'negative-value' : ''); ?>"><?php echo e(\App\Support\NumberFormatter::natural($todayNetCash, config('decimal'))); ?></strong>
                    <small><?php echo e(trans('file.Today Net Cash')); ?></small>
                </span>
            </div>
            <a href="<?php echo e(route('accounts.index')); ?>" class="metric-card">
                <span class="metric-icon icon-cash"><i class="dripicons-wallet"></i></span>
                <span>
                    <strong><?php echo e(\App\Support\NumberFormatter::natural($mainCashBalance, config('decimal'))); ?></strong>
                    <small><?php echo e(trans('file.Main Cash Balance')); ?></small>
                </span>
            </a>
        </div>

        <div class="dashboard-section-title"><?php echo e(trans('file.Order Progress')); ?></div>
        <div class="metric-grid order-metrics">
            <a href="<?php echo e(route('tailoringproducts.index')); ?>" class="metric-card">
                <span class="metric-icon icon-active"><i class="dripicons-clock"></i></span>
                <span>
                    <strong><?php echo e($activeOrders); ?></strong>
                    <small><?php echo e(trans('file.Active Curtain Orders')); ?></small>
                </span>
            </a>
            <a href="<?php echo e(route('tailoringproducts.completed')); ?>" class="metric-card">
                <span class="metric-icon icon-waiting"><i class="dripicons-checklist"></i></span>
                <span>
                    <strong><?php echo e($awaitingAcceptance); ?></strong>
                    <small><?php echo e(trans('file.Awaiting Acceptance')); ?></small>
                </span>
            </a>
            <a href="<?php echo e(route('tailoringproducts.delivered')); ?>" class="metric-card">
                <span class="metric-icon icon-delivered"><i class="dripicons-box"></i></span>
                <span>
                    <strong><?php echo e($deliveredOrders); ?></strong>
                    <small><?php echo e(trans('file.Delivered Orders')); ?></small>
                </span>
            </a>
        </div>

        <div class="dashboard-section-title"><?php echo e(trans('file.Financial Overview')); ?></div>
        <div class="metric-grid financial-metrics">
            <a href="<?php echo e(route('tailoringproducts.index')); ?>" class="metric-card">
                <span class="metric-icon icon-customer"><i class="dripicons-user"></i></span>
                <span>
                    <strong><?php echo e(\App\Support\NumberFormatter::natural($customerDue, config('decimal'))); ?></strong>
                    <small><?php echo e(trans('file.Customer Due')); ?></small>
                </span>
            </a>
            <a href="<?php echo e(route('supplier.index')); ?>" class="metric-card">
                <span class="metric-icon icon-supplier"><i class="dripicons-store"></i></span>
                <span>
                    <strong><?php echo e(\App\Support\NumberFormatter::natural($supplierDue, config('decimal'))); ?></strong>
                    <small><?php echo e(trans('file.Supplier Due')); ?></small>
                </span>
            </a>
            <a href="<?php echo e(route('tailor.monthlySummary', ['month' => now()->format('Y-m')])); ?>" class="metric-card">
                <span class="metric-icon icon-tailor"><i class="dripicons-cutlery"></i></span>
                <span>
                    <strong><?php echo e(\App\Support\NumberFormatter::natural($tailorFeesDue, config('decimal'))); ?></strong>
                    <small><?php echo e(trans('file.Tailor Fees Due')); ?></small>
                </span>
            </a>
        </div>

        <div class="dashboard-columns">
            <div class="dashboard-panel orders-panel">
                <div class="panel-heading">
                    <h4><?php echo e(trans('file.Recent Curtain Orders')); ?></h4>
                    <a href="<?php echo e(route('tailoringproducts.index')); ?>"><?php echo e(trans('file.View All')); ?></a>
                </div>
                <div class="table-responsive">
                    <table class="table dashboard-table">
                        <thead>
                            <tr>
                                <th><?php echo e(trans('file.Order Code')); ?></th>
                                <th><?php echo e(trans('file.Customer')); ?></th>
                                <th><?php echo e(trans('file.Tailor')); ?></th>
                                <th><?php echo e(trans('file.Completion Date')); ?></th>
                                <th><?php echo e(trans('file.Status')); ?></th>
                                <th><?php echo e(trans('file.Due Amount')); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $recentOrders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <?php
                                    $statusLabels = [
                                        'pending' => trans('file.Pending'),
                                        'completed' => trans('file.Awaiting Acceptance'),
                                        'delivered' => trans('file.Delivered'),
                                    ];
                                ?>
                                <tr>
                                    <td><a href="<?php echo e(route('tailoringproducts.show', $order->id)); ?>"><?php echo e($order->code); ?></a></td>
                                    <td><?php echo e(optional($order->customer)->name ?: '-'); ?></td>
                                    <td><?php echo e(optional(optional($order->curtain)->tailor)->name ?: '-'); ?></td>
                                    <td><?php echo e(optional($order->completion_date)->format(config('date_format')) ?: '-'); ?></td>
                                    <td><span class="order-status status-<?php echo e($order->status); ?>"><?php echo e($statusLabels[$order->status] ?? $order->status); ?></span></td>
                                    <td><?php echo e(\App\Support\NumberFormatter::natural($order->due_amount, config('decimal'))); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr><td colspan="6" class="empty-row"><?php echo e(trans('file.No curtain orders found')); ?></td></tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="dashboard-panel stock-panel">
                <div class="panel-heading">
                    <h4><?php echo e(trans('file.Stock Attention')); ?></h4>
                    <a href="<?php echo e(route('report.qtyAlert')); ?>"><?php echo e(trans('file.View All')); ?></a>
                </div>
                <div class="table-responsive">
                    <table class="table dashboard-table">
                        <thead>
                            <tr>
                                <th><?php echo e(trans('file.Product')); ?></th>
                                <th><?php echo e(trans('file.Current Stock')); ?></th>
                                <th><?php echo e(trans('file.Alert Level')); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $lowStockItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><strong><?php echo e($item->name); ?></strong><small><?php echo e($item->code); ?></small></td>
                                    <td class="stock-low"><?php echo e(\App\Support\NumberFormatter::natural($item->current_stock, config('decimal'))); ?></td>
                                    <td><?php echo e(\App\Support\NumberFormatter::natural($item->alert_quantity, config('decimal'))); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr><td colspan="3" class="empty-row"><?php echo e(trans('file.No low stock items')); ?></td></tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div class="dashboard-panel transactions-panel">
            <div class="panel-heading">
                <h4><?php echo e(trans('file.Recent Cash Movements')); ?></h4>
                <a href="<?php echo e(route('accounts.index')); ?>"><?php echo e(trans('file.View All')); ?></a>
            </div>
            <div class="table-responsive">
                <table class="table dashboard-table">
                    <thead>
                        <tr>
                            <th><?php echo e(trans('file.Recorded')); ?></th>
                            <th><?php echo e(trans('file.reference')); ?></th>
                            <th><?php echo e(trans('file.Transaction Type')); ?></th>
                            <th><?php echo e(trans('file.Cash In')); ?></th>
                            <th><?php echo e(trans('file.Cash Out')); ?></th>
                            <th><?php echo e(trans('file.Balance')); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $recentTransactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td><?php echo e($transaction->created_at->format(config('date_format') . ' H:i')); ?></td>
                                <td><?php echo e($transaction->reference_no ?: '-'); ?></td>
                                <td><?php echo e(trans('file.' . $transaction->category)); ?></td>
                                <td class="cash-in"><?php echo e($transaction->direction === 'in' ? \App\Support\NumberFormatter::natural($transaction->amount, config('decimal')) : '-'); ?></td>
                                <td class="cash-out"><?php echo e($transaction->direction === 'out' ? \App\Support\NumberFormatter::natural($transaction->amount, config('decimal')) : '-'); ?></td>
                                <td><?php echo e(\App\Support\NumberFormatter::natural($transaction->balance_after, config('decimal'))); ?></td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr><td colspan="6" class="empty-row"><?php echo e(trans('file.No cash movements found')); ?></td></tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</section>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('css'); ?>
<style>
    .curtain-dashboard { padding-bottom: 28px; }
    .dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 10px 0 24px; }
    .dashboard-heading-actions { display: flex; align-items: center; gap: 12px; }
    .dashboard-heading h3 { margin: 0 0 4px; font-size: 22px; }
    .dashboard-heading p { margin: 0; color: #7a7e8f; }
    .period-filter { display: inline-flex; align-items: center; border: 1px solid #dfe3e8; background: #fff; }
    .period-filter a { min-width: 74px; padding: 9px 12px; border-inline-end: 1px solid #e7e9ed; color: #666a7d; font-size: 11px; font-weight: 600; text-align: center; white-space: nowrap; }
    .period-filter a:last-child { border-inline-end: 0; }
    .period-filter a:hover { color: #26951f; text-decoration: none; }
    .period-filter a.active { background: #26951f; color: #fff; }
    .dashboard-section-title { margin: 20px 0 10px; color: #6d7183; font-size: 12px; font-weight: 700; text-transform: uppercase; }
    .metric-grid { display: grid; gap: 12px; }
    .today-financial-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .order-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .financial-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .metric-card { display: flex; align-items: center; gap: 13px; min-height: 92px; padding: 16px; border: 1px solid #e5e8ed; background: #fff; color: #4f5265; box-shadow: 0 5px 18px rgba(33, 38, 49, .04); }
    a.metric-card:hover { border-color: #b9dcb7; color: #26951f; text-decoration: none; }
    .metric-card strong { display: block; margin-bottom: 3px; color: #36394b; font-size: 21px; line-height: 1.2; }
    .metric-card strong.negative-value { color: #bd453c; }
    .metric-card small { display: block; color: #777b8d; font-size: 12px; }
    .metric-icon { display: inline-flex; flex: 0 0 42px; align-items: center; justify-content: center; width: 42px; height: 42px; font-size: 20px; }
    .icon-active { background: #e8f1ff; color: #276cbd; }
    .icon-waiting { background: #fff2d7; color: #a56a00; }
    .icon-delivered, .icon-in { background: #e1f5e8; color: #16844b; }
    .icon-cash { background: #e8f7e6; color: #26951f; }
    .icon-customer { background: #e8f1ff; color: #276cbd; }
    .icon-supplier { background: #f0eaff; color: #6f4fb3; }
    .icon-tailor { background: #fff0e7; color: #ad5c27; }
    .icon-out { background: #ffe9e7; color: #b6473d; }
    .dashboard-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; margin-top: 24px; }
    .dashboard-panel { border: 1px solid #e5e8ed; background: #fff; box-shadow: 0 5px 18px rgba(33, 38, 49, .04); }
    .panel-heading { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 14px 18px; border-bottom: 1px solid #eceef2; }
    .panel-heading h4 { margin: 0; font-size: 15px; }
    .panel-heading a { color: #26951f; font-size: 12px; font-weight: 600; }
    .dashboard-table { margin: 0; }
    .dashboard-table th { padding: 11px 14px; border-top: 0; background: #f7f8fa; color: #717587; font-size: 11px; font-weight: 600; white-space: nowrap; }
    .dashboard-table td { padding: 12px 14px; border-top-color: #edf0f3; color: #565a6d; font-size: 12px; vertical-align: middle; }
    .dashboard-table td small { display: block; margin-top: 2px; color: #9195a3; }
    .order-status { display: inline-flex; padding: 4px 7px; font-size: 10px; font-weight: 700; white-space: nowrap; }
    .status-pending { background: #fff2d7; color: #966100; }
    .status-completed { background: #e8f1ff; color: #276cbd; }
    .status-delivered { background: #e1f5e8; color: #16844b; }
    .stock-low, .cash-out { color: #bd453c !important; font-weight: 700; }
    .cash-in { color: #16844b !important; font-weight: 700; }
    .transactions-panel { margin-top: 16px; }
    .empty-row { padding: 28px !important; color: #9296a5 !important; text-align: center; }
    @media (max-width: 991px) {
        .dashboard-heading { align-items: flex-start; }
        .dashboard-heading-actions { align-items: flex-end; flex-direction: column-reverse; }
        .today-financial-metrics, .financial-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .dashboard-columns { grid-template-columns: 1fr; }
    }
    @media (max-width: 575px) {
        .dashboard-heading { flex-direction: column; }
        .dashboard-heading-actions { align-items: stretch; width: 100%; }
        .period-filter { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
        .period-filter a { min-width: 0; padding: 9px 5px; }
        .dashboard-heading .btn { padding: 8px 10px; font-size: 11px; }
        .today-financial-metrics, .order-metrics, .financial-metrics { grid-template-columns: 1fr; }
        .metric-card { min-height: 76px; }
    }
</style>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('backend.layout.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\MHNazary\Pictures\sellbox\resources\views\backend\index.blade.php ENDPATH**/ ?>