@extends('layouts.admin')

@section('content')

<div style="margin-bottom:25px;">

    <p style="
    color:#64748b;
    font-size:14px;
    margin-bottom:8px;
    ">
        Home / Maintenance
    </p>

    <h2 style="
    font-size:34px;
    font-weight:700;
    margin:0;
    ">
        Rekap Maintenance
    </h2>

    <hr style="
    margin-top:20px;
    border:none;
    border-top:4px solid #e5e7eb;
    ">

</div>


<!-- ADD BUTTON -->
<div style="margin-bottom:20px;">

<a href="/admin/maintenance/create"
style="
background:#16a34a;
color:white;
padding:10px 18px;
border-radius:10px;
text-decoration:none;
font-weight:700;
font-size:14px;
display:inline-block;
box-shadow:0 4px 10px rgba(22,163,74,0.15);
">

+ Tambahkan Rekap Maintenance

</a>

</div>


<!-- TABLE CARD -->
<div class="card" style="
padding:20px;
border-radius:18px;
background:white;
box-shadow:0 4px 16px rgba(0,0,0,0.05);
">

<table style="
width:100%;
border-collapse:collapse;
">

<tr>

<th style="
padding:16px;
text-align:left;
color:#64748b;
font-size:14px;
font-weight:700;
border-bottom:1px solid #e5e7eb;
">
Kendaraan
</th>

<th style="
padding:16px;
text-align:left;
color:#64748b;
font-size:14px;
font-weight:700;
border-bottom:1px solid #e5e7eb;
">
Service
</th>

<th style="
padding:16px;
text-align:left;
color:#64748b;
font-size:14px;
font-weight:700;
border-bottom:1px solid #e5e7eb;
">
Tanggal
</th>

<th style="
padding:16px;
text-align:left;
color:#64748b;
font-size:14px;
font-weight:700;
border-bottom:1px solid #e5e7eb;
">
Biaya
</th>

<th style="
padding:16px;
text-align:left;
color:#64748b;
font-size:14px;
font-weight:700;
border-bottom:1px solid #e5e7eb;
">
Vendor
</th>

<th>Status</th>
<th>Aksi</th>

</tr>

@foreach($records as $record)

<tr style="
border-bottom:1px solid #f1f5f9;
">

<td style="padding:18px 16px;">

<strong>
{{ $record->vehicle->vehicle_name }}
</strong>

</td>

<td style="padding:18px 16px;">

<span style="
background:#dbeafe;
color:#1d4ed8;
padding:7px 14px;
border-radius:999px;
font-size:13px;
font-weight:700;
">

{{ $record->service_type }}

</span>

</td>

<td style="padding:18px 16px;">
{{ $record->service_date }}
</td>

<td style="padding:18px 16px;">

<strong>
Rp {{ number_format($record->cost, 0, ',', '.') }}
</strong>

</td>

<td style="padding:18px 16px;">
{{ $record->vendor }}
</td>

<!--STATUS-->

<td style="padding:18px 16px;">

@if(($record->maintenance_status ?? 'ongoing') == 'completed')

<span style="
background:#dcfce7;
color:#15803d;
padding:6px 12px;
border-radius:999px;
font-size:12px;
font-weight:700;
">
Selesai
</span>

@else

<span style="
background:#fef3c7;
color:#92400e;
padding:6px 12px;
border-radius:999px;
font-size:12px;
font-weight:700;
">
Proses
</span>

@endif

</td>

<td style="padding:18px 16px;">

@if(($record->maintenance_status ?? 'ongoing') != 'completed')

<form method="POST"
action="/admin/maintenance/{{ $record->id }}/complete">

@csrf

<button style="
background:#16a34a;
color:white;
border:none;
padding:8px 12px;
border-radius:8px;
cursor:pointer;
">
Selesaikan
</button>

</form>

@else

-

@endif

</td>

</tr>

@endforeach

</table>

</div>

@endsection