@extends('layouts.admin')
@section('title', 'Create License')

@section('content')

<div style="display:flex;align-items:center;gap:0.75rem;margin-bottom:1.5rem">

</div>

<div style="max-width:600px">
    <div class="card" style="padding:1.75rem">
        <div style="margin-bottom:1.5rem">
            <h2 style="font-size:1.1rem;font-weight:800;color:var(--foreground)">Create Manual License</h2>
            <p style="font-size:0.8rem;color:var(--muted-foreground);margin-top:0.25rem">Issue a license directly without an order.</p>
        </div>

        <form method="POST" action="{{ route('admin.licenses.store') }}" style="display:flex;flex-direction:column;gap:1rem">
            @csrf

            <div>
                <label>Customer</label>
                <select name="user_id" required class="select">
                    <option value="">Select customer...</option>
                    @foreach($customers as $customer)
                    <option value="{{ $customer->id }}" @selected(old('user_id')==$customer->id)>
                        {{ $customer->name }} ({{ $customer->email }})
                    </option>
                    @endforeach
                </select>
            </div>

            <div>
                <label>Product</label>
                <select name="product_id" required class="select">
                    <option value="">Select product...</option>
                    @foreach($products as $product)
                    <option value="{{ $product->id }}" @selected(old('product_id')==$product->id)>{{ $product->name }}</option>
                    @endforeach
                </select>
            </div>

            <div style="display:grid;grid-template-columns:1fr 1fr;gap:1rem">
                <div>
                    <label>License Type</label>
                    <select name="type" required class="select">
                        <option value="single"    @selected(old('type')==='single')>Regular — Single domain</option>
                        <option value="unlimited" @selected(old('type')==='unlimited')>Extended — Unlimited activations</option>
                    </select>
                </div>
                <div>
                    <label>Max Activations</label>
                    <input type="number" name="max_activations" value="{{ old('max_activations',1) }}" min="1" required class="input">
                </div>
            </div>

            <div>
                <label>Expires At <span style="color:var(--muted-foreground);font-weight:400">(leave blank for lifetime)</span></label>
                <input type="date" name="expires_at" value="{{ old('expires_at') }}" class="input">
            </div>

            <div>
                <label>Notes</label>
                <textarea name="notes" rows="3" class="input" style="resize:none">{{ old('notes') }}</textarea>
            </div>

            <button type="submit" class="btn btn-primary" style="justify-content:center;padding:0.75rem">
                Generate License
            </button>
        </form>
    </div>
</div>

@endsection
