@extends('layouts.app')

@section('title', 'Tambah Tahun Ajaran')

@section('content')
<div class="container-fluid">
    <!-- Page Header -->
    <div class="mb-4">
        <div class="d-flex align-items-center mb-2">
            <a href="{{ route('superadmin.academic-years.index') }}" class="btn btn-outline-secondary btn-sm me-3">
                <i class="bi bi-arrow-left"></i>
            </a>
            <div>
                <h4 class="mb-0">
                    <i class="bi bi-plus-circle text-primary me-2"></i>
                    Tambah Tahun Ajaran Baru
                </h4>
                <p class="text-muted mb-0 small">Isi form di bawah untuk menambah tahun ajaran</p>
            </div>
        </div>
    </div>

    @if(session('error'))
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <i class="bi bi-exclamation-circle me-2"></i>{{ session('error') }}
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    </div>
    @endif

    <div class="row">
        <div class="col-lg-8">
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-primary text-white py-3">
                    <h5 class="mb-0">
                        <i class="bi bi-calendar-range me-2"></i>
                        Informasi Tahun Ajaran
                    </h5>
                </div>
                <div class="card-body p-4">
                    <form action="{{ route('superadmin.academic-years.store') }}" method="POST">
                        @csrf

                        <div class="mb-4">
                            <label class="form-label fw-bold">
                                <i class="bi bi-calendar-event text-muted me-1"></i>
                                Nama Tahun Ajaran <span class="text-danger">*</span>
                            </label>
                            <input type="text" name="name" class="form-control @error('name') is-invalid @enderror" 
                                value="{{ old('name') }}" placeholder="Contoh: 2025/2026" required>
                            @error('name')
                            <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                            <small class="text-muted">Format: YYYY/YYYY</small>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-calendar-check text-muted me-1"></i>
                                    Tanggal Mulai <span class="text-danger">*</span>
                                </label>
                                <input type="date" name="start_date" class="form-control @error('start_date') is-invalid @enderror" 
                                    value="{{ old('start_date') }}" required>
                                @error('start_date')
                                <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-calendar-x text-muted me-1"></i>
                                    Tanggal Selesai <span class="text-danger">*</span>
                                </label>
                                <input type="date" name="end_date" class="form-control @error('end_date') is-invalid @enderror" 
                                    value="{{ old('end_date') }}" required>
                                @error('end_date')
                                <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>

                        <div class="mb-4">
                            <label class="form-label fw-bold">
                                <i class="bi bi-journal-text text-muted me-1"></i>
                                Keterangan
                            </label>
                            <textarea name="description" class="form-control @error('description') is-invalid @enderror" 
                                rows="3" placeholder="Keterangan tambahan (opsional)">{{ old('description') }}</textarea>
                            @error('description')
                            <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        <div class="border-top pt-4 mt-4">
                            <div class="d-flex justify-content-between">
                                <a href="{{ route('superadmin.academic-years.index') }}" class="btn btn-secondary">
                                    <i class="bi bi-x-circle me-1"></i>
                                    Batal
                                </a>
                                <button type="submit" class="btn btn-primary">
                                    <i class="bi bi-save me-1"></i>
                                    Simpan Tahun Ajaran
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-lg-4">
            <div class="card border-0 border-start border-info border-4 bg-light">
                <div class="card-body">
                    <h6 class="text-info mb-3">
                        <i class="bi bi-lightbulb-fill me-1"></i>Panduan
                    </h6>
                    <ul class="small text-muted mb-0">
                        <li class="mb-2">Nama tahun ajaran biasanya dalam format YYYY/YYYY</li>
                        <li class="mb-2">Tentukan periode mulai dan selesai dengan tepat</li>
                        <li class="mb-2">Tahun ajaran baru akan berstatus nonaktif secara default</li>
                        <li class="mb-2">Aktifkan tahun ajaran dari halaman daftar setelah dibuat</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
