/* CELD Gallery Styles */

/* ── Override body background ── */
body {
  background: var(--bg);
}

/* ── Gallery Header ── */
.gallery-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(12, 12, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(110, 231, 183, 0.1);
}

.gallery-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.gallery-header-inner h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.gallery-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Sort Controls (pill bar) ── */
.sort-controls {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(224, 245, 236, 0.08);
}

.sort-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 400;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.sort-btn:hover {
  color: var(--text-secondary);
}

.sort-btn.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 500;
}

/* ── Upload Button (in header) ── */
.upload-btn {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(224, 245, 236, 0.15);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.upload-btn:hover {
  color: var(--text);
  border-color: rgba(224, 245, 236, 0.3);
}

/* ── Gallery Grid (CSS columns masonry) ── */
.gallery-container {
  padding: 0 2rem 4rem;
}

.gallery-grid {
  position: relative;
  width: 100%;
}

/* ── Media Item ── */
.media-item {
  position: absolute;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
}

.media-item:hover {
  transform: scale(1.02);
  z-index: 1;
}

.media-item img,
.media-item video {
  width: 100%;
  display: block;
}

.media-item img {
  opacity: 1;
  background: var(--bg-elevated);
}

/* Hover overlay with vote controls */
.media-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2.5rem 0.75rem 0.75rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.media-item:hover .media-overlay {
  opacity: 1;
}

.media-item .play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.8);
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* ── Vote Controls ── */
.vote-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8125rem;
  transition: background 0.15s;
  display: flex;
  align-items: center;
}

.vote-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.vote-btn.upvote.active {
  background: var(--accent);
  color: var(--bg);
}

.vote-btn.downvote.active {
  background: #f87171;
  color: var(--bg);
}

.vote-count {
  font-size: 0.8125rem;
  font-weight: 500;
  min-width: 1.5rem;
  text-align: center;
  color: var(--text);
}

.share-link-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font-body);
  margin-left: auto;
  transition: background 0.15s;
}

.share-link-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

/* ── Lightbox (Fullscreen Overlay) ── */
.fullscreen-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 200;
}

.fullscreen-overlay.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  transition: color 0.2s;
  z-index: 201;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: var(--text);
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-muted);
  font-size: 2.5rem;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  z-index: 201;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.nav-prev { left: 1rem; }
.nav-next { right: 1rem; }

.fullscreen-content {
  max-width: 90vw;
  max-height: 75vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-content img,
.fullscreen-content video {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.fullscreen-controls {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid rgba(224, 245, 236, 0.08);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.fullscreen-controls .vote-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.fullscreen-controls .vote-btn {
  padding: 0.4rem 0.75rem;
  font-size: 1rem;
}

.fullscreen-controls .vote-count {
  font-size: 1rem;
  min-width: 2rem;
}

.share-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: color 0.2s;
}

.share-btn:hover {
  color: var(--text);
}

.delete-btn {
  color: var(--text-muted);
}

.delete-btn:hover {
  color: #f87171;
}

.media-info {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Upload Modal ── */
.upload-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
}

.upload-modal.active {
  display: flex;
}

.upload-modal-content {
  background: var(--bg-elevated);
  border: 1px solid rgba(224, 245, 236, 0.08);
  border-radius: var(--radius);
  width: 90vw;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}

.upload-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(224, 245, 236, 0.06);
}

.upload-modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.upload-modal-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.upload-modal-actions .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.upload-drop-zone {
  margin: 1.5rem;
  padding: 3rem 1.5rem;
  border: 1px dashed rgba(224, 245, 236, 0.15);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(110, 231, 183, 0.05);
}

.upload-drop-zone input[type="file"] {
  display: none;
}

/* Upload Queue */
.upload-queue {
  padding: 0 1.5rem;
}

.upload-queue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(224, 245, 236, 0.04);
}

.upload-queue-thumb {
  width: 48px;
  height: 48px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--bg);
}

.upload-queue-info {
  flex: 1;
  min-width: 0;
}

.upload-queue-name {
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-queue-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.upload-queue-progress {
  height: 3px;
  background: rgba(224, 245, 236, 0.06);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.upload-queue-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s;
}

.upload-queue-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s;
}

.upload-queue-remove:hover {
  color: #f87171;
}


/* ── Loading ── */
.loading {
  text-align: center;
  padding: 2rem;
  font-size: 0.875rem;
  color: transparent;
  min-height: 1px;
}

.loading.active {
  color: var(--text-muted);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid rgba(110, 231, 183, 0.2);
  color: var(--text);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font-body);
  z-index: 400;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .gallery-header-inner h2 {
    font-size: 1rem;
  }

  .gallery-actions {
    width: 100%;
    justify-content: space-between;
  }

  .nav-btn {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 2rem;
  }

  .fullscreen-controls {
    padding: 0.5rem 1rem;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .sort-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
  }
}
