@extends('layouts.app')

@section('title', 'Purchase Invoice')

@section('content')
<style>
    .form-container {
        background-color: #fff;
        padding: 30px;
        border-radius: 10px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        max-width: 800px;
        margin: 30px auto;
        font-family: Arial, sans-serif;
        border-style: groove;
    }

    .form-container h2 {
        text-align: center;
        margin-bottom: 25px;
    }

    .form-group {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 15px;
    }

    .form-group label {
        flex: 0 0 40%;
        font-weight: bold;
        margin-bottom: 5px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        flex: 0 0 60%;
        padding: 10px;
        font-size: 14px;
        border-radius: 5px;
        border: 2px solid gray;
    }

    button[type="submit"] {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        background-color: #28a745;
        color: white;
        border: none;
        border-radius: 8px;
        cursor: pointer;
    }
</style>

<div class="form-container">
    <h2>Purchase Invoice Form</h2>
    <form action="{{ $action }}" method="POST" enctype="multipart/form-data">
        @csrf
        @if($method !== 'POST')
            @method($method)
        @endif

        <div class="form-group">
            <label for="make">Make:</label>
            <input type="text" id="make" name="make" value="{{ old('make', $invoice->make ?? '') }}" required>
        </div>

        <div class="form-group">
            <label for="model">Model:</label>
            <input type="text" id="model" name="model" value="{{ old('model', $invoice->model ?? '') }}" required>
        </div>

        <div class="form-group">
            <label for="varient">Varient:</label>
            <input type="text" id="varient" name="varient" value="{{ old('varient', $invoice->varient ?? '') }}" required>
        </div>

        <div class="form-group">
            <label for="registration_no">Registration No:</label>
            <input type="text" id="registration_no" name="registration_no" value="{{ old('registration_no', $invoice->registration_no ?? '') }}" required>
        </div>

        <div class="form-group">
            <label for="purchase_date">Purchase Date:</label>
            <input type="date" id="purchase_date" name="purchase_date" value="{{ old('purchase_date', $invoice->purchase_date ?? '') }}" required>
        </div>

        <div class="form-group">
            <label for="vendor_name">Seller Name:</label>
            <input type="text" id="vendor_name" name="vendor_name" value="{{ old('vendor_name', $invoice->vendor_name ?? '') }}" required>
        </div>

        <div class="form-group">
            <label for="seller_cnic">Seller Cnic:</label>
            <input type="text" id="seller_cnic" name="seller_cnic" value="{{ old('seller_cnic', $invoice->seller_cnic ?? '') }}" required>
        </div>

        <div class="form-group">
            <label for="phone_no">Phone No:</label>
            <input type="text" id="seller_phone" name="seller_phone" value="{{ old('seller_phone', $invoice->seller_phone ?? '') }}">
        </div>

        <div class="form-group">
            <label for="seller_address">Seller Address</label>

            <textarea row="2" class="form-control" type="text" id="seller_address" name="seller_address" value="{{ old('seller_address', $invoice->seller_address ?? '') }}" required></textarea>
        </div>



        <!-- <div class="form-group">
            <label for="buyer_name">Buyer Name:</label>
            <input type="text" id="buyer_name" name="buyer_name" value="{{ old('buyer_name', $invoice->buyer_name ?? '') }}">
        </div>

        <div class="form-group">
            <label for="buyer_cnic">Buyer Cnic:</label>
            <input type="text" id="buyer_cnic" name="buyer_cnic" value="{{ old('buyer_cnic', $invoice->buyer_cnic ?? '') }}">
        </div>

        <div class="form-group">
            <label for="buyer_phone">Phone No:</label>
            <input type="text" id="buyer_phone" name="buyer_phone" value="{{ old('buyer_phone', $invoice->buyer_phone ?? '') }}">
        </div>

        <div class="form-group">
            <label for="buyer_address">Buyer Address</label>
            <textarea row="2" class="form-control" type="text" id="buyer_address" name="buyer_address" value="{{ old('buyer_address', $invoice->buyer_address ?? '') }}"></textarea>
        </div> -->

        <div class="form-group">
            <label for="purchase_price">Purchase Price:</label>
            <input type="number" step="0.01" id="purchase_price" name="purchase_price" value="{{ old('purchase_price', $invoice->purchase_price ?? '') }}" required>
        </div>

        <div class="form-group">
            <label for="invoice_file">Upload Invoice File:</label>
            <input type="file" id="invoice_file_path" name="invoice_file_path" accept="application/pdf,image/*">
        </div>

        <button type="submit">
            {{ $method === 'POST' ? 'Submit Invoice' : 'Update Invoice' }}
        </button>
    </form>
</div>
@endsection
