@extends('layouts.admin')

@section('admin-content')
    <div class="container-fluid">
        <div class="row mb-4">
            <div class="col-12">
                <div class="card border-0 shadow-sm">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-center">
                            <div>
                                <h1 class="h3 mb-1 text-dark">
                                    <i class="fas fa-plus-circle text-primary me-2"></i>
                                    {{ trans('app.Add Version') }}
                                </h1>
                                <p class="text-muted mb-0">{{ $productCategory->name }}</p>
                            </div>
                            <div>
                                <a href="{{ route('admin.product-categories.edit', $productCategory) }}"
                                    class="btn btn-outline-secondary">
                                    <i class="fas fa-arrow-left me-1"></i>
                                    {{ trans('app.Back') }}
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        @if ($errors->any())
            <div class="row mb-4">
                <div class="col-12">
                    <div class="alert alert-danger">
                        <h5 class="alert-heading">
                            <i class="fas fa-exclamation-triangle me-2"></i>
                            {{ trans('app.Validation Errors') }}
                        </h5>
                        <ul class="mb-0">
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                </div>
            </div>
        @endif

        <form method="post" action="{{ route('admin.product-categories.versions.store', $productCategory) }}"
            class="needs-validation" novalidate>
            @csrf

            <div class="row">
                <div class="col-lg-8">
                    <div class="card mb-4">
                        <div class="card-header bg-primary text-white">
                            <h5 class="card-title mb-0">
                                <i class="fas fa-code-branch me-2"></i>
                                {{ trans('app.Version Details') }}
                            </h5>
                        </div>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label for="version" class="form-label">
                                        <i class="fas fa-tag text-primary me-1"></i>
                                        {{ trans('app.Version') }} <span class="text-danger">*</span>
                                    </label>
                                    <input type="text" class="form-control @error('version') is-invalid @enderror"
                                        id="version" name="version" value="{{ old('version') }}" placeholder="1.0.0"
                                        required>
                                    @error('version')
                                        <div class="invalid-feedback">{{ $message }}</div>
                                    @enderror
                                </div>

                                <div class="col-md-6 mb-3">
                                    <label for="status" class="form-label">
                                        <i class="fas fa-toggle-on text-success me-1"></i>
                                        {{ trans('app.Status') }} <span class="text-danger">*</span>
                                    </label>
                                    <select class="form-select @error('status') is-invalid @enderror" id="status"
                                        name="status" required>
                                        <option value="draft" {{ old('status', 'draft') === 'draft' ? 'selected' : '' }}>
                                            {{ trans('app.Draft') }}</option>
                                        <option value="published" {{ old('status') === 'published' ? 'selected' : '' }}>
                                            {{ trans('app.Published') }}</option>
                                        <option value="archived" {{ old('status') === 'archived' ? 'selected' : '' }}>
                                            {{ trans('app.Archived') }}</option>
                                    </select>
                                    @error('status')
                                        <div class="invalid-feedback">{{ $message }}</div>
                                    @enderror
                                </div>

                                <div class="col-md-6 mb-3">
                                    <label for="release_type" class="form-label">
                                        <i class="fas fa-rocket text-danger me-1"></i>
                                        {{ trans('app.Release Type') }} <span class="text-danger">*</span>
                                    </label>
                                    <select class="form-select @error('release_type') is-invalid @enderror" id="release_type"
                                            name="release_type" required>
                                        <option value="minor" {{ old('release_type', 'minor') === 'minor' ? 'selected' : '' }}>{{ trans('app.Minor') }}</option>
                                        <option value="moderate" {{ old('release_type') === 'moderate' ? 'selected' : '' }}>{{ trans('app.Moderate') }}</option>
                                        <option value="major" {{ old('release_type') === 'major' ? 'selected' : '' }}>{{ trans('app.Major') }}</option>
                                    </select>
                                    @error('release_type')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                    @enderror
                                </div>
                            </div>

                            <div class="mb-3">
                                <label for="note" class="form-label">
                                    <i class="fas fa-align-left text-secondary me-1"></i>
                                    {{ trans('app.Note') }}
                                </label>
                                <textarea class="form-control @error('note') is-invalid @enderror" id="note" name="note"
                                    rows="3" placeholder="{{ trans('app.Optional short note') }}">{{ old('note') }}</textarea>
                                @error('note')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="mb-3">
                                <label for="changelog" class="form-label">
                                    <i class="fas fa-list text-info me-1"></i>
                                    {{ trans('app.Changelog') }}
                                </label>
                                <textarea class="form-control @error('changelog') is-invalid @enderror" id="changelog" name="changelog" rows="6"
                                    placeholder="{{ trans('app.List changes for this version') }}">{{ old('changelog') }}</textarea>
                                @error('changelog')
                                    <div class="invalid-feedback">{{ $message }}</div>
                                @enderror
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-lg-4">
                    <div class="card mb-4">
                        <div class="card-header bg-secondary text-white">
                            <h5 class="card-title mb-0">
                                <i class="fas fa-tools me-2"></i>
                                {{ trans('app.Actions') }}
                            </h5>
                        </div>
                        <div class="card-body">
                            <div class="d-grid gap-2">
                                <button type="submit" class="btn btn-primary">
                                    <i class="fas fa-save me-1"></i>{{ trans('app.Save') }}
                                </button>
                                <a href="{{ route('admin.product-categories.edit', $productCategory) }}"
                                    class="btn btn-outline-secondary">
                                    <i class="fas fa-times me-1"></i>{{ trans('app.Cancel') }}
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
@endsection
