<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@yield('title', 'LabConnect')</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <style>
        body { background-color: #f4f6f9; }
        .navbar-brand { font-weight: 700; letter-spacing: .5px; }
        .badge-urgent { background-color: #dc3545; }
        .badge-ecart { background-color: #fd7e14; }
        .table-actions form { display: inline-block; }
        .card { border: none; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
    </style>
</head>
<body>
@auth
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
    <div class="container-fluid">
        <a class="navbar-brand" href="{{ route('dashboard') }}">LabConnect</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navMenu">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navMenu">
            <ul class="navbar-nav me-auto">
                @if(auth()->user()->isAdmin())
                    <li class="nav-item"><a class="nav-link" href="{{ route('admin.dashboard') }}">Tableau de bord</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('admin.requests.index') }}">Demandes</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('admin.partners.index') }}">Partenaires</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('admin.users.index') }}">Comptes</a></li>
                @elseif(auth()->user()->isPartner())
                    <li class="nav-item"><a class="nav-link" href="{{ route('partner.dashboard') }}">Tableau de bord</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('partner.requests.index', 'prelevement') }}">Prelevement</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('partner.requests.index', 'consommable') }}">Consommables</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('partner.requests.index', 'reclamation') }}">Reclamations</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('partner.requests.index', 'resultat') }}">Resultats</a></li>
                @elseif(auth()->user()->isCourier())
                    <li class="nav-item"><a class="nav-link" href="{{ route('courier.dashboard') }}">Tableau de bord</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('courier.requests.index') }}">Mes demandes</a></li>
                @endif
            </ul>
            <span class="navbar-text text-light me-3">{{ auth()->user()->name }} ({{ auth()->user()->role }})</span>
            <form action="{{ route('logout') }}" method="POST">
                @csrf
                <button class="btn btn-outline-light btn-sm">Deconnexion</button>
            </form>
        </div>
    </div>
</nav>
@endauth

<div class="container pb-5">
    @if(session('success'))
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            {{ session('success') }}
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    @endif
    @if(session('warning'))
        <div class="alert alert-warning alert-dismissible fade show" role="alert">
            {{ session('warning') }}
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    @endif
    @if($errors->any())
        <div class="alert alert-danger">
            <ul class="mb-0">
                @foreach($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    @yield('content')
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
