@extends('layouts.app')

@section('title', 'Add Manager')

@section('content')
<div class="container-fluid px-4 py-6">
    <div class="max-w-3xl mx-auto">
        <div class="d-flex align-items-center mb-4">
            <a href="{{ route('operations-manager.index') }}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> Back to list
            </a>
        </div>

        <div class="card shadow-sm">
            <div class="card-header bg-white">
                <h4 class="mb-0">Create Manager Account</h4>
            </div>
            <div class="card-body">
                @if ($errors->any())
                    <div class="alert alert-danger">
                        <ul class="mb-0">
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                @endif

                <form action="{{ route('operations-manager.store') }}" method="POST">
                    @csrf
                    <div class="mb-4">
                        <label class="form-label fw-semibold" for="name">Full Name <span class="text-danger">*</span></label>
                        <input type="text" name="name" id="name" class="form-control" value="{{ old('name') }}" required>
                    </div>
                    <div class="mb-4">
                        <label class="form-label fw-semibold" for="email">Email <span class="text-danger">*</span></label>
                        <input type="email" name="email" id="email" class="form-control" value="{{ old('email') }}" required>
                    </div>
                    <div class="mb-4">
                        <label class="form-label fw-semibold" for="role">Role <span class="text-danger">*</span></label>
                        <select name="role" id="role" class="form-select" required>
                            <option value="DRM Manager" {{ old('role') == 'DRM Manager' ? 'selected' : '' }}>DRM Manager</option>
                            <option value="Youth and Volunteer Coordinator" {{ old('role') == 'Youth and Volunteer Coordinator' ? 'selected' : '' }}>Youth and Volunteer Coordinator</option>
                            <option value="Operations Manager" {{ old('role') == 'Operations Manager' ? 'selected' : '' }}>Operations Manager</option>
                        </select>
                    </div>
                    <div class="row">
                        <div class="col-md-6 mb-4">
                            <label class="form-label fw-semibold" for="password">Password <span class="text-danger">*</span></label>
                            <input type="password" name="password" id="password" class="form-control" required>
                            <small class="text-muted">Minimum 8 characters.</small>
                        </div>
                        <div class="col-md-6 mb-4">
                            <label class="form-label fw-semibold" for="password_confirmation">Confirm Password <span class="text-danger">*</span></label>
                            <input type="password" name="password_confirmation" id="password_confirmation" class="form-control" required>
                        </div>
                    </div>
                    {{-- <div class="form-check form-switch mb-4">
                        <input class="form-check-input" type="checkbox" role="switch" id="is_active" name="is_active" {{ old('is_active', true) ? 'checked' : '' }}>
                        <label class="form-check-label" for="is_active">Account is active</label>
                    </div> --}}
                    <input type="hidden" name="is_active" value="1">
                    <div class="mb-4">
                        <label class="form-label fw-semibold">Account is active</label>
                        <input type="text" class="form-control" value="Active" disabled>
                    </div>

                    <div class="d-flex gap-2">
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save me-1"></i> Create Account
                        </button>
                        <a href="{{ route('operations-manager.index') }}" class="btn btn-outline-secondary">Cancel</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection

