@extends('admin.layouts.app')

@section('title', 'Шинэ мэдээ')
@section('page_title', 'Шинэ мэдээ нэмэх')

@section('content')

<form action="{{ route('admin.news.store') }}" method="POST" enctype="multipart/form-data" class="max-w-3xl bg-white rounded-2xl border border-gray-100 p-6 lg:p-8 space-y-5">
    @csrf

    <div>
        <label class="block text-sm font-semibold mb-1">Гарчиг <span class="text-nsma-red">*</span></label>
        <input type="text" name="title" value="{{ old('title') }}" required class="w-full px-4 py-3 border border-gray-200 rounded-lg outline-none">
    </div>

    <div class="grid md:grid-cols-2 gap-4">
        <div>
            <label class="block text-sm font-semibold mb-1">Ангилал</label>
            <input type="text" name="category" value="{{ old('category') }}" class="w-full px-4 py-3 border border-gray-200 rounded-lg outline-none">
        </div>
        <div>
            <label class="block text-sm font-semibold mb-1">Tag (таслалаар тусгаарлах)</label>
            <input type="text" name="tags" value="{{ old('tags') }}" class="w-full px-4 py-3 border border-gray-200 rounded-lg outline-none">
        </div>
    </div>

    <div>
        <label class="block text-sm font-semibold mb-1">Богино тойм</label>
        <textarea name="excerpt" rows="2" class="w-full px-4 py-3 border border-gray-200 rounded-lg outline-none">{{ old('excerpt') }}</textarea>
    </div>

    <div>
        <label class="block text-sm font-semibold mb-1">Контент <span class="text-nsma-red">*</span></label>
        <textarea name="content" rows="12" required class="w-full px-4 py-3 border border-gray-200 rounded-lg outline-none font-mono text-sm">{{ old('content') }}</textarea>
        <p class="text-xs text-gray-500 mt-1">HTML дэмжинэ</p>
    </div>

    <div>
        <label class="block text-sm font-semibold mb-1">Cover зураг</label>
        <input type="file" name="cover_image" accept="image/*" class="w-full">
    </div>

    <div class="grid md:grid-cols-2 gap-4">
        <div>
            <label class="block text-sm font-semibold mb-1">Нийтлэх огноо</label>
            <input type="datetime-local" name="published_at" value="{{ old('published_at', now()->format('Y-m-d\TH:i')) }}" class="w-full px-4 py-3 border border-gray-200 rounded-lg outline-none">
        </div>
        <div class="flex items-end gap-6">
            <label class="flex items-center gap-2 pb-3"><input type="hidden" name="is_published" value="0"><input type="checkbox" name="is_published" value="1" checked class="rounded"> Нийтлэх</label>
            <label class="flex items-center gap-2 pb-3"><input type="hidden" name="is_featured" value="0"><input type="checkbox" name="is_featured" value="1" class="rounded"> Onцлох</label>
        </div>
    </div>

    <div class="border-t pt-5">
        <h3 class="font-semibold mb-3">SEO</h3>
        <input type="text" name="meta_title" placeholder="Meta title" class="w-full px-4 py-3 border border-gray-200 rounded-lg outline-none mb-3">
        <textarea name="meta_description" placeholder="Meta description" rows="2" class="w-full px-4 py-3 border border-gray-200 rounded-lg outline-none"></textarea>
    </div>

    <div class="flex gap-3 pt-4 border-t">
        <button class="bg-nsma-red text-white font-semibold px-6 py-3 rounded-lg">Хадгалах</button>
        <a href="{{ route('admin.news.index') }}" class="text-gray-600 self-center">Цуцлах</a>
    </div>
</form>

@endsection
