@extends('admin.layout')

@section('header-title', 'Kategori Düzenle')

@section('content')
<style>
    .page-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 32px;
        flex-wrap: wrap;
        gap: 16px;
    }
    .page-title {
        font-size: 24px;
        font-weight: 800;
        color: #1f2937;
    }
    .page-subtitle {
        font-size: 14px;
        color: #6b7280;
        margin-top: 4px;
    }
    .page-subtitle a {
        color: #3b82f6;
        text-decoration: none;
    }
    .page-subtitle a:hover {
        text-decoration: underline;
    }

    .card {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
        max-width: 640px;
    }
    .card-body {
        padding: 28px;
    }

    .alert-error {
        background: #fef2f2;
        border: 1px solid #fecaca;
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 24px;
        color: #dc2626;
        font-size: 14px;
        max-width: 640px;
    }
    .alert-error ul {
        margin: 8px 0 0 20px;
    }

    .form-group {
        margin-bottom: 20px;
    }
    .form-label {
        display: block;
        font-weight: 600;
        font-size: 14px;
        color: #374151;
        margin-bottom: 6px;
    }
    .required {
        color: #ef4444;
    }
    .form-control {
        width: 100%;
        padding: 10px 14px;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 14px;
        font-family: inherit;
        outline: none;
        transition: all 0.2s;
    }
    .form-control:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    textarea.form-control {
        resize: vertical;
        min-height: 80px;
    }
    .form-control-sm {
        width: 200px;
    }

    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-bottom: 20px;
    }

    .form-actions {
        display: flex;
        gap: 12px;
        padding-top: 8px;
    }
    .btn {
        padding: 10px 24px;
        border: none;
        border-radius: 8px;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        transition: all 0.2s;
    }
    .btn-primary {
        background: #3b82f6;
        color: white;
    }
    .btn-primary:hover {
        background: #2563eb;
    }
    .btn-secondary {
        background: #f3f4f6;
        color: #374151;
    }
    .btn-secondary:hover {
        background: #e5e7eb;
    }
    .btn-danger {
        background: #fee2e2;
        color: #991b1b;
    }
    .btn-danger:hover {
        background: #fecaca;
    }
</style>

<div class="page-header">
    <div>
        <h1 class="page-title">📚 Kategori Düzenle</h1>
        <p class="page-subtitle"><a href="{{ route('admin.interview-categories.index') }}">← Kategoriler</a></p>
    </div>
</div>

@if ($errors->any())
    <div class="alert-error">
        <strong>Hata:</strong>
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

<div class="card">
    <div class="card-body">
        <form method="POST" action="{{ route('admin.interview-categories.update', $category) }}">
            @csrf
            @method('PUT')

            <div class="form-group">
                <label class="form-label" for="name">İsim <span class="required">*</span></label>
                <input 
                    type="text" 
                    id="name" 
                    name="name" 
                    value="{{ old('name', $category->name) }}" 
                    required 
                    class="form-control"
                >
            </div>

            <div class="form-group">
                <label class="form-label" for="slug">Slug <span class="required">*</span></label>
                <input 
                    type="text" 
                    id="slug" 
                    name="slug" 
                    value="{{ old('slug', $category->slug) }}" 
                    required 
                    class="form-control"
                >
            </div>

            <div class="form-group">
                <label class="form-label" for="description">Açıklama</label>
                <textarea 
                    id="description" 
                    name="description" 
                    rows="3" 
                    class="form-control"
                >{{ old('description', $category->description) }}</textarea>
            </div>

            <div class="form-row">
                <div class="form-group">
                    <label class="form-label" for="icon">İkon (Emoji)</label>
                    <input 
                        type="text" 
                        id="icon" 
                        name="icon" 
                        value="{{ old('icon', $category->icon) }}"
                        class="form-control"
                    >
                </div>
                <div class="form-group">
                    <label class="form-label" for="color">Renk</label>
                    <input 
                        type="text" 
                        id="color" 
                        name="color" 
                        value="{{ old('color', $category->color) }}"
                        class="form-control"
                    >
                </div>
            </div>

            <div class="form-group">
                <label class="form-label" for="time_limit">Süre Limiti (dakika)</label>
                <input 
                    type="number" 
                    id="time_limit" 
                    name="time_limit" 
                    value="{{ old('time_limit', $category->time_limit) }}" 
                    min="1" 
                    max="180"
                    class="form-control form-control-sm"
                >
            </div>

            <div class="form-actions">
                <button type="submit" class="btn btn-primary">
                    <svg style="width:18px;height:18px" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
                    </svg>
                    Güncelle
                </button>
                <a href="{{ route('admin.interview-categories.index') }}" class="btn btn-secondary">
                    İptal
                </a>
                <form method="POST" action="{{ route('admin.interview-categories.destroy', $category) }}" style="display: flex; margin-left: auto;" onsubmit="return confirm('Bu kategoriyi silmek istediğinizden emin misiniz?');">
                    @csrf
                    @method('DELETE')
                    <button type="submit" class="btn btn-danger">
                        <svg style="width:18px;height:18px" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
                        </svg>
                        Sil
                    </button>
                </form>
            </div>
        </form>
    </div>
</div>
@endsection
