@extends('layouts.admin')

@section('title', 'ویرایش پکیج')

@section('content')
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    ویرایش پکیج: {{ $package->name_fa }}
                </h2>
            </div>
            <div class="body">
                <form action="{{ route('admin.packages.update', $package->id) }}" method="POST">
                    @csrf
                    @method('PUT')
                    <div class="row clearfix">
                        <div class="col-sm-6">
                            <div class="form-group">
                                <div class="form-line">
                                    <label for="name_fa">عنوان پکیج *</label>
                                    <input type="text" id="name_fa" name="name_fa" class="form-control" value="{{ old('name_fa', $package->name_fa) }}" required>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="form-group">
                                <div class="form-line">
                                    <label for="duration_days">مدت زمان (روز) *</label>
                                    <input type="number" id="duration_days" name="duration_days" class="form-control" value="{{ old('duration_days', $package->duration_days) }}" required min="1">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row clearfix">
                        <div class="col-sm-6">
                            <div class="form-group">
                                <div class="form-line">
                                    <label for="price">قیمت (تومان) *</label>
                                    <input type="number" id="price" name="price" class="form-control" value="{{ old('price', $package->price) }}" required min="0">
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="form-group">
                                <div class="form-line">
                                    <label for="discount_price">قیمت با تخفیف (اختیاری)</label>
                                    <input type="number" id="discount_price" name="discount_price" class="form-control" value="{{ old('discount_price', $package->discount_price) }}">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row clearfix">
                        <div class="col-sm-12">
                            <div class="form-group">
                                <div class="form-line">
                                    <label for="features">ویژگی‌ها (هر ویژگی در یک خط)</label>
                                    <textarea id="features" name="features" rows="5" class="form-control">{{ old('features', is_array($package->features) ? implode("\n", $package->features) : $package->features) }}</textarea>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row clearfix">
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label for="status">وضعیت *</label>
                                <select class="form-control show-tick" id="status" name="status" required>
                                    <option value="active" {{ old('status', $package->status) == 'active' ? 'selected' : '' }}>فعال</option>
                                    <option value="inactive" {{ old('status', $package->status) == 'inactive' ? 'selected' : '' }}>غیرفعال</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <button type="submit" class="btn btn-primary m-t-15 waves-effect">ذخیره تغییرات</button>
                    <a href="{{ route('admin.packages.index') }}" class="btn btn-default m-t-15 waves-effect">بازگشت</a>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
