{{-- client/create_ticket.blade.php --}}
@extends('layouts.client')
@section('title','Buat Tiket')
@section('content')
<div class="row justify-content-center"><div class="col-lg-7">
<div class="card">
  <div class="card-header fw-bold">Buat Tiket Baru</div>
  <div class="card-body">
    <form action="{{ route('client.tickets.store') }}" method="POST">@csrf
    <div class="row g-3">
      <div class="col-12"><label class="form-label fw-semibold">Subjek *</label><input type="text" name="subject" class="form-control" required placeholder="Ringkasan masalah..." value="{{ old('subject') }}"></div>
      <div class="col-12"><label class="form-label fw-semibold">Deskripsi *</label><textarea name="description" class="form-control" rows="5" required placeholder="Jelaskan masalah secara detail...">{{ old('description') }}</textarea></div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Prioritas *</label>
        <select name="priority" class="form-select" required>
          @foreach(['critical'=>'🔴 Critical','high'=>'🟠 High','medium'=>'🟡 Medium','low'=>'🟢 Low'] as $v=>$l)<option value="{{ $v }}" {{ old('priority','medium')===$v?'selected':'' }}>{{ $l }}</option>@endforeach
        </select>
      </div>
      <div class="col-md-6">
        <label class="form-label fw-semibold">Kategori *</label>
        <select name="category" class="form-select" required>
          @foreach(['network'=>'Network','hardware'=>'Hardware','software'=>'Software','cctv'=>'CCTV','other'=>'Lainnya'] as $v=>$l)<option value="{{ $v }}" {{ old('category')===$v?'selected':'' }}>{{ $l }}</option>@endforeach
        </select>
      </div>
      @if($devices->count())
      <div class="col-12">
        <label class="form-label fw-semibold">Perangkat Terkait</label>
        <select name="device_id" class="form-select">
          <option value="">-- Tidak ada --</option>
          @foreach($devices as $d)<option value="{{ $d->id }}">{{ $d->brand }} {{ $d->model }} ({{ $d->type }})</option>@endforeach
        </select>
      </div>
      @endif
      <div class="col-12 d-flex gap-2 justify-content-end">
        <a href="{{ route('client.dashboard') }}" class="btn btn-secondary">Batal</a>
        <button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i>Kirim Tiket</button>
      </div>
    </div>
    </form>
  </div>
</div>
</div></div>
@endsection
