@extends('layouts.dashboard')

@section('content')
<div class="container mx-auto px-4 py-6">
    <div class="bg-white rounded-lg shadow-lg">
        <div class="p-4 border-b border-gray-200 flex justify-between items-center">
            <h2 class="text-2xl font-bold">{{ isset($docente) ? 'Editar Docente' : 'Crear Docente' }}</h2>
        </div>
        <div class="p-4">
            <form action="{{ isset($docente) ? route('docentes.update', $docente->id) : route('docentes.store') }}" method="POST">
                @csrf
                @if(isset($docente))
                    @method('PUT')
                @endif
                <div class="grid grid-cols-1 gap-6">
                    <div>
                        <label for="nombre" class="block text-sm font-medium text-gray-700">Nombre</label>
                        <input type="text" name="nombre" id="nombre" value="{{ old('nombre', $docente->nombre ?? '') }}" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                    </div>
                    <div>
                        <label for="telefono" class="block text-sm font-medium text-gray-700">Teléfono</label>
                        <input type="text" name="telefono" id="telefono" value="{{ old('telefono', $docente->telefono ?? '') }}" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                    </div>
                    <div>
                        <label for="correo" class="block text-sm font-medium text-gray-700">Correo</label>
                        <input type="email" name="correo" id="correo" value="{{ old('correo', $docente->correo ?? '') }}" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                    </div>
                    <div class="mb-4">
                        <label for="tipo_licencia" class="block text-sm font-medium text-gray-700 mb-2">
                            Tipo de Licencia
                        </label>
                        <div class="relative rounded-md shadow-sm">
                            <select name="tipo_licencia"
                                    id="tipo_licencia"
                                    class="block w-full pl-3 pr-10 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                                    required>
                                <option value="">Seleccione un tipo de licencia</option>
                                <option value="A" {{ isset($docente) && $docente->tipo_licencia == 'A' ? 'selected' : '' }}>Licencia A</option>
                                <option value="B" {{ isset($docente) && $docente->tipo_licencia == 'B' ? 'selected' : '' }}>Licencia B</option>
                                <option value="C" {{ isset($docente) && $docente->tipo_licencia == 'C' ? 'selected' : '' }}>Licencia C</option>
                            </select>
                            <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                                <i class="fas fa-id-card text-gray-400"></i>
                            </div>
                        </div>
                        @error('tipo_licencia')
                            <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                        @enderror
                    </div>
                    <div>
                        <label for="materia" class="block text-sm font-medium text-gray-700">Materia</label>
                        <select name="materia" id="materia" class="mt-1 block w-full border border-gray-300 rounded-lg shadow-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                            <option value="">Seleccione una materia</option>
                            <option value="Matemáticas" {{ old('materia', $docente->materia ?? '') == 'Matemáticas' ? 'selected' : '' }}>Matemáticas</option>
                            <option value="Programación" {{ old('materia', $docente->materia ?? '') == 'Programación' ? 'selected' : '' }}>Programación</option>
                            <option value="Base de datos" {{ old('materia', $docente->materia ?? '') == 'Base de datos' ? 'selected' : '' }}>Base de datos</option>
                            <option value="Sistemas Operativos" {{ old('materia', $docente->materia ?? '') == 'Sistemas Operativos' ? 'selected' : '' }}>Sistemas Operativos</option>
                            <option value="Redes" {{ old('materia', $docente->materia ?? '') == 'Redes' ? 'selected' : '' }}>Redes</option>
                        </select>
                    </div>
                </div>
                <div class="mt-6 flex justify-end">
                    <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600">
                        {{ isset($docente) ? 'Actualizar' : 'Crear' }}
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection