{{--
    Partial: ряд 1 дашборда — stat-карточки (заявки, посетители, авто, время ответа)
    Переменные: $leadsToday, $leadsUnread, $leadsYesterday, $leadsTotal,
                $visitsToday, $visitYesterday, $uniqueToday,
                $carsTotal, $servicesTotal, $reviewsTotal,
                $responseTime, $systemInfo
--}}
<div class="row">

    {{-- Заявки сегодня --}}
    <div class="col-6 col-md-3">
        <div class="info-box shadow-sm mb-3">
            <span class="info-box-icon {{ $leadsUnread > 0 ? 'bg-danger' : 'bg-success' }} elevation-1">
                <i class="fas fa-paper-plane"></i>
            </span>
            <div class="info-box-content">
                <span class="info-box-text">Заявки сегодня</span>
                <span class="info-box-number">
                    {{ $leadsToday }}
                    @if($leadsUnread > 0)
                        <span class="badge badge-danger ml-1">{{ $leadsUnread }} новых</span>
                    @endif
                </span>
                <div class="progress" style="height:3px">
                    @php $pct = $leadsYesterday > 0 ? min(100, round($leadsToday/$leadsYesterday*100)) : ($leadsToday > 0 ? 100 : 0); @endphp
                    <div class="progress-bar {{ $leadsToday >= $leadsYesterday ? 'bg-success' : 'bg-warning' }}"
                         style="width:{{ $pct }}%"></div>
                </div>
                <span class="progress-description">
                    Вчера: {{ $leadsYesterday }} | Всего: {{ $leadsTotal }}
                </span>
            </div>
        </div>
    </div>

    {{-- Посетители сегодня --}}
    <div class="col-6 col-md-3">
        <div class="info-box shadow-sm mb-3">
            <span class="info-box-icon bg-info elevation-1">
                <i class="fas fa-eye"></i>
            </span>
            <div class="info-box-content">
                <span class="info-box-text">Просмотры сегодня</span>
                <span class="info-box-number">
                    {{ number_format($visitsToday) }}
                </span>
                <div class="progress" style="height:3px">
                    @php $vPct = ($visitYesterday?->views ?? 0) > 0 ? min(100, round($visitsToday/($visitYesterday->views)*100)) : ($visitsToday > 0 ? 100 : 0); @endphp
                    <div class="progress-bar bg-info" style="width:{{ $vPct }}%"></div>
                </div>
                <span class="progress-description">
                    Уник. IP: {{ $uniqueToday }} | Вчера: {{ $visitYesterday?->views ?? 0 }}
                </span>
            </div>
        </div>
    </div>

    {{-- Авто в каталоге --}}
    <div class="col-6 col-md-3">
        <div class="info-box shadow-sm mb-3">
            <span class="info-box-icon bg-warning elevation-1">
                <i class="fas fa-car"></i>
            </span>
            <div class="info-box-content">
                <span class="info-box-text">Автомобилей</span>
                <span class="info-box-number">{{ $carsTotal }}</span>
                <div class="progress" style="height:3px">
                    <div class="progress-bar bg-warning" style="width:100%"></div>
                </div>
                <span class="progress-description">
                    Услуг: {{ $servicesTotal }} | Отзывов: {{ $reviewsTotal }}
                </span>
            </div>
        </div>
    </div>

    {{-- Скорость ответа --}}
    <div class="col-6 col-md-3">
        <div class="info-box shadow-sm mb-3">
            <span class="info-box-icon {{ ($responseTime ?? 999) < 200 ? 'bg-success' : (($responseTime ?? 999) < 500 ? 'bg-warning' : 'bg-danger') }} elevation-1">
                <i class="fas fa-tachometer-alt"></i>
            </span>
            <div class="info-box-content">
                <span class="info-box-text">Время ответа</span>
                <span class="info-box-number">
                    @if($responseTime !== null)
                        {{ $responseTime }} <small>мс</small>
                    @else
                        —
                    @endif
                </span>
                <div class="progress" style="height:3px">
                    @php $rPct = $responseTime ? min(100, round($responseTime / 10)) : 0; @endphp
                    <div class="progress-bar {{ $responseTime < 200 ? 'bg-success' : ($responseTime < 500 ? 'bg-warning' : 'bg-danger') }}"
                         style="width:{{ $rPct }}%"></div>
                </div>
                <span class="progress-description">
                    PHP {{ $systemInfo['php'] }} | OPcache {{ $systemInfo['opcache'] ? '✓' : '✗' }}
                </span>
            </div>
        </div>
    </div>

</div>
