<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dashboard - PrestamosTec</title>
    <!-- Tailwind CSS desde CDN -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- Alpine.js -->
    <script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <!-- En el head, después de los otros scripts -->
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
</head>
<body class="bg-gray-100">
    <div class="min-h-screen flex">
        <!-- Sidebar -->
        <aside class="bg-[#1E40AF] text-white w-64 min-h-screen px-4 py-6 hidden md:block">
            <div class="flex items-center justify-center mb-8">
                <span class="text-2xl font-bold">PrestamosTecmm</span>
            </div>
            <nav>
                <ul class="space-y-2">
                    <!-- Inicio -->
                    <li>
                        <a href="/dashboard" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                            <i class="fas fa-home"></i>
                            <span>Inicio</span>
                        </a>
                    </li>

                    <!-- Préstamos -->
                    <li>
                        <a href="/prestamos" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                            <i class="fas fa-book"></i>
                            <span>Préstamos</span>
                        </a>
                    </li>

                    <!-- Usuarios -->
                    <li>
                        <a href="/usuarios" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                            <i class="fas fa-users"></i>
                            <span>Usuarios</span>
                        </a>
                    </li>

                    <!-- Configuración con Submenú -->
                    <li x-data="{ open: false }" class="relative">
                        <button @click="open = !open"
                                class="flex items-center justify-between w-full px-4 py-2 rounded hover:bg-blue-700">
                            <div class="flex items-center space-x-2">
                                <i class="fas fa-cog"></i>
                                <span>Configuración</span>
                            </div>
                            <i class="fas fa-chevron-down text-sm transition-transform duration-200"
                               :class="{ 'transform rotate-180': open }"></i>
                        </button>

                        <!-- Submenú de Configuración -->
                        <ul x-show="open"
                            x-transition:enter="transition ease-out duration-200"
                            x-transition:enter-start="opacity-0 transform -translate-y-2"
                            x-transition:enter-end="opacity-100 transform translate-y-0"
                            x-transition:leave="transition ease-in duration-150"
                            x-transition:leave-start="opacity-100 transform translate-y-0"
                            x-transition:leave-end="opacity-0 transform -translate-y-2"
                            class="pl-4 mt-2 space-y-1 text-sm">

                            <!-- Marca -->
                            <li>
                                <a href="{{ route('marca.index') }}" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                                    <i class="fas fa-trademark"></i>
                                    <span>Marca</span>
                                </a>
                            </li>

                            <!-- Tipos -->
                            <li>
                                <a href="/configuracion/tipos" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                                    <i class="fas fa-tags"></i>
                                    <span>Tipos</span>
                                </a>
                            </li>

                            <!-- Tipos de Licencia -->
                            <li>
                                <a href="/configuracion/licencias" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                                    <i class="fas fa-id-card"></i>
                                    <span>Tipos de Licencia</span>
                                </a>
                            </li>

                            <!-- Capacidad -->
                            <li>
                                <a href="/configuracion/capacidad" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                                    <i class="fas fa-users"></i>
                                    <span>Capacidad</span>
                                </a>
                            </li>

                            <!-- Puestos -->
                            <li x-data="{ openPuestos: false }" class="relative">
                                <button @click="openPuestos = !openPuestos"
                                        class="flex items-center justify-between w-full px-4 py-2 rounded hover:bg-blue-700">
                                    <div class="flex items-center space-x-2">
                                        <i class="fas fa-user-tie"></i>
                                        <span>Puestos</span>
                                    </div>
                                    <i class="fas fa-chevron-right text-xs"
                                       :class="{ 'transform rotate-90': openPuestos }"></i>
                                </button>

                                <!-- Submenú de Puestos -->
                                <ul x-show="openPuestos"
                                    class="pl-4 mt-1 space-y-1">
                                    <li>
                                        <a href="/configuracion/puestos/docentes" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                                            <i class="fas fa-chalkboard-teacher"></i>
                                            <span>Docentes</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a href="/configuracion/puestos/choferes" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                                            <i class="fas fa-car"></i>
                                            <span>Choferes</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a href="/configuracion/puestos/admin" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                                            <i class="fas fa-user-shield"></i>
                                            <span>Administradores</span>
                                        </a>
                                    </li>
                                </ul>
                            </li>

                            <!-- Estatus -->
                            <li>
                                <a href="/configuracion/estatus" class="flex items-center space-x-2 px-4 py-2 rounded hover:bg-blue-700">
                                    <i class="fas fa-toggle-on"></i>
                                    <span>Estatus</span>
                                </a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </nav>
        </aside>

        <div class="flex-1 flex flex-col">
            <!-- Navbar -->
            <header class="bg-white shadow">
                <div class="flex items-center justify-between px-6 py-4">
                    <button class="md:hidden text-gray-500 hover:text-gray-700">
                        <i class="fas fa-bars text-xl"></i>
                    </button>
                    <div class="flex items-center space-x-4">
                        <div class="relative" x-data="{ open: false }">
                            <button @click="open = !open" class="flex items-center space-x-2 text-gray-700 hover:text-gray-900">
                                <img src="https://ui-avatars.com/api/?name={{ Auth::user()->name }}" alt="Profile" class="w-8 h-8 rounded-full">
                                <span>{{ Auth::user()->name }}</span>
                                <i class="fas fa-chevron-down"></i>
                            </button>
                            <!-- Menú desplegable -->
                            <div x-show="open"
                                 @click.away="open = false"
                                 class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1">
                                <form method="POST" action="{{ route('logout') }}">
                                    @csrf
                                    <button type="submit" class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
                                        <i class="fas fa-sign-out-alt mr-2"></i> Cerrar Sesión
                                    </button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </header>

            <!-- Main Content -->
            <main class="flex-1 p-6">
                @yield('content')
            </main>

            <!-- Footer -->
            <footer class="bg-white shadow mt-auto">
                <div class="max-w-7xl mx-auto py-4 px-6">
                    <div class="flex justify-between items-center">
                        <p class="text-gray-600">&copy; 2024 PrestamosTecmm. Todos los derechos reservados.</p>
                        <div class="flex space-x-4">
                            <a href="#" class="text-gray-600 hover:text-gray-900">
                                <i class="fab fa-facebook"></i>
                            </a>
                            <a href="#" class="text-gray-600 hover:text-gray-900">
                                <i class="fab fa-twitter"></i>
                            </a>
                            <a href="#" class="text-gray-600 hover:text-gray-900">
                                <i class="fab fa-instagram"></i>
                            </a>
                        </div>
                    </div>
                </div>
            </footer>
        </div>
    </div>
</body>
</html>