<div class="gallery-container">
    <div class="gallery-header">
        <a href="<?php echo Config::get('URL'); ?>gallery/index" 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 Gallery
        </a>
    </div>

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

        <div class="gallery-view-info">
            <h1><?php echo htmlspecialchars($this->image->title); ?></h1>

            <div class="gallery-view-meta">
                <div class="gallery-view-author">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
                        <circle cx="12" cy="7" r="4"></circle>
                    </svg>
                    <a href="<?php echo Config::get('URL'); ?>profile/showProfile/<?php echo $this->image->user_name; ?>">
                        <?php echo htmlspecialchars($this->image->user_name); ?>
                    </a>
                </div>

                <div class="gallery-view-date">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
                        <line x1="16" y1="2" x2="16" y2="6"></line>
                        <line x1="8" y1="2" x2="8" y2="6"></line>
                        <line x1="3" y1="10" x2="21" y2="10"></line>
                    </svg>
                    <?php echo date('M j, Y', strtotime($this->image->created_at)); ?>
                </div>

                <div class="gallery-view-size">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
                        <polyline points="7 10 12 15 17 10"></polyline>
                        <line x1="12" y1="15" x2="12" y2="3"></line>
                    </svg>
                    <?php echo GalleryModel::formatFileSize($this->image->file_size); ?>
                </div>
            </div>

            <?php if ($this->image->description): ?>
                <div class="gallery-view-description">
                    <?php echo nl2br(htmlspecialchars($this->image->description)); ?>
                </div>
            <?php endif; ?>

            <?php if ($this->image->user_id == Session::get('user_id')): ?>
                <div class="gallery-view-actions">
                    <a href="<?php echo Config::get('URL'); ?>gallery/edit/<?php echo $this->image->id; ?>" class="gallery-btn gallery-btn-secondary">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                            <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
                        </svg>
                        Edit
                    </a>
                    <a href="<?php echo Config::get('URL'); ?>gallery/delete/<?php echo $this->image->id; ?>"
                       class="gallery-btn gallery-btn-danger"
                       onclick="return confirm('Delete this image permanently?');">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <polyline points="3 6 5 6 21 6"></polyline>
                            <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
                        </svg>
                        Delete
                    </a>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>
