<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Control de Flota</title>

    @livewireStyles
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    {{-- Bootstrap Icons --}}
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
</head>
<body>

<div class="d-flex">
    <!-- Menú lateral -->
    <div class="text-white p-3" style="min-width: 220px; min-height: 100vh; background-color: #1c1f26;">
        <div class="text-center mb-4">
            <img src="{{ asset('images/logo.png') }}" alt="Logo" style="width: 120px; height: auto;">
        </div>
        <h5 class="text-white">Menú</h5>
        <ul class="nav flex-column">
            <li class="nav-item">
                <a href="{{ route('dashboard') }}"
                   class="nav-link {{ request()->routeIs('dashboard') ? 'fw-bold' : 'text-white' }}"
                   style="{{ request()->routeIs('dashboard') ? 'background-color: #95a5a6 ; color: white;' : '' }}">
                    <i class="bi bi-bar-chart-line-fill me-2"></i>Dashboard
                </a>
            </li>
            <li class="nav-item">
                <a href="{{ route('equipos') }}"
                   class="nav-link {{ request()->routeIs('equipos') ? 'fw-bold' : 'text-white' }}"
                   style="{{ request()->routeIs('equipos') ? 'background-color: #2563eb; color: white;' : '' }}">
                    <i class="bi bi-truck me-2"></i>Equipos
                </a>
            </li>
            <li class="nav-item">
                <a href="{{ route('control.diario.live') }}"
                   class="nav-link {{ request()->routeIs('control.diario.live') ? 'fw-bold' : 'text-white' }}"
                   style="{{ request()->routeIs('control.diario.live') ? 'background-color: #2563eb; color: white;' : '' }}">
                    <i class="bi bi-list-check me-2"></i>Control Diario
                </a>
            </li>
            <li class="nav-item">
                <a href="{{ route('talleres') }}"
                   class="nav-link {{ request()->routeIs('talleres') ? 'fw-bold' : 'text-white' }}"
                   style="{{ request()->routeIs('talleres') ? 'background-color: #2563eb; color: white;' : '' }}">
                    <i class="bi bi-tools me-2"></i>Talleres
                </a>
            </li>
            @role('admin')
                <li class="nav-item">
                    <a href="{{ route('usuarios') }}"
                       class="nav-link {{ request()->routeIs('usuarios') ? 'fw-bold' : 'text-white' }}"
                       style="{{ request()->routeIs('usuarios') ? 'background-color: #2563eb; color: white;' : '' }}">
                        <i class="bi bi-person-badge-fill me-2"></i>Usuarios
                    </a>
                </li>
            @endrole
        </ul>
    </div>

    <!-- Contenido principal -->
    <div class="flex-grow-1 p-4" style="background-color: #f9fafb;">
        <!-- Navbar superior -->
        <nav class="navbar navbar-expand-lg" style="background-color: #1c1f26; border-radius: .375rem;">
            <div class="container-fluid text-white">
                <a class="navbar-brand text-white" href="#">Control de Flota</a>
                <div class="ms-auto d-flex align-items-center gap-3">
                    <div class="text-end text-white">
                        <strong>{{ Auth::user()->name }}</strong><br>
                        <small>{{ ucfirst(Auth::user()->getRoleNames()->first() ?? 'Sin rol') }}</small>
                    </div>
                    <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-inline">
                        @csrf
                        <button type="submit" class="btn btn-sm btn-outline-light">Cerrar Sesión</button>
                    </form>
                </div>
            </div>
        </nav>

        {{-- Contenido dinámico --}}
        <div class="mt-4">
            @yield('content')
        </div>
    </div>
</div>

@livewireScripts
<script src="{{ asset('js/app.js') }}" defer></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

</body>
</html>
