{{--
    Partial: ряд 3 дашборда — быстрые действия, состояние системы, контент сайта
    Переменные: $leadsUnread, $leadsTotal, $carsTotal, $servicesTotal, $reviewsTotal,
                $visitsToday, $uniqueToday, $systemInfo
--}}
<div class="row">

    {{-- Быстрые действия --}}
    <div class="col-md-4">
        <div class="card card-outline card-secondary shadow-sm mb-3">
            <div class="card-header"><h3 class="card-title"><i class="fas fa-bolt mr-2"></i>Быстрые действия</h3></div>
            <div class="card-body">
                <div class="row">
                    <div class="col-6 mb-2">
                        <a href="{{ route('admin.cars.create') }}" class="btn btn-block btn-outline-warning btn-sm">
                            <i class="fas fa-plus mr-1"></i>Добавить авто
                        </a>
                    </div>
                    <div class="col-6 mb-2">
                        <a href="{{ route('admin.services.create') }}" class="btn btn-block btn-outline-primary btn-sm">
                            <i class="fas fa-plus mr-1"></i>Добавить услугу
                        </a>
                    </div>
                    <div class="col-6 mb-2">
                        <a href="{{ route('admin.reviews.create') }}" class="btn btn-block btn-outline-info btn-sm">
                            <i class="fas fa-plus mr-1"></i>Добавить отзыв
                        </a>
                    </div>
                    <div class="col-6 mb-2">
                        <a href="{{ route('admin.blocks.create') }}" class="btn btn-block btn-outline-success btn-sm">
                            <i class="fas fa-plus mr-1"></i>Новый блок
                        </a>
                    </div>
                    <div class="col-6 mb-2">
                        <a href="{{ route('admin.leads.index') }}" class="btn btn-block btn-outline-danger btn-sm">
                            <i class="fas fa-inbox mr-1"></i>Заявки
                        </a>
                    </div>
                    <div class="col-6 mb-2">
                        <form action="{{ route('admin.cache.clear') }}" method="POST" class="d-block">
                            @csrf
                            <button type="submit" class="btn btn-block btn-outline-secondary btn-sm">
                                <i class="fas fa-broom mr-1"></i>Очистить кеш
                            </button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    {{-- Состояние системы --}}
    <div class="col-md-4">
        <div class="card card-outline card-secondary shadow-sm mb-3">
            <div class="card-header"><h3 class="card-title"><i class="fas fa-server mr-2"></i>Система</h3></div>
            <div class="card-body p-0">
                <table class="table table-sm mb-0">
                    <tbody>
                        <tr>
                            <td class="text-muted" style="width:55%">PHP</td>
                            <td><code>{{ $systemInfo['php'] }}</code></td>
                        </tr>
                        <tr>
                            <td class="text-muted">Laravel</td>
                            <td><code>{{ $systemInfo['laravel'] }}</code></td>
                        </tr>
                        <tr>
                            <td class="text-muted">Кеш</td>
                            <td><code>{{ $systemInfo['cache_driver'] }}</code></td>
                        </tr>
                        <tr>
                            <td class="text-muted">OPcache</td>
                            <td>
                                @if($systemInfo['opcache'])
                                    <span class="text-success"><i class="fas fa-check-circle"></i> Включён</span>
                                    <small class="text-muted d-block">
                                        hits: {{ number_format($systemInfo['opcache_hits']) }}
                                    </small>
                                @else
                                    <span class="text-danger"><i class="fas fa-times-circle"></i> Выключен</span>
                                @endif
                            </td>
                        </tr>
                        <tr>
                            <td class="text-muted">Upload limit</td>
                            <td><code>{{ $systemInfo['max_upload'] }}</code></td>
                        </tr>
                        <tr>
                            <td class="text-muted">Memory</td>
                            <td><code>{{ $systemInfo['memory_limit'] }}</code></td>
                        </tr>
                        <tr>
                            <td class="text-muted">Диск</td>
                            <td>
                                <div class="progress mb-1" style="height:6px">
                                    <div class="progress-bar {{ $systemInfo['disk_pct'] > 80 ? 'bg-danger' : ($systemInfo['disk_pct'] > 60 ? 'bg-warning' : 'bg-success') }}"
                                         style="width:{{ $systemInfo['disk_pct'] }}%"></div>
                                </div>
                                <small class="text-muted">
                                    {{ $systemInfo['disk_pct'] }}% занято
                                    (свободно {{ $systemInfo['disk_free'] }})
                                </small>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    {{-- Контент сайта --}}
    <div class="col-md-4">
        <div class="card card-outline card-secondary shadow-sm mb-3">
            <div class="card-header"><h3 class="card-title"><i class="fas fa-database mr-2"></i>Контент сайта</h3></div>
            <div class="card-body p-0">
                <table class="table table-sm mb-0">
                    <tbody>
                        <tr>
                            <td class="text-muted">
                                <i class="fas fa-car text-warning mr-2"></i>Автомобили
                            </td>
                            <td class="text-right font-weight-bold">
                                <a href="{{ route('admin.cars.index') }}">{{ $carsTotal }}</a>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-muted">
                                <i class="fas fa-concierge-bell text-primary mr-2"></i>Услуги
                            </td>
                            <td class="text-right font-weight-bold">
                                <a href="{{ route('admin.services.index') }}">{{ $servicesTotal }}</a>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-muted">
                                <i class="fas fa-star text-info mr-2"></i>Отзывы
                            </td>
                            <td class="text-right font-weight-bold">
                                <a href="{{ route('admin.reviews.index') }}">{{ $reviewsTotal }}</a>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-muted">
                                <i class="fas fa-paper-plane text-danger mr-2"></i>Заявки
                            </td>
                            <td class="text-right font-weight-bold">
                                <a href="{{ route('admin.leads.index') }}">{{ $leadsTotal }}</a>
                                @if($leadsUnread > 0)
                                    <span class="badge badge-danger">{{ $leadsUnread }}</span>
                                @endif
                            </td>
                        </tr>
                        <tr>
                            <td class="text-muted">
                                <i class="fas fa-th-large text-success mr-2"></i>Блоки
                            </td>
                            <td class="text-right font-weight-bold">
                                <a href="{{ route('admin.blocks.index') }}">{{ \App\Models\Block::count() }}</a>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-muted">
                                <i class="fas fa-clock text-secondary mr-2"></i>Посетителей сегодня
                            </td>
                            <td class="text-right font-weight-bold text-info">{{ $visitsToday }}</td>
                        </tr>
                        <tr>
                            <td class="text-muted">
                                <i class="fas fa-user-check text-secondary mr-2"></i>Уникальных IP
                            </td>
                            <td class="text-right font-weight-bold">{{ $uniqueToday }}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</div>
