/* gallery.css — Full-screen image gallery */

/* ── Overlay ── */
.gallery-overlay {
    position: fixed; inset: 0; z-index: 5000;
    background: #0f172a;
    display: flex; flex-direction: column;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.gallery-overlay.active { opacity: 1; pointer-events: auto; }

/* ── Header ── */
.gallery-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 2rem; border-bottom: 1px solid #1e293b;
    background: #0f172a; flex-shrink: 0; gap: 1rem; flex-wrap: wrap;
}
.gallery-header-left { display: flex; align-items: center; gap: 1rem; }
.gallery-header-right { display: flex; align-items: center; gap: 0.75rem; }
.gallery-close-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid #1e293b;
    background: #1e293b; color: #94a3b8; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; flex-shrink: 0;
}
.gallery-close-btn:hover { background: #334155; color: #f8fafc; }
.gallery-title { font-size: 1.2rem; font-weight: 800; color: #f8fafc; margin: 0; }
.gallery-subtitle { font-size: 0.8rem; color: #64748b; margin: 0.15rem 0 0; }

.gallery-search-wrap {
    position: relative; display: flex; align-items: center;
}
.gallery-search-wrap svg { position: absolute; left: 0.85rem; color: #64748b; pointer-events: none; }
.gallery-search {
    background: #1e293b; border: 1px solid #334155; border-radius: 8px;
    color: #f8fafc; padding: 0.55rem 1rem 0.55rem 2.4rem;
    font-size: 0.875rem; outline: none; width: 220px;
    transition: border-color 0.2s;
}
.gallery-search:focus { border-color: var(--primary-orange); }
.gallery-search::placeholder { color: #475569; }

.gallery-upload-btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 1.1rem; background: var(--primary-orange); color: white;
    border-radius: 8px; font-weight: 700; font-size: 0.875rem; cursor: pointer;
    transition: all 0.2s ease; white-space: nowrap;
}
.gallery-upload-btn:hover { background: #e06c11; transform: translateY(-1px); }

/* ── Body / Grid ── */
.gallery-body {
    flex: 1; overflow-y: auto; padding: 1.5rem 2rem;
    -webkit-overflow-scrolling: touch;
}
.gallery-loading {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 60vh; gap: 1rem; color: #475569;
}
.gallery-spinner {
    width: 40px; height: 40px; border: 3px solid #1e293b;
    border-top-color: var(--primary-orange); border-radius: 50%;
    animation: gallerySpin 0.8s linear infinite;
}
@keyframes gallerySpin { to { transform: rotate(360deg); } }

.gallery-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 60vh; gap: 0.75rem;
    color: #475569; text-align: center;
}
.gallery-empty p { font-size: 1.1rem; font-weight: 600; color: #64748b; margin: 0; }
.gallery-empty span { font-size: 0.875rem; color: #475569; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

/* ── Gallery Card ── */
.gallery-card {
    position: relative; border-radius: 12px; overflow: hidden;
    background: #1e293b; cursor: pointer; aspect-ratio: 1;
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.gallery-card:hover { border-color: var(--primary-orange); transform: scale(1.03); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.gallery-card.selected { border-color: #22c55e; }
.gallery-card img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform 0.3s ease;
}
.gallery-card:hover img { transform: scale(1.05); }
.gallery-card-overlay {
    position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 60%);
    opacity: 0; transition: opacity 0.2s ease;
    display: flex; flex-direction: column; justify-content: flex-end; padding: 0.75rem;
}
.gallery-card:hover .gallery-card-overlay { opacity: 1; }
.gallery-card-name {
    font-size: 0.7rem; font-weight: 600; color: white;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gallery-card-size { font-size: 0.65rem; color: #94a3b8; margin-top: 2px; }
.gallery-card-actions {
    position: absolute; top: 0.5rem; right: 0.5rem; display: flex; gap: 0.35rem;
    opacity: 0; transition: opacity 0.2s;
}
.gallery-card:hover .gallery-card-actions { opacity: 1; }
.gallery-card-btn {
    width: 30px; height: 30px; border-radius: 8px; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; transition: all 0.15s ease;
}
.gallery-card-btn.use { background: var(--primary-orange); color: white; }
.gallery-card-btn.use:hover { background: #e06c11; transform: scale(1.1); }
.gallery-card-btn.preview { background: rgba(15,23,42,0.8); color: white; }
.gallery-card-btn.preview:hover { background: #1e293b; transform: scale(1.1); }

/* ── Fullscreen Preview ── */
.gallery-preview {
    position: fixed; inset: 0; z-index: 6000;
    background: rgba(0,0,0,0.95); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
.gallery-preview.active { opacity: 1; pointer-events: auto; }
.gallery-preview-content {
    display: flex; flex-direction: column; align-items: center;
    max-width: 90vw; max-height: 80vh;
}
.gallery-preview-content img {
    max-width: 100%; max-height: 72vh;
    object-fit: contain; border-radius: 12px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    transition: opacity 0.2s ease;
}
.gallery-preview-info { text-align: center; margin-top: 1rem; }
.gallery-preview-info p { color: #f8fafc; font-weight: 600; font-size: 0.95rem; margin: 0; }
.gallery-preview-info span { color: #64748b; font-size: 0.8rem; }
.gallery-preview-close {
    position: fixed; top: 1.5rem; right: 1.5rem; z-index: 6001;
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
    color: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.gallery-preview-close:hover { background: rgba(255,255,255,0.2); transform: scale(1.1); }
.gallery-preview-prev, .gallery-preview-next {
    position: fixed; top: 50%; transform: translateY(-50%);
    width: 48px; height: 48px; border-radius: 50%;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
    color: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.gallery-preview-prev { left: 1.5rem; }
.gallery-preview-next { right: 1.5rem; }
.gallery-preview-prev:hover, .gallery-preview-next:hover { background: rgba(255,255,255,0.2); transform: translateY(-50%) scale(1.1); }
.gallery-preview-select {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 0.6rem;
    padding: 0.8rem 2rem; background: var(--primary-orange); color: white;
    border: none; border-radius: 9999px; font-weight: 700; font-size: 1rem;
    cursor: pointer; box-shadow: 0 4px 20px rgba(252,128,25,0.5);
    transition: all 0.2s ease;
}
.gallery-preview-select:hover { background: #e06c11; transform: translateX(-50%) translateY(-2px); box-shadow: 0 8px 28px rgba(252,128,25,0.6); }

/* ── Browse Gallery Button (inside modals) ── */
.browse-gallery-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 1rem; border: 1.5px dashed #cbd5e1; border-radius: 8px;
    background: transparent; color: var(--text-light); font-size: 0.85rem;
    font-weight: 600; cursor: pointer; transition: all 0.2s ease;
    width: 100%; justify-content: center; margin-top: 0.5rem;
}
.browse-gallery-btn:hover { border-color: var(--primary-orange); color: var(--primary-orange); background: #fff7ed; }
body.dark-mode .browse-gallery-btn:hover { background: rgba(252,128,25,0.1); }

/* ── Mobile ── */
@media (max-width: 768px) {
    .gallery-header { padding: 1rem; }
    .gallery-title { font-size: 1rem; }
    .gallery-search { width: 150px; }
    .gallery-body { padding: 1rem; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.6rem; }
    .gallery-preview-prev { left: 0.5rem; }
    .gallery-preview-next { right: 0.5rem; }
}
