@extends('super-admin.layout')

@section('title', $admin ? 'Edit admin' : 'Add admin')

@section('content')
<div class="pg-head">
    <div><h1>{{ $admin ? 'Edit admin' : 'Add admin' }}</h1></div>
    <a href="{{ route('mexco.super.admins') }}" class="btn-outline">← Back</a>
</div>

<div class="card form-panel" style="max-width:640px">
    <form method="POST" action="{{ $admin ? route('mexco.super.admins.update', $admin) : route('mexco.super.admins.store') }}" class="form-stack">
        @csrf
        @if($admin) @method('PUT') @endif

        <div class="form-row">
            <label class="form-label">Name *</label>
            <input type="text" name="name" class="form-input" value="{{ old('name', $admin?->name) }}" required>
        </div>
        <div class="form-row">
            <label class="form-label">Email *</label>
            <input type="email" name="email" class="form-input" value="{{ old('email', $admin?->email) }}" required>
        </div>
        <div class="form-row">
            <label class="form-label">Password {{ $admin ? '' : '*' }}</label>
            <input type="password" name="password" class="form-input" {{ $admin ? '' : 'required' }}>
        </div>
        <div class="form-row">
            <label class="form-label">Confirm password</label>
            <input type="password" name="password_confirmation" class="form-input">
            @if($admin)<div class="form-hint">Leave blank to keep current password.</div>@endif
        </div>
        <button type="submit" class="btn-purple">Save</button>
    </form>
</div>
@endsection
