@extends('layouts.admin')

@section('title', 'New Investment')

@section('content')
<div class="fundi-page-header">
    <div>
        <h1>New Investment</h1>
        <p class="fundi-page-header__desc">Create a customer investment placement.</p>
    </div>
    <a href="{{ route('admin.investments.index') }}" class="fundi-btn fundi-btn--secondary">Back</a>
</div>

<div class="fundi-card">
    <div class="fundi-card__body fundi-card__body--padded">
        <form method="POST" action="{{ route('admin.investments.store') }}">
            @csrf
            <div class="fundi-form-grid">
                <div class="fundi-form-group">
                    <label for="customer_id">Customer *</label>
                    <select id="customer_id" name="customer_id" class="fundi-select" required>
                        <option value="">— Select —</option>
                        @foreach($customers as $c)
                            <option value="{{ $c->id }}" @selected(old('customer_id') == $c->id)>{{ $c->customer_no }} — {{ $c->display_name }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="fundi-form-group">
                    <label for="product_id">Product *</label>
                    <select id="product_id" name="product_id" class="fundi-select" required>
                        <option value="">— Select —</option>
                        @foreach($products as $p)
                            <option value="{{ $p->id }}" @selected(old('product_id') == $p->id)>{{ $p->name }} ({{ $p->interest_rate }}%)</option>
                        @endforeach
                    </select>
                </div>
                <div class="fundi-form-group">
                    <label for="account_id">Settlement Account</label>
                    <select id="account_id" name="account_id" class="fundi-select">
                        <option value="">— Select —</option>
                        @foreach($accounts as $a)
                            <option value="{{ $a->id }}" @selected(old('account_id') == $a->id)>{{ $a->account_no }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="fundi-form-group">
                    <label for="principal">Principal (₦) *</label>
                    <input type="number" step="0.01" min="1" id="principal" name="principal" class="fundi-input" value="{{ old('principal') }}" required>
                </div>
                <div class="fundi-form-group">
                    <label for="tenor_days">Tenor (days) *</label>
                    <input type="number" min="1" id="tenor_days" name="tenor_days" class="fundi-input" value="{{ old('tenor_days') }}" required>
                </div>
                <div class="fundi-form-group">
                    <label for="interest_rate">Interest Rate (%)</label>
                    <input type="number" step="0.01" min="0" id="interest_rate" name="interest_rate" class="fundi-input" value="{{ old('interest_rate') }}">
                </div>
                <div class="fundi-form-group">
                    <label for="start_date">Start Date</label>
                    <input type="date" id="start_date" name="start_date" class="fundi-input" value="{{ old('start_date', date('Y-m-d')) }}">
                </div>
            </div>
            <div class="fundi-form-actions">
                <button type="submit" class="fundi-btn fundi-btn--primary">Create Investment</button>
                <a href="{{ route('admin.investments.index') }}" class="fundi-btn fundi-btn--secondary">Cancel</a>
            </div>
        </form>
    </div>
</div>
@endsection
