@extends('layouts.security')

@section('content')

<style>

.hover-card{
    transition:.25s;
}

.hover-card:hover{
    transform:translateY(-4px);
    box-shadow:0 12px 25px rgba(0,0,0,.10) !important;
}

</style>

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

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

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

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

</div>

<!-- STAT CARDS -->

<div style="
display:grid;
grid-template-columns:repeat(3,1fr);
gap:20px;
margin-bottom:25px;
">

<div style="
background:white;
padding:25px;
border-radius:18px;
box-shadow:0 4px 16px rgba(0,0,0,.05);
transition:.25s;
cursor:pointer;
"
onmouseover="
this.style.transform='translateY(-4px)';
this.style.boxShadow='0 12px 25px rgba(0,0,0,.10)';
"
onmouseout="
this.style.transform='translateY(0px)';
this.style.boxShadow='0 4px 16px rgba(0,0,0,.05)';
">

<h4 style="color:#64748b;">
Perjalanan Aktif
</h4>

<h1 style="
margin-top:10px;
color:#16a34a;
">
{{ $activeTripCount }}
</h1>

</div>

<div style="
background:white;
padding:25px;
border-radius:18px;
box-shadow:0 4px 16px rgba(0,0,0,.05);
transition:.25s;
cursor:pointer;
"
onmouseover="
this.style.transform='translateY(-4px)';
this.style.boxShadow='0 12px 25px rgba(0,0,0,.10)';
"
onmouseout="
this.style.transform='translateY(0px)';
this.style.boxShadow='0 4px 16px rgba(0,0,0,.05)';
">

<h4 style="color:#64748b;">
Perjalanan Hari Ini
</h4>

<h1 style="
margin-top:10px;
color:#2563eb;
">
{{ $tripsToday }}
</h1>

</div>

<div style="
background:white;
padding:25px;
border-radius:18px;
box-shadow:0 4px 16px rgba(0,0,0,.05);
transition:.25s;
cursor:pointer;
"
onmouseover="
this.style.transform='translateY(-4px)';
this.style.boxShadow='0 12px 25px rgba(0,0,0,.10)';
"
onmouseout="
this.style.transform='translateY(0px)';
this.style.boxShadow='0 4px 16px rgba(0,0,0,.05)';
">
<h4 style="color:#64748b;">
Pengembalian Hari Ini
</h4>

<h1 style="
margin-top:10px;
color:#dc2626;
">
{{ $returnedToday }}
</h1>

</div>

</div>

<!-- WARNING CARD -->

<div style="
background:#fff7ed;
padding:20px;
border-radius:18px;
margin-bottom:25px;
border-left:6px solid #f97316;
">

<h3>⚠ Peringatan Operasional</h3>

<p>
Pengembalian Terlambat:
<strong>{{ $lateTrips->count() }}</strong>
</p>

<p>
Perjalanan Aktif:
<strong>{{ $activeTrips->count() }}</strong>
</p>

</div>

<!-- ACTIVE TRIPS -->

<div style="
background:white;
padding:20px;
border-radius:18px;
box-shadow:0 4px 16px rgba(0,0,0,.05);
margin-bottom:25px;
transition:.25s;
"
onmouseover="
this.style.transform='translateY(-4px)';
this.style.boxShadow='0 12px 25px rgba(0,0,0,.10)';
"
onmouseout="
this.style.transform='translateY(0px)';
this.style.boxShadow='0 4px 16px rgba(0,0,0,.05)';
">

<h3>Log Monitor Peminjaman</h3>

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

<tr>

<th style="padding:16px;text-align:left;">
Karyawan
</th>

<th style="padding:16px;text-align:left;">
Kendaraan
</th>

<th style="padding:16px;text-align:left;">
Berangkat
</th>

<th style="padding:16px;text-align:left;">
Status
</th>

</tr>

@forelse($activeTrips as $trip)

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

<td style="padding:16px;">
{{ $trip->request->user->name ?? '-' }}
</td>

<td style="padding:16px;">
{{ $trip->vehicle->vehicle_name ?? '-' }}
</td>

<td style="padding:16px;">
{{ $trip->departure_time }}
</td>

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

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

ON TRIP

</span>

</td>

</tr>

@empty

<tr>

<td colspan="4"
style="
padding:20px;
text-align:center;
">

Tidak ada penggunaan aktif

</td>

</tr>

@endforelse

</table>

</div>

<!-- LATE RETURNS -->

<div style="
background:white;
padding:20px;
border-radius:18px;
box-shadow:0 4px 16px rgba(0,0,0,.05);
transition:.25s;
"
onmouseover="
this.style.transform='translateY(-4px)';
this.style.boxShadow='0 12px 25px rgba(0,0,0,.10)';
"
onmouseout="
this.style.transform='translateY(0px)';
this.style.boxShadow='0 4px 16px rgba(0,0,0,.05)';
">

<h3>Pengembalian Terlambat</h3>

@forelse($lateTrips as $trip)

<div style="
background:#fee2e2;
padding:15px;
border-radius:12px;
margin-bottom:10px;
">

<strong>
{{ $trip->vehicle->vehicle_name ?? 'Unknown Vehicle' }}
</strong>

<br>

Terlambat dikembalikan oleh:

<strong>
{{ $trip->request->user->name ?? 'Unknown Employee' }}
</strong>

</div>

@empty

<p>
Tidak ada pengembalian terlambat hari ini.
</p>

@endforelse

</div>

@endsection