@extends('admin.layout')

@section('header-title', 'Yeni Forum Kategorisi')

@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;
    }

    .form-row {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 20px;
        margin-bottom: 20px;
    }
    .form-group {
        margin-bottom: 20px;
    }
    .form-label {
        display: block;
        font-size: 14px;
        font-weight: 600;
        color: #1f2937;
        margin-bottom: 8px;
    }
    .form-control,
    .form-select {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        font-size: 14px;
        font-family: inherit;
        outline: none;
        transition: all 0.2s;
    }
    .form-control:focus,
    .form-select:focus {
        border-color: #1e40af;
        box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
    }
    textarea.form-control {
        resize: vertical;
        min-height: 100px;
    }
    .form-hint {
        font-size: 13px;
        color: #6b7280;
        margin-top: 4px;
    }
    .form-error {
        font-size: 13px;
        color: #ef4444;
        margin-top: 4px;
    }
    .required {
        color: #ef4444;
    }

    .card {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    }
    .card-header {
        background: #f9fafb;
        border-bottom: 1px solid #e5e7eb;
        padding: 20px;
    }
    .card-title {
        font-size: 16px;
        font-weight: 700;
        color: #1f2937;
        margin: 0;
    }
    .card-body {
        padding: 20px;
    }

    .form-actions {
        display: flex;
        gap: 12px;
        margin-top: 24px;
        padding-top: 20px;
        border-top: 1px solid #e5e7eb;
    }
    .btn {
        padding: 10px 20px;
        border: none;
        border-radius: 6px;
        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: #1e40af;
        color: white;
    }
    .btn-primary:hover {
        background: #1e3a8a;
    }
    .btn-secondary {
        background: white;
        color: #374151;
        border: 1px solid #e5e7eb;
    }
    .btn-secondary:hover {
        background: #f9fafb;
    }

    .grid-2 {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 24px;
    }

    @media (max-width: 768px) {
        .grid-2 {
            grid-template-columns: 1fr;
        }
        .form-row {
            grid-template-columns: 1fr;
        }
    }
</style>

<div class="page-header">
    <div>
        <h1 class="page-title">🗂️ Yeni Forum Kategorisi</h1>
        <p class="page-subtitle">Forum için yeni bir kategori oluşturun</p>
    </div>
</div>

<div class="grid-2">
    <div>
        <div class="card">
            <div class="card-body">
                <form action="{{ route('admin.forum-categories.store') }}" method="POST">
                    @csrf

                    <div class="form-group">
                        <label class="form-label" for="name">Kategori Adı <span class="required">*</span></label>
                        <input 
                            type="text" 
                            id="name" 
                            name="name" 
                            value="{{ old('name') }}" 
                            class="form-control" 
                            placeholder="Örn: KPSS Hazırlığı, Mülakat Deneyimleri" 
                            required 
                            autofocus
                        >
                        @error('name')
                            <div class="form-error">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="slug">Slug</label>
                        <input 
                            type="text" 
                            id="slug" 
                            name="slug" 
                            value="{{ old('slug') }}" 
                            class="form-control" 
                            placeholder="Otomatik oluşturulur"
                        >
                        <div class="form-hint">Boş bırakılırsa isimden otomatik oluşturulur.</div>
                        @error('slug')
                            <div class="form-error">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="description">Açıklama</label>
                        <textarea 
                            id="description" 
                            name="description" 
                            class="form-control" 
                            placeholder="Kategori hakkında kısa açıklama"
                        >{{ old('description') }}</textarea>
                        @error('description')
                            <div class="form-error">{{ $message }}</div>
                        @enderror
                    </div>

                    <div class="form-row">
                        <div class="form-group">
                            <label class="form-label" for="parent_id">Üst Kategori</label>
                            <select id="parent_id" name="parent_id" class="form-select">
                                <option value="">— Ana Kategori —</option>
                                @foreach($parentCategories as $id => $name)
                                    <option value="{{ $id }}" {{ old('parent_id') == $id ? 'selected' : '' }}>{{ $name }}</option>
                                @endforeach
                            </select>
                            @error('parent_id')
                                <div class="form-error">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="form-group">
                            <label class="form-label" for="order">Sıra</label>
                            <input 
                                type="number" 
                                id="order" 
                                name="order" 
                                value="{{ old('order', 0) }}" 
                                min="0" 
                                class="form-control"
                            >
                            @error('order')
                                <div class="form-error">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="form-group">
                            <label class="form-label" for="icon">İkon (Emoji)</label>
                            <input 
                                type="text" 
                                id="icon" 
                                name="icon" 
                                value="{{ old('icon', '💬') }}" 
                                class="form-control" 
                                placeholder="💬"
                                maxlength="2"
                            >
                            @error('icon')
                                <div class="form-error">{{ $message }}</div>
                            @enderror
                        </div>
                    </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>
                            Kaydet
                        </button>
                        <a href="{{ route('admin.forum-categories.index') }}" class="btn btn-secondary">İptal</a>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div>
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">💡 İpuçları</h3>
            </div>
            <div class="card-body">
                <ul style="list-style: none; padding: 0; margin: 0; font-size: 14px; color: #6b7280; line-height: 1.8;">
                    <li style="margin-bottom: 12px;">• Ana kategoriler <strong>Üst Kategori</strong> seçilmeden oluşturulur.</li>
                    <li style="margin-bottom: 12px;">• Alt kategoriler bir ana kategoriye bağlı olmalıdır.</li>
                    <li style="margin-bottom: 12px;">• <strong>Sıra</strong> alanı küçük sayılar önce görünür (0 en önce).</li>
                    <li>• İkon alanına emoji girerek kategoriyi görsel hale getirebilirsiniz.</li>
                </ul>
            </div>
        </div>
    </div>
</div>

@endsection
