@extends('layouts.app')

@push('head')
<style>
    .pegawai-shell {
        position: relative;
        overflow: hidden;
        background: linear-gradient(155deg, rgba(10, 22, 48, 0.9) 0%, rgba(6, 14, 32, 0.86) 60%, rgba(4, 9, 22, 0.95) 100%);
        border: 1px solid rgba(99, 102, 241, 0.25);
        border-radius: 28px;
        padding: 36px 40px;
        box-shadow: 0 36px 68px rgba(4, 10, 26, 0.6);
        backdrop-filter: blur(18px);
    }
    .pegawai-shell::before,
    .pegawai-shell::after {
        content: "";
        position: absolute;
        width: 360px;
        height: 360px;
        border-radius: 50%;
        filter: blur(150px);
        opacity: 0.55;
        pointer-events: none;
    }
    .pegawai-shell::before {
        top: -240px;
        right: -200px;
        background: rgba(56, 189, 248, 0.45);
    }
    .pegawai-shell::after {
        bottom: -260px;
        left: -220px;
        background: rgba(129, 140, 248, 0.4);
    }
    .pegawai-shell > * { position: relative; z-index: 1; }
    .pegawai-header {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-bottom: 24px;
    }
    .pegawai-header h2 {
        margin: 0;
        font-size: 28px;
        font-weight: 700;
        letter-spacing: -0.02em;
    }
    .pegawai-header p {
        margin: 0;
        color: rgba(226, 232, 240, 0.76);
        letter-spacing: 0.03em;
        font-size: 13px;
    }
    .pegawai-alert {
        padding: 12px 14px;
        border-radius: 14px;
        font-size: 13px;
        margin-bottom: 16px;
    }
    .pegawai-alert.success {
        background: rgba(34, 197, 94, 0.14);
        border: 1px solid rgba(34, 197, 94, 0.38);
        color: #bbf7d0;
    }
    .pegawai-alert.error {
        background: rgba(248, 113, 113, 0.12);
        border: 1px solid rgba(248, 113, 113, 0.38);
        color: #fecaca;
    }
    .pegawai-summary {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 14px;
        margin-bottom: 24px;
    }
    .pegawai-summary-card {
        padding: 16px 18px;
        border-radius: 16px;
        background: rgba(8, 16, 36, 0.76);
        border: 1px solid rgba(129, 140, 248, 0.24);
        box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.12);
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    .pegawai-summary-card span {
        font-size: 12px;
        color: rgba(203, 213, 225, 0.7);
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }
    .pegawai-summary-card strong {
        font-size: 24px;
        font-weight: 700;
        color: #f8fafc;
    }
    .pegawai-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 18px;
        margin-bottom: 24px;
    }
    .pegawai-action-card {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 18px 20px;
        border-radius: 18px;
        background: rgba(14, 23, 45, 0.78);
        border: 1px solid rgba(148, 163, 184, 0.24);
        box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.12);
    }
    .pegawai-action-card h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 700;
        color: #e2e8f0;
    }
    .pegawai-action-card p {
        margin: 0;
        color: rgba(148, 163, 184, 0.82);
        font-size: 13px;
        line-height: 1.6;
    }
    .pegawai-action-card input[type="file"] {
        background: rgba(2, 6, 23, 0.92);
        border: 1px dashed rgba(148, 163, 184, 0.32);
        border-radius: 12px;
        padding: 10px 12px;
        color: #cbd5f5;
    }
    .pegawai-action-card button,
    .pegawai-action-card a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 12px 20px;
        border-radius: 14px;
        font-weight: 600;
        letter-spacing: 0.05em;
        color: #f8fafc;
        border: none;
        cursor: pointer;
        transition: transform 0.18s ease, box-shadow 0.18s ease;
        text-decoration: none;
    }
    .pegawai-action-card button:hover,
    .pegawai-action-card a:hover {
        transform: translateY(-2px);
    }
    .pegawai-btn-green {
        background: linear-gradient(135deg, #22c55e, #16a34a);
        box-shadow: 0 18px 32px rgba(34, 197, 94, 0.32);
    }
    .pegawai-btn-amber {
        background: linear-gradient(135deg, #f59e0b, #d97706);
        box-shadow: 0 18px 32px rgba(245, 158, 11, 0.32);
    }
    .pegawai-btn-blue {
        background: linear-gradient(135deg, #2563eb, #06b6d4);
        box-shadow: 0 18px 32px rgba(37, 99, 235, 0.28);
    }
    .pegawai-clock {
        color: rgba(226, 232, 240, 0.8);
        font-size: 14px;
        letter-spacing: 0.04em;
    }
</style>
@endpush

@section('content')
<div class="pegawai-shell">
    <div class="pegawai-header">
        <h2>Halo, {{ auth()->user()->name }}</h2>
        <p>Tetap pantau jam kerja dan tindakan absensi Anda melalui panel yang serba cepat ini.</p>
    </div>

    @if (session('status'))
        <div class="pegawai-alert success">{{ session('status') }}</div>
    @endif
    @if ($errors->any())
        <div class="pegawai-alert error">
            <ul style="margin:0; padding-left:16px;">
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    @php
        $currentTime = now();
        $formattedNow = $currentTime->format('d/m/Y H:i');
        $currentDay = $currentTime->isoFormat('dddd, D MMMM YYYY');
    @endphp

    <div class="pegawai-summary">
        <div class="pegawai-summary-card">
            <span>Tanggal</span>
            <strong>{{ $currentDay }}</strong>
        </div>
        <div class="pegawai-summary-card">
            <span>Waktu Saat Ini</span>
            <strong>{{ $currentTime->format('H:i:s') }}</strong>
        </div>
        <div class="pegawai-summary-card">
            <span>Status Akun</span>
            <strong>{{ strtoupper(auth()->user()->role ?? 'PEGAWAI') }}</strong>
        </div>
    </div>

    <div class="pegawai-actions">
        <div class="pegawai-action-card">
            <h3>Absen Masuk</h3>
            <p>Unggah selfie sebagai bukti kehadiran dan catat waktu kedatangan Anda.</p>
            <form method="POST" action="{{ route('absensi.clockIn') }}" enctype="multipart/form-data">
                @csrf
                <input type="file" name="selfie_photo" accept="image/*" capture="user" required>
                <button type="submit" class="pegawai-btn-green">Absen Masuk</button>
            </form>
        </div>
        <div class="pegawai-action-card">
            <h3>Absen Keluar</h3>
            <p>Selesaikan shift dengan mencatat waktu pulang secara cepat.</p>
            <form method="POST" action="{{ route('absensi.clockOut') }}">
                @csrf
                <button type="submit" class="pegawai-btn-amber">Absen Keluar</button>
            </form>
        </div>
        <div class="pegawai-action-card">
            <h3>Riwayat Kehadiran</h3>
            <p>Lihat kronologi lengkap aktivitas absensi Anda untuk memastikan semua data terekam.</p>
            <a href="{{ route('absensi.history') }}" class="pegawai-btn-blue">Lihat Riwayat</a>
        </div>
    </div>

    <div class="pegawai-clock">Terakhir diperbarui pada {{ $formattedNow }}.</div>
</div>
@endsection
