/* Gallery Container */
.gallery-container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  gap: 20px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  gap: 10px;
}

.filter-btn {
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.filter-btn:hover {
  background: var(--surface-hover);
}

.filter-btn--active {
  background: var(--bordeaux);
  border-color: var(--bordeaux);
  color: var(--accent);
  font-weight: 600;
}

.filter-btn--active:hover {
  background: var(--bordeaux-dark);
}

/* Button */
.btn {
  padding: 10px 20px;
  background: var(--bordeaux);
  color: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.3s;
}

.btn:hover:not(:disabled) {
  background: var(--bordeaux-dark);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--download {
  padding: 10px 20px;
  background: var(--bordeaux);
  color: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.3s;
}

.btn--download:hover {
  background: var(--bordeaux-dark);
}

/* Selection Controls */
.selection-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary {
  padding: 10px 20px;
  background: var(--bg-secondary);
  color: var(--text-body);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.3s;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

/* Gallery Stats */
.gallery-stats {
  text-align: center;
  margin-bottom: 30px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Grid Size Toggle Buttons */
.grid-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-btn:hover {
  background: var(--surface-hover);
}

.grid-btn--active {
  background: var(--bordeaux);
  border-color: var(--bordeaux);
  color: var(--accent);
}

.grid-btn--active:hover {
  background: var(--bordeaux-dark);
}

/* Masonry Grid - Dynamic Columns */
.gallery-masonry {
  display: grid;
  gap: 16px;
  margin-bottom: 40px;
  grid-template-columns: repeat(3, 1fr);
  transition: grid-template-columns 0.3s ease;
}

.gallery-masonry[data-cols="3"] {
  grid-template-columns: repeat(3, 1fr);
}

.gallery-masonry[data-cols="4"] {
  grid-template-columns: repeat(4, 1fr);
}

.gallery-masonry[data-cols="5"] {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1200px) {
  .gallery-masonry[data-cols="5"] {
    grid-template-columns: repeat(4, 1fr);
  }
  .gallery-masonry[data-cols="4"] {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .gallery-masonry {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .grid-size-toggle {
    display: none !important;
  }
}

/* Media Item */
.media-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: transform 0.3s ease, border-color 0.3s ease;
  aspect-ratio: 1;
  border: 1px solid var(--border-subtle);
}

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

.media-item--selected {
  border-color: var(--bordeaux);
  border-width: 2px;
}

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

.media-item img {
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
}

.media-item img.loaded {
  opacity: 1;
}

/* Media Badge */
.media-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
}

/* Video Play Icon */
.media-video-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  background: rgba(165, 42, 64, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
}

/* Media Info (Hover) */
.media-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  color: white;
  padding: 10px 10px 8px;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.3s;
}

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

.media-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

/* Media Checkbox */
.media-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  cursor: pointer;
}

.media-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--bordeaux);
}

.media-item--selected .media-checkbox {
  background: rgba(165, 42, 64, 0.8);
}

.media-download-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 5;
}

.media-item:hover .media-download-btn {
  opacity: 1;
}

.media-download-btn:hover {
  background: rgba(165, 42, 64, 0.8);
}

/* Empty State */
.gallery-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* Upload Section */
.upload-container {
  max-width: 700px;
  margin: 0 auto;
}

.upload-form {
  background: var(--bg-secondary);
  padding: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.upload__dropzone {
  border: 2px dashed var(--accent);
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: background 0.3s;
  margin-bottom: 20px;
}

.upload__dropzone:hover {
  background: var(--surface-hover);
}

.upload__dropzone--active {
  background: var(--surface-hover);
  border-color: var(--bordeaux);
}

.upload__dropzone-content {
  pointer-events: none;
}

.upload__title {
  display: block;
  font-weight: 600;
  color: var(--text-headline);
  margin-bottom: 8px;
}

.upload__hint {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Upload Preview */
.upload__preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.upload__thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.upload__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload__thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

/* Upload Meta */
.upload__meta {
  margin-bottom: 20px;
}

.upload__input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-body);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  box-sizing: border-box;
}

