@extends('layouts.admin')

@section('title', 'Edit Banner')

@section('admin-content')
    <div class="page-header">
        <div>
            <h3 class="page-title">Edit Banner</h3>
            <p class="text-muted mb-0">Update banner details</p>
        </div>
        <a href="{{ route('admin.banners.index') }}" class="btn btn-light border shadow-sm">
            <i class="bi bi-arrow-left me-1"></i> Back to List
        </a>
    </div>

    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card shadow-sm">
                <div class="card-body p-4">
                    <form action="{{ route('admin.banners.update', $banner->id) }}" method="POST" enctype="multipart/form-data">
                        @csrf
                        @method('PUT')
                        
                        <div class="mb-3">
                            <label class="form-label fw-bold">Current Image</label>
                            <div class="ratio ratio-21x9 bg-light border rounded mb-2">
                                <img src="{{ asset('storage/' . $banner->image) }}" class="object-fit-cover rounded">
                            </div>
                        </div>

                        <div class="mb-3">
                            <label class="form-label fw-bold">Change Image</label>
                            <input type="file" name="image" class="form-control" accept="image/*">
                            <div class="form-text">Leave empty to keep current image.</div>
                        </div>

                        <div class="row g-3 mb-3">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">Position</label>
                                <select name="position" class="form-select" required>
                                    <option value="home_top" {{ $banner->position == 'home_top' ? 'selected' : '' }}>Home Top (Slider)</option>
                                    <option value="home_top_right_1" {{ $banner->position == 'home_top_right_1' ? 'selected' : '' }}>Home Top Right (Top)</option>
                                    <option value="home_top_right_2" {{ $banner->position == 'home_top_right_2' ? 'selected' : '' }}>Home Top Right (Bottom)</option>
                                    <option value="home_middle" {{ $banner->position == 'home_middle' ? 'selected' : '' }}>Home Middle</option>
                                    <option value="footer" {{ $banner->position == 'footer' ? 'selected' : '' }}>Footer</option>
                                    <option value="client_logo" {{ $banner->position == 'client_logo' ? 'selected' : '' }}>Client Logo</option>
                                    <option disabled>--- Product/Supplier Pages ---</option>
                                    <option value="product_sidebar" {{ $banner->position == 'product_sidebar' ? 'selected' : '' }}>Product Page Sidebar (Vertical)</option>
                                    <option value="product_middle" {{ $banner->position == 'product_middle' ? 'selected' : '' }}>Product Page Middle (Horizontal)</option>
                                    <option value="supplier_sidebar" {{ $banner->position == 'supplier_sidebar' ? 'selected' : '' }}>Supplier Page Sidebar (Vertical)</option>
                                    <option value="supplier_middle" {{ $banner->position == 'supplier_middle' ? 'selected' : '' }}>Supplier Page Middle (Horizontal)</option>
                                    <option value="profile_sidebar" {{ $banner->position == 'profile_sidebar' ? 'selected' : '' }}>Seller Profile Sidebar (Vertical)</option>
                                    <option value="profile_middle" {{ $banner->position == 'profile_middle' ? 'selected' : '' }}>Seller Profile Middle (Horizontal)</option>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">Type</label>
                                <select name="type" class="form-select" required>
                                    <option value="standard" {{ $banner->type == 'standard' ? 'selected' : '' }}>Standard</option>
                                    <option value="blink" {{ $banner->type == 'blink' ? 'selected' : '' }}>Blink Effect</option>
                                    <option value="slider" {{ $banner->type == 'slider' ? 'selected' : '' }}>Slider (Auto-rotate)</option>
                                </select>
                            </div>
                        </div>

                        <div class="mb-3">
                            <label class="form-label fw-bold">Link URL (Optional)</label>
                            <input type="url" name="link" class="form-control" value="{{ $banner->link }}" placeholder="https://...">
                        </div>

                        <button type="submit" class="btn btn-primary-gradient w-100 py-2">
                            <i class="bi bi-check-lg me-2"></i> Update Banner
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
