{{-- Errors --}}
@if ($errors->any())
  <div class="rounded-xl border border-rose-200 bg-rose-50/70 px-3 py-2 text-sm text-rose-800">
    <i class="fa-solid fa-triangle-exclamation"></i>
    {{ $errors->first() }}
  </div>
@endif

<div class="grid grid-cols-1 gap-4">
  {{-- Range --}}
  <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
    <div>
      <label class="mb-1 block text-sm font-semibold">Min Amount (BDT)</label>
      <input name="min_amount" type="number" min="0" step="1" value="{{ old('min_amount', $rule->min_amount) }}" required
             class="w-full rounded-xl border border-slate-200 bg-white px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-rose-500/60">
    </div>
    <div>
      <label class="mb-1 block text-sm font-semibold">Max Amount (BDT)</label>
      <input name="max_amount" type="number" min="0" step="1" value="{{ old('max_amount', $rule->max_amount) }}"
             placeholder="∞ for empty"
             class="w-full rounded-xl border border-slate-200 bg-white px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-rose-500/60">
      <div class="mt-1 text-xs text-slate-500">ফাঁকা রাখলে Infinity ধরা হবে।</div>
    </div>
  </div>

  {{-- Type + Value --}}
  <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
    <div>
      <label class="mb-1 block text-sm font-semibold">Calculation Type</label>
      <div class="flex items-center gap-2">
        <label class="inline-flex items-center gap-2 rounded-full border border-slate-200 px-3 py-2 text-sm">
          <input type="radio" name="calc_type" value="flat" {{ old('calc_type', $rule->calc_type)==='flat' ? 'checked' : '' }}> Flat (৳)
        </label>
        <label class="inline-flex items-center gap-2 rounded-full border border-slate-200 px-3 py-2 text-sm">
          <input type="radio" name="calc_type" value="percent" {{ old('calc_type', $rule->calc_type)==='percent' ? 'checked' : '' }}> Percent (%)
        </label>
      </div>
    </div>
    <div>
      <label class="mb-1 block text-sm font-semibold">Value</label>
      <input name="value" type="number" step="0.01" min="0.01"
             value="{{ old('value', $rule->value) }}" required
             class="w-full rounded-xl border border-slate-200 bg-white px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-rose-500/60">
      <div class="mt-1 text-xs text-slate-500">
        Flat হলে টাকা (BDT), Percent হলে % (০.০১–১০০)।
      </div>
    </div>
  </div>

  {{-- Active --}}
  <div class="flex items-center gap-2">
    <input type="hidden" name="is_active" value="0">
    <input id="is_active" type="checkbox" name="is_active" value="1" {{ old('is_active', $rule->is_active) ? 'checked' : '' }}
           class="h-4 w-4 rounded border-slate-300 text-rose-600 focus:ring-rose-500">
    <label for="is_active" class="text-sm font-semibold">Active</label>
  </div>
</div>