.upload__input:focus {
  outline: none;
  border-color: var(--accent);
}

.upload__input--textarea {
  resize: vertical;
  min-height: 60px;
}

/* Upload Status */
.upload__status {
  padding: 10px;
  border-radius: 4px;
  margin-top: 10px;
  display: none;
  text-align: center;
}

.upload__status--success {
  background: rgba(42, 165, 42, 0.2);
  color: #2aa52a;
  display: block;
}

.upload__status--error {
  background: rgba(165, 42, 42, 0.2);
  color: #a52a2a;
  display: block;
}

/* Lightbox Modal */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.lightbox-overlay.open {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.lightbox-close {
  position: absolute;
  top: 15px;
  left: 15px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.lightbox-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.lightbox-media {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 65vh;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.lightbox-media-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-zoom-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.lightbox-media img,
.lightbox-media video {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.lightbox-corner-download {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 10;
}

.lightbox-media-wrapper:hover .lightbox-corner-download {
  opacity: 1;
}

.lightbox-corner-download:hover {
  background: rgba(165, 42, 64, 0.8);
}

.lightbox-zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  padding: 10px 15px;
  border-radius: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 20;
}

.lightbox-zoom-controls button {
  background: var(--bordeaux);
  color: var(--accent);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.lightbox-zoom-controls button:hover {
  background: var(--bordeaux-dark);
}

.lightbox-zoom-controls span {
  color: white;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  min-width: 50px;
  text-align: center;
}

.lightbox-info {
  padding: 20px;
  border-top: 1px solid var(--border-subtle);
}

.lightbox-uploader {
  margin-bottom: 15px;
  color: var(--text-body);
  font-size: 0.95rem;
}

.lightbox-versions {
  margin-top: 15px;
}

.lightbox-versions h4 {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: var(--text-headline);
}

.version-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

.version-item:last-child {
  border: none;
}

.version-label {
  font-weight: 600;
  color: var(--text-headline);
}

.version-size {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.version-download {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}

.version-download:hover {
  text-decoration: underline;
}

/* Lightbox Navigation */
.lightbox-nav {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.lightbox-nav-btn {
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  padding: 15px 20px;
  cursor: pointer;
  font-size: 20px;
  pointer-events: auto;
  transition: background 0.3s;
}

.lightbox-nav-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Download Modal */
.download-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.download-modal-overlay.open {
  display: flex;
}

.download-modal-content {
  position: relative;
  max-width: 600px;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 30px;
  border: 1px solid var(--border-subtle);
}

.download-modal-content h2 {
  color: var(--text-headline);
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.download-modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.download-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
}

.download-tier {
  background: var(--bg-primary);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  text-align: center;
}

.download-tier h3 {
  color: var(--text-headline);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.download-tier-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.download-tier-btn {
  width: 100%;
  padding: 8px;
  background: var(--bordeaux);
  color: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.3s;
}

.download-tier-btn:hover {
  background: var(--bordeaux-dark);
}

/* Responsive */
@media (max-width: 768px) {
  .gallery-header {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
    justify-content: center;
  }

  .btn--download {
    width: 100%;
  }

  .lightbox-content {
    max-width: 95%;
    max-height: 85vh;
  }

  .lightbox-media {
    height: 60vh;
  }

  .download-modal-content {
    max-width: 90%;
  }

  .gallery-header > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  .grid-size-toggle {
    width: 100%;
    justify-content: center;
  }

  .btn--download {
    width: 100%;
  }

  .lightbox-zoom-controls {
    bottom: 10px;
    padding: 8px 12px;
  }

  .lightbox-zoom-controls button {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .lightbox-corner-download {
    width: 32px;
    height: 32px;
    font-size: 16px;
    top: 8px;
    right: 8px;
  }
}
