<?php $__env->startSection('content'); ?>
<?php
    $banner = $homebanner ?? null;
?>

<div class="row mb-4">
    <div class="col-md-12">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-1">
                <li class="breadcrumb-item"><a href="#" class="text-decoration-none text-muted small">Dashboard</a></li>
                <li class="breadcrumb-item"><a href="#" class="text-decoration-none text-muted small">Home Banner</a></li>
                <li class="breadcrumb-item active text-primary small fw-semibold" aria-current="page">Edit</li>
            </ol>
        </nav>
        <h2 class="fw-bold text-dark">Edit Home Banner</h2>
        <p class="text-secondary small">Refresh the hero message, improve the copy, or swap the image without changing the overall layout.</p>
    </div>
</div>

<div class="row">
    <div class="col-lg-7">
        <div class="card border-0 shadow-lg rounded-4 overflow-hidden">
            <div class="card-header bg-white border-0 py-3 px-4 mt-2">
                <h6 class="m-0 fw-bold text-dark"><i class="bi bi-pencil-fill me-2 text-primary"></i> Edit Banner Information</h6>
            </div>
            <div class="card-body p-4 pt-2">
                <form action="<?php echo e(route('home-banners.update', $banner->id)); ?>" method="POST" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                    <div class="mb-4">
                        <label for="heading" class="form-label fw-bold text-dark mb-2">Banner Heading</label>
                        <div class="input-group">
                            <span class="input-group-text bg-light border-0"><i class="bi bi-type-h1 text-secondary"></i></span>
                            <input type="text" name="heading" class="form-control bg-light border-0 <?php $__errorArgs = ['heading'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" id="heading" placeholder="Enter banner heading" value="<?php echo e(old('heading', $banner->heading ?? '')); ?>" required style="padding: 0.75rem;">
                        </div>
                        <?php $__errorArgs = ['heading'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback d-block mt-2"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="mb-4">
                        <label for="description" class="form-label fw-bold text-dark mb-2">Banner Description</label>
                        <div class="input-group">
                            <span class="input-group-text bg-light border-0 align-items-start pt-3"><i class="bi bi-text-paragraph text-secondary"></i></span>
                            <textarea name="description" class="form-control bg-light border-0 <?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" id="description" rows="5" placeholder="Update the banner description." required><?php echo e(old('description', $banner->description ?? '')); ?></textarea>
                        </div>
                        <?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback d-block mt-2"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="mb-4">
                        <label for="image" class="form-label fw-bold text-dark mb-2">Banner Image Update</label>

                        <?php if(!empty($banner?->image)): ?>
                            <div class="mb-3 p-3 border rounded-4 d-flex align-items-center bg-light">
                                <img src="<?php echo e(asset('storage/' . $banner->image)); ?>" alt="<?php echo e($banner->heading ?? 'Banner image'); ?>" class="rounded-3 border object-fit-cover me-3 current-banner-thumb">
                                <div>
                                    <span class="d-block small text-secondary fw-bold text-uppercase" style="font-size: 10px;">Current Image</span>
                                    <a href="<?php echo e(route('home-banners.show', $banner->id)); ?>" class="text-decoration-none text-primary fw-bold small">
                                        Preview Banner <i class="bi bi-box-arrow-up-right ms-1"></i>
                                    </a>
                                </div>
                                <div class="ms-auto">
                                    <span class="badge bg-success-subtle text-success rounded-pill px-3">Live</span>
                                </div>
                            </div>
                        <?php endif; ?>

                        <div class="upload-container bg-light rounded-4 p-4 text-center border-2 border-dashed border-secondary-subtle">
                            <i class="bi bi-image-alt text-primary fs-1 mb-3 d-block"></i>
                            <p class="text-dark fw-semibold mb-1">Upload a replacement image</p>
                            <p class="text-secondary small mb-0">Leave this empty if you want to keep the current banner visual</p>
                            <input type="file" name="image" class="form-control <?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" id="image" onchange="showFileName(this)" required>
                            <p class="text-secondary small mb-0" id="file-name">JPEG, PNG, JPG, or WEBP up to 2MB</p>
                        </div>
                        <?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback d-block mt-2"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <script>
                        function showFileName(input) {
                            if (input.files && input.files[0]) {
                                document.getElementById('file-name').innerText =
                                    'Selected: ' + input.files[0].name;
                            }
                        }
                    </script>

                    <hr class="my-4 opacity-50">

                    <div class="d-flex align-items-center justify-content-between">
                        <a href="<?php echo e(route('home-banners.show', $banner->id)); ?>" class="btn btn-link text-decoration-none text-secondary fw-semibold">
                            <i class="bi bi-x-circle me-1"></i> Cancel Edit
                        </a>
                        <button type="submit" class="btn btn-primary rounded-3 px-5 fw-bold shadow-sm py-2">
                            <i class="bi bi-check-lg me-2"></i> Update Banner
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="col-lg-5">
        <div class="card border-0 shadow-sm rounded-4 bg-white mb-4">
            <div class="card-body p-4">
                <h6 class="fw-bold text-dark mb-3"><i class="bi bi-info-circle me-2 text-primary"></i> Banner Summary</h6>
                <div class="mb-3 pb-3 border-bottom d-flex justify-content-between align-items-center">
                    <span class="text-secondary small">Record ID</span>
                    <span class="badge bg-light text-dark border fw-bold">#<?php echo e($banner->id ?? 'New'); ?></span>
                </div>
                <div class="mb-3 pb-3 border-bottom d-flex justify-content-between align-items-center">
                    <span class="text-secondary small">Created At</span>
                    <span class="text-dark fw-medium small"><?php echo e(!empty($banner?->created_at) ? $banner->created_at->format('M d, Y H:i') : 'Not available'); ?></span>
                </div>
                <div class="d-flex justify-content-between align-items-center">
                    <span class="text-secondary small">Last Updated</span>
                    <span class="text-dark fw-medium small"><?php echo e(!empty($banner?->updated_at) ? $banner->updated_at->diffForHumans() : 'Not updated yet'); ?></span>
                </div>
            </div>
        </div>

        <div class="alert bg-primary-subtle text-primary border-0 rounded-4 p-4 shadow-sm">
            <div class="d-flex">
                <i class="bi bi-lightbulb-fill fs-4 me-3"></i>
                <div>
                    <h6 class="fw-bold mb-1">Editing Tip</h6>
                    <p class="small mb-0 opacity-75">Try to keep the heading and description aligned with the image style so the homepage hero feels focused and consistent.</p>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('styles'); ?>
<style>
    .upload-container {
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;
    }
    .upload-container:hover {
        background-color: #f1f5f9 !important;
        border-color: #3b82f6 !important;
    }
    .upload-container input[type="file"] {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
    }
    .bg-primary-subtle { background-color: #eff6ff !important; }
    .bg-success-subtle { background-color: #ecfdf5 !important; }
    .text-success { color: #10b981 !important; }
    .border-dashed { border-style: dashed !important; }
    .input-group-text { border: none !important; }
    .current-banner-thumb {
        width: 84px;
        height: 84px;
        object-fit: cover;
    }
    .breadcrumb-item + .breadcrumb-item::before { content: "\2022"; color: #cbd5e1; }
</style>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\portfolio\resources\views\homebanner\edit.blade.php ENDPATH**/ ?>