@extends('layouts.admin')

@section('title', 'Görüşme Düzenle')
@section('page-title', 'Görüşme Düzenle')
@section('page-subtitle', $gorusme->title)

@section('content')
<div class="mt-4 max-w-2xl">
    <div class="mb-3">
        <a href="{{ route('admin.gorusmeler.index') }}"
           class="inline-flex items-center gap-1.5 text-sm text-gray-500 hover:text-primary transition-colors">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/></svg>
            Görüşmelere Dön
        </a>
    </div>
    <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
        <form method="POST" action="{{ route('admin.gorusmeler.update', $gorusme) }}">
            @csrf
            @method('PUT')

            <div class="space-y-5">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Görüşme Başlığı <span class="text-red-500">*</span></label>
                    <input type="text" name="title" value="{{ old('title', $gorusme->title) }}" required
                           class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-orange-400">
                </div>

                <div class="grid grid-cols-2 gap-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Tarih & Saat <span class="text-red-500">*</span></label>
                        <input type="datetime-local" name="scheduled_at"
                               value="{{ old('scheduled_at', $gorusme->scheduled_at->format('Y-m-d\TH:i')) }}" required
                               class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-orange-400">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Süre (dakika)</label>
                        <select name="duration_minutes" class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-orange-400">
                            @foreach([30, 45, 60, 90, 120] as $min)
                            <option value="{{ $min }}" {{ old('duration_minutes', $gorusme->duration_minutes) == $min ? 'selected' : '' }}>
                                {{ $min < 60 ? $min . ' dakika' : ($min / 60) . ' saat' }}
                            </option>
                            @endforeach
                        </select>
                    </div>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Durum</label>
                    <select name="status" class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-orange-400">
                        <option value="scheduled" {{ old('status', $gorusme->status) === 'scheduled' ? 'selected' : '' }}>Planlandı</option>
                        <option value="completed" {{ old('status', $gorusme->status) === 'completed' ? 'selected' : '' }}>Tamamlandı</option>
                        <option value="cancelled" {{ old('status', $gorusme->status) === 'cancelled' ? 'selected' : '' }}>İptal Edildi</option>
                        <option value="rescheduled" {{ old('status', $gorusme->status) === 'rescheduled' ? 'selected' : '' }}>Yeniden Planlandı</option>
                    </select>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Görüşmeci</label>
                    <select name="interviewer_id" class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-orange-400">
                        <option value="">Seçin</option>
                        @foreach($interviewers as $interviewer)
                        <option value="{{ $interviewer->id }}" {{ old('interviewer_id', $gorusme->interviewer_id) == $interviewer->id ? 'selected' : '' }}>
                            {{ $interviewer->name }}
                        </option>
                        @endforeach
                    </select>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Konum</label>
                    <input type="text" name="location" value="{{ old('location', $gorusme->location) }}"
                           placeholder="Ofis adresi veya oda adı"
                           class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-orange-400">
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Online Toplantı Linki</label>
                    <input type="url" name="meeting_link" value="{{ old('meeting_link', $gorusme->meeting_link) }}"
                           placeholder="https://meet.google.com/..."
                           class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-orange-400">
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Notlar</label>
                    <textarea name="notes" rows="3"
                              class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-orange-400">{{ old('notes', $gorusme->notes) }}</textarea>
                </div>
            </div>

            <div class="flex items-center gap-3 mt-6 pt-5 border-t border-gray-100">
                <button type="submit"
                        class="bg-primary text-white px-5 py-2 rounded-lg text-sm font-medium hover:bg-orange-600 transition-colors">
                    Güncelle
                </button>
                <a href="{{ route('admin.gorusmeler.show', $gorusme) }}"
                   class="text-sm text-gray-500 hover:text-gray-700">İptal</a>
            </div>
        </form>
    </div>
</div>
@endsection