@extends('admin.layout')

@section('header-title', 'Yeni Flashcard Oluştur')

@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: 700px;
    }
    .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;
    }
    .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,
    .form-select {
        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,
    .form-select:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    textarea.form-control {
        resize: vertical;
        min-height: 100px;
    }
    .form-control-sm {
        width: 150px;
    }

    .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;
    }
</style>

<div class="page-header">
    <div>
        <h1 class="page-title">📇 Yeni Flashcard Oluştur</h1>
        <p class="page-subtitle"><a href="{{ route('admin.interview-flashcards.index') }}">← Flashcardlar</a></p>
    </div>
</div>

@if ($errors->any())
    <div class="alert-error" style="max-width: 700px;">
        <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-flashcards.store') }}">
            @csrf

            <div class="form-group">
                <label class="form-label" for="category_id">Kategori <span class="required">*</span></label>
                <select id="category_id" name="category_id" required class="form-select">
                    <option value="">Seçiniz</option>
                    @foreach ($categories as $category)
                        <option value="{{ $category->id }}" {{ old('category_id') == $category->id ? 'selected' : '' }}>{{ $category->name }}</option>
                    @endforeach
                </select>
            </div>

            <div class="form-group">
                <label class="form-label" for="title">Başlık <span class="required">*</span></label>
                <input 
                    type="text" 
                    id="title" 
                    name="title" 
                    value="{{ old('title') }}" 
                    required 
                    class="form-control"
                    placeholder="Flashcard başlığı"
                >
            </div>

            <div class="form-group">
                <label class="form-label" for="content">Ön Yüz (Soru) <span class="required">*</span></label>
                <textarea 
                    id="content" 
                    name="content" 
                    rows="4" 
                    required 
                    class="form-control"
                    placeholder="Flashcard ön yüzü - soru veya konu..."
                >{{ old('content') }}</textarea>
            </div>

            <div class="form-group">
                <label class="form-label" for="back_content">Arka Yüz (Cevap) <span class="required">*</span></label>
                <textarea 
                    id="back_content" 
                    name="back_content" 
                    rows="4" 
                    required 
                    class="form-control"
                    placeholder="Flashcard arka yüzü - cevap veya açıklama..."
                >{{ old('back_content') }}</textarea>
            </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 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>
                    Flashcard Oluştur
                </button>
                <a href="{{ route('admin.interview-flashcards.index') }}" class="btn btn-secondary">
                    İptal
                </a>
            </div>
        </form>
    </div>
</div>
@endsection
