@extends('layouts.app')

@section('title', 'Edit Operations 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">Update Operations Manager</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.update', $manager) }}" method="POST">
                    @csrf
                    @method('PUT')
                    <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', $manager->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', $manager->email) }}" required>
                    </div>
                    <div class="row">
                        <div class="col-md-6 mb-4">
                            <label class="form-label fw-semibold" for="password">New Password</label>
                            <input type="password" name="password" id="password" class="form-control">
                            <small class="text-muted">Leave blank to keep the current password.</small>
                        </div>
                        <div class="col-md-6 mb-4">
                            <label class="form-label fw-semibold" for="password_confirmation">Confirm Password</label>
                            <input type="password" name="password_confirmation" id="password_confirmation" class="form-control">
                        </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', $manager->is_active) ? 'checked' : '' }}>
                        <label class="form-check-label" for="is_active">Account is active</label>
                    </div>

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

