@extends('layouts.app')

@section('title', 'Panel Petugas')
@section('page_header', 'Petugas Lapangan')

@section('sidebar')
<div id="sidebar-wrapper">

    {{-- HEADER --}}
    <div class="sidebar-header">
        <img src="/img/logo.png" alt="Logo E-Absensi">
        <h6>E-ABSENSI</h6>
        <span class="badge bg-success-subtle text-success px-3 py-2 rounded-pill" style="font-size: 10px;">
            {{ auth()->user()->role === 'guru' ? 'GURU' : 'PETUGAS' }}
        </span>
    </div>

    {{-- MENU NAVIGASI --}}
    <div class="overflow-auto flex-grow-1">

        <p class="menu-title">Beranda Utama</p>
        <a href="{{ route('petugas.dashboard') }}"
           class="nav-link {{ request()->routeIs('petugas.dashboard') ? 'active' : '' }}">
            <i class="bi bi-house-door-fill"></i> Beranda
        </a>

        <p class="menu-title">Presensi</p>

        {{-- ✅ FIX: route scan sesuai role --}}
        <a href="{{ auth()->user()->role === 'guru' ? route('guru.scan') : route('petugas.scan') }}"
           class="nav-link {{ request()->routeIs('guru.scan', 'petugas.scan') ? 'active' : '' }}">
            <i class="bi bi-qr-code-scan"></i> Scan Presensi
        </a>

        {{-- ✅ FIX: route laporan harian sesuai role --}}
        <a href="{{ route('petugas.laporan.harian') }}"
           class="nav-link {{ request()->routeIs('petugas.laporan.harian') ? 'active' : '' }}">
            <i class="bi bi-calendar2-check-fill"></i> Laporan Harian
        </a>

        <p class="menu-title">Konfigurasi</p>
        <a href="{{ route('petugas.user.password') }}"
           class="nav-link {{ request()->routeIs('petugas.user.password') ? 'active' : '' }}">
            <i class="bi bi-person-gear"></i> Pengaturan Akun
        </a>

    </div>

    {{-- TOMBOL LOGOUT --}}
    <div class="p-3 border-top">
        <form action="{{ route('logout') }}" method="POST">
            @csrf
            <button type="submit" class="btn btn-outline-danger btn-logout w-100">
                <i class="bi bi-box-arrow-right me-1"></i> Keluar Sistem
            </button>
        </form>
    </div>

</div>
@endsection

@section('content')
    @yield('petugas-content')
@endsection