<?php $title = htmlspecialchars($album->title) . ' - Photos'; ?>
<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-white font-weight-bold"><?= htmlspecialchars($album->title) ?></h1>
    <div>
        <a href="<?= $baseUrl ?>/photos" class="glass-btn mr-2"><i class="fas fa-arrow-left mr-1"></i>Back</a>
        <?php if (isset($_SESSION['user_id'])): ?>
        <form method="POST" action="<?= $baseUrl ?>/photos/album/<?= $album->id ?>/upload" enctype="multipart/form-data" style="display:inline;">
            <input type="file" name="photos[]" multiple accept="image/*" class="d-none" id="photoUpload" onchange="this.form.submit()">
            <button type="button" class="glass-btn glass-btn-primary" onclick="document.getElementById('photoUpload').click()"><i class="fas fa-upload mr-1"></i>Upload Photos</button>
        </form>
        <?php endif; ?>
    </div>
</div>
<?php if (!empty($photos)): ?>
<div class="row">
    <?php foreach ($photos as $photo): ?>
    <div class="col-lg-3 col-md-4 col-6 mb-4">
        <div class="glass-card p-2 text-center">
            <img src="<?= $baseUrl . '/' . ltrim($photo->file_path, '/') ?>" class="img-fluid rounded mb-2" style="height: 150px; object-fit: cover; width: 100%;">
            <small style="color: rgba(255,255,255,0.5);"><?= htmlspecialchars($photo->title ?? '') ?></small>
            <?php if (isset($_SESSION['user_id'])): ?>
            <form method="POST" action="<?= $baseUrl ?>/photos/<?= $photo->id ?>/delete" onsubmit="return confirm('Delete this photo?');">
                <button type="submit" class="btn btn-sm btn-danger mt-1"><i class="fas fa-trash"></i></button>
            </form>
            <?php endif; ?>
        </div>
    </div>
    <?php endforeach; ?>
</div>
<?php else: ?>
<div class="empty-state"><i class="fas fa-image"></i><p>No photos in this album</p></div>
<?php endif; ?>
