@extends('layouts.app')

@section('title','Edit Tiket')

@section('content')

<div class="container" style="max-width:960px;">
    <div class="card-dark p-4">
        <div class="d-flex flex-column flex-md-row align-items-start align-items-md-center justify-content-between gap-3 mb-3">
            <div>
                <h3 class="mb-1">Edit Tiket</h3>
                <p class="text-muted-sm">Perbarui informasi tiket.</p>
            </div>
            <a href="{{ route('tiket.index') }}" class="btn btn-outline-soft">Kembali ke daftar</a>
        </div>

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

        <form action="{{ route('tiket.update', $tiket->id) }}" method="POST">
            @csrf
            @method('PUT')

            <div class="row g-4">
                <div class="col-md-6">
                    <label class="form-label">Event</label>
                    <select name="event_id" class="form-control-dark form-control" required>
                        @foreach($events as $event)
                            <option value="{{ $event->id }}" {{ old('event_id', $tiket->event_id) == $event->id ? 'selected' : '' }}>{{ $event->nama_event }}</option>
                        @endforeach
                    </select>
                </div>

                <div class="col-md-6">
                    <label class="form-label">Jenis Tiket</label>
                    <input type="text" name="jenis" class="form-control-dark form-control" value="{{ old('jenis', $tiket->jenis) }}" placeholder="Contoh: VIP" required>
                </div>

                <div class="col-md-6">
                    <label class="form-label">Harga (Rp)</label>
                    <input type="number" name="harga" class="form-control-dark form-control" value="{{ old('harga', $tiket->harga) }}" required>
                </div>

                <div class="col-md-6">
                    <label class="form-label">Stok</label>
                    <input type="number" name="stok" class="form-control-dark form-control" value="{{ old('stok', $tiket->stok) }}" required>
                </div>
            </div>

            <div class="mt-4 d-flex flex-wrap gap-2">
                <button class="btn-primary-glow">Perbarui Tiket</button>
                <a href="{{ route('tiket.index') }}" class="btn btn-outline-soft">Batal</a>
            </div>
        </form>
    </div>
</div>

@endsection