@extends('backend.master')
@section('content')
<div class="container-fluid py-3">

  <style>
    .card-edge{ border:1px solid #e6e8ef; border-radius:16px; background:#fff; box-shadow:0 4px 18px rgba(17,24,39,.06) }
    .section-title{ font-size:.95rem; font-weight:700; color:#334155 }
    .btn-save{ background:#5b21b6; border-color:#5b21b6 } .btn-save:hover{ background:#4c1d95; border-color:#4c1d95 }
    @media (max-width:576px){ .btn-wide{ width:100% } }
  </style>

  <div class="d-flex align-items-center gap-2 mb-3">
    <a href="{{ url('/admin/deposit-packages') }}" class="btn btn-light border"><i class="fa-solid fa-arrow-left"></i></a>
    <h5 class="mb-0"><i class="fa-regular fa-pen-to-square me-2"></i>Edit: {{ $package->title }}</h5>
  </div>

  <form action="{{ url('/admin/deposit-packages/'.$package->id) }}" method="POST" class="card-edge p-3">
    @csrf @method('PUT')

    @if ($errors->any())
      <div class="alert alert-danger"><ul class="mb-0">@foreach ($errors->all() as $e)<li>{{ $e }}</li>@endforeach</ul></div>
    @endif

    <div class="section-title mb-2"><i class="fa-regular fa-rectangle-list me-1"></i> Basics</div>
    <div class="row g-3 mb-3">
      <div class="col-md-6">
        <label class="form-label">Title *</label>
        <input name="title" class="form-control" value="{{ old('title', $package->title) }}" required>
      </div>
      <div class="col-md-6">
        <label class="form-label">Badge Text</label>
        <input name="badge_text" class="form-control" value="{{ old('badge_text', $package->badge_text) }}">
      </div>
    </div>

    <div class="section-title mb-2"><i class="fa-solid fa-tags me-1"></i> Pricing</div>
    <div class="row g-3 mb-3">
      <div class="col-md-4">
        <label class="form-label">Principal Amount *</label>
        <input type="number" step="0.01" name="principal_amount" class="form-control" value="{{ old('principal_amount',$package->principal_amount) }}" required>
      </div>
      <div class="col-md-4">
        <label class="form-label">Bonus Percent *</label>
        <input type="number" step="0.01" name="bonus_percent" class="form-control" value="{{ old('bonus_percent',$package->bonus_percent) }}" required>
      </div>
      <div class="col-md-4">
        <label class="form-label">Sort Order</label>
        <input type="number" name="sort_order" class="form-control" value="{{ old('sort_order',$package->sort_order) }}" min="0">
      </div>
      <div class="col-md-4">
        <label class="form-label">Status *</label>
        <select name="status" class="form-select" required>
          <option value="active"   @selected(old('status',$package->status)==='active')>Active</option>
          <option value="inactive" @selected(old('status',$package->status)==='inactive')>Inactive</option>
        </select>
      </div>
    </div>

    <div class="d-flex gap-2 flex-wrap">
      <button class="btn btn-save text-white btn-wide"><i class="fa-regular fa-circle-check me-1"></i> Update</button>
      <a class="btn btn-outline-secondary btn-wide" href="{{ url('/admin/deposit-packages') }}">Back</a>
    </div>
  </form>
</div>
@endsection
