@extends('backEnd.layouts.master')
@section('title', 'Edit Feature')

@section('css')
<style>@verbatim
    .card { border: none; box-shadow: 0 0 20px rgba(18,38,63,.03); border-radius: 12px; }
    .form-label { font-weight: 600; font-size: 13px; color: #636e72; margin-bottom: 6px; }
    .form-control { border-radius: 8px; padding: 10px 12px; }
    .switch { position: relative; display: inline-block; width: 44px; height: 22px; }
    .switch input { opacity: 0; width: 0; height: 0; }
    .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #eef2f7; transition: .4s; border-radius: 34px; }
    .slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 2px; bottom: 1px; background-color: white; transition: .4s; border-radius: 50%; }
    input:checked + .slider { background-color: #0acf97; }
    input:checked + .slider:before { transform: translateX(20px); }
    .icon-preview { width: 42px; height: 42px; background: #e8f5e9; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #2e7d32; font-size: 18px; }
@endverbatim</style>
@endsection

@section('content')
<div class="container-fluid">
    <div class="row mb-3 mt-3">
        <div class="col-12 d-flex justify-content-between align-items-center">
            <h4 class="page-title mb-0 fw-bold">Edit Feature</h4>
            <a href="{{ route('admin.landing-features.index') }}" class="btn btn-light rounded-pill border px-4">
                <i class="fe-arrow-left me-1"></i> Back
            </a>
        </div>
    </div>

    <form action="{{ route('admin.landing-features.update', $feature->id) }}" method="POST">
        @csrf
        <div class="row">
            <div class="col-lg-7">
                <div class="card">
                    <div class="card-body">

                        <div class="mb-3">
                            <label class="form-label">Title <span class="text-danger">*</span></label>
                            <input type="text" name="title" value="{{ old('title', $feature->title) }}"
                                class="form-control @error('title') is-invalid @enderror" required>
                            @error('title')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>

                        <div class="mb-3">
                            <label class="form-label">Description</label>
                            <input type="text" name="description" value="{{ old('description', $feature->description) }}"
                                class="form-control">
                        </div>

                        <div class="mb-3">
                            <label class="form-label">Icon <span class="text-muted small">(Font Awesome class)</span></label>
                            <div class="input-group">
                                <span class="input-group-text">
                                    <div class="icon-preview">
                                        <i class="{{ old('icon', $feature->icon ?? 'fa-solid fa-star') }}" id="iconEl"></i>
                                    </div>
                                </span>
                                <input type="text" name="icon" id="iconInput" value="{{ old('icon', $feature->icon) }}"
                                    class="form-control" placeholder="fa-solid fa-leaf"
                                    oninput="document.getElementById('iconEl').className = this.value">
                            </div>
                            <small class="text-muted">যেমন: fa-solid fa-leaf, fa-solid fa-plane, fa-solid fa-star</small>
                        </div>

                        <div class="mb-3">
                            <label class="form-label">Sort Order</label>
                            <input type="number" name="sort_order" value="{{ old('sort_order', $feature->sort_order) }}"
                                class="form-control" min="0" style="max-width: 120px;">
                        </div>

                        <div class="d-flex align-items-center gap-3">
                            <label class="switch mb-0">
                                <input type="checkbox" name="status" value="1" {{ old('status', $feature->status) ? 'checked' : '' }}>
                                <span class="slider"></span>
                            </label>
                            <span class="text-muted small">Active</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <button type="submit" class="btn btn-primary rounded-pill px-5 mt-3">
            <i class="fe-save me-1"></i> Update Feature
        </button>
    </form>
</div>
@endsection
