<div class="gallery-container">
    <div class="gallery-header">
        <a href="<?php echo Config::get('URL'); ?>gallery/view/<?php echo $this->image->id; ?>" class="gallery-back">
            <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                <line x1="19" y1="12" x2="5" y2="12"></line>
                <polyline points="12 19 5 12 12 5"></polyline>
            </svg>
            Back to Image
        </a>
    </div>

    <div class="gallery-form-container">
        <h1>Edit Image</h1>

        <div class="gallery-edit-preview">
            <img src="<?php echo Config::get('URL'); ?>gallery/image/<?php echo $this->image->id; ?>/thumb"
                 alt="<?php echo htmlspecialchars($this->image->title); ?>">
        </div>

        <form method="post" action="<?php echo Config::get('URL'); ?>gallery/edit/<?php echo $this->image->id; ?>" class="gallery-form">
            <div class="gallery-form-group">
                <label class="gallery-form-label" for="title">Title</label>
                <input type="text" name="title" id="title" class="gallery-form-input"
                       value="<?php echo htmlspecialchars($this->image->title); ?>" required>
            </div>

            <div class="gallery-form-group">
                <label class="gallery-form-label" for="description">Description</label>
                <textarea name="description" id="description" class="gallery-form-textarea" rows="4"><?php echo htmlspecialchars($this->image->description); ?></textarea>
            </div>

            <div class="gallery-form-group">
                <label class="gallery-form-checkbox">
                    <input type="checkbox" name="is_public" value="1" <?php echo $this->image->is_public ? 'checked' : ''; ?>>
                    <span>Make this image public</span>
                </label>
                <small class="gallery-form-hint">Public images are visible to everyone in the gallery</small>
            </div>

            <div class="gallery-form-actions">
                <button type="submit" name="submit_edit" class="gallery-btn gallery-btn-primary">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <polyline points="20 6 9 17 4 12"></polyline>
                    </svg>
                    Save Changes
                </button>
                <a href="<?php echo Config::get('URL'); ?>gallery/view/<?php echo $this->image->id; ?>" class="gallery-btn gallery-btn-secondary">Cancel</a>
            </div>
        </form>
    </div>
</div>
