@extends('layout.admin')

@section('content')
<div class="container">
    <h2 class="mb-4">✏️ অফার এডিট করুন</h2>

    <form method="POST" action="{{ route('admin.offers.update', $offer->id) }}" enctype="multipart/form-data" class="card shadow p-4">
        @csrf

        <div class="row">
            <div class="col-md-6 mb-3">
                <label class="form-label">অফার টাইটেল</label>
                <input type="text" name="title" class="form-control" value="{{ $offer->title }}" required>
            </div>
            <div class="col-md-6 mb-3">
                <label class="form-label">মেয়াদ</label>
                <input type="text" name="validity" class="form-control" value="{{ $offer->validity }}" required>
            </div>
        </div>

        <div class="mb-3">
            <label class="form-label">বিস্তারিত</label>
            <textarea name="description" class="form-control" rows="3" required>{{ $offer->description }}</textarea>
        </div>

        <div class="row">
            <div class="col-md-4 mb-3">
                <label class="form-label">মূল্য (৳)</label>
                <input type="number" name="price" class="form-control" value="{{ $offer->price }}" required>
            </div>
            <div class="col-md-4 mb-3">
                <label class="form-label">ক্যাশব্যাক (৳)</label>
                <input type="number" name="cashback" class="form-control" value="{{ $offer->cashback }}" required>
            </div>
            <div class="col-md-4 mb-3">
                <label class="form-label">লোগো পরিবর্তন করুন</label>
                <input type="file" name="logo" class="form-control">
                <small class="text-muted">বর্তমান: {{ $offer->logo }}</small>
            </div>
        </div>

        <div class="row">
            <div class="col-md-6 mb-3">
                <label class="form-label">অপারেটর</label>
                <select name="operator_id" class="form-select" required>
                    @foreach($operators as $op)
                        <option value="{{ $op->id }}" {{ $offer->operator_id == $op->id ? 'selected' : '' }}>{{ $op->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="col-md-6 mb-3">
                <label class="form-label">ক্যাটাগরি</label>
                <select name="category_id" class="form-select" required>
                    @foreach($categories as $cat)
                        <option value="{{ $cat->id }}" {{ $offer->category_id == $cat->id ? 'selected' : '' }}>{{ $cat->name }}</option>
                    @endforeach
                </select>
            </div>
        </div>

        <button type="submit" class="btn btn-primary">💾 আপডেট করুন</button>
    </form>
</div>
@endsection