/* Media Gallery Styles */

body {
  margin: 0;
  padding: 0;
  padding-top: 70px; /* Account for fixed navbar */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: rgb(40, 40, 40); /* Match content card background */
  min-height: 100vh;
  color: white;
  overflow-x: hidden; /* Prevent horizontal scroll */
}

.gallery-wrapper {
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
  max-width: 1560px;
  min-height: 100vh;
  box-sizing: border-box;
}

.gallery-wrapper .tab-hero {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* Gallery Header */

.gallery-header {
  text-align: center;
  margin-bottom: 2rem;
}

.gallery-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
}

.gallery-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.gallery-btn.primary {
  background: linear-gradient(135deg, #6c47a6 0%, #946fe3 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(108, 71, 166, 0.4);
}

.gallery-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 71, 166, 0.6);
}

.gallery-search {
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.gallery-search input {
  background: transparent;
  border: none;
  color: white;
  padding: 0.5rem;
  font-size: 0.95rem;
  outline: none;
  min-width: 200px;
}

.gallery-search input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.gallery-search button {
  background: rgba(108, 71, 166, 0.2);
  border: none;
  color: #946fe3;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.gallery-search button:hover {
  background: rgba(108, 71, 166, 0.3);
}

/* Gallery Controls */

.gallery-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.sort-options {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sort-options label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
}

.sort-options select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
}

.sort-options select option {
  background: #1a0933;
}

.view-options {
  display: flex;
  gap: 0.5rem;
}

.view-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.view-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.view-btn.active {
  background: #6c47a6;
  border-color: #6c47a6;
}

/* Loading State */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #6c47a6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state p {
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}

/* Gallery Grid */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
}

.gallery-grid.masonry-view {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.gallery-grid.masonry-view .gallery-item-image {
  aspect-ratio: auto;
  height: 0;
  padding-top: 100%; /* Square aspect ratio for masonry */
}

.gallery-grid.masonry-view .gallery-item {
  border-radius: 8px;
}

.gallery-item {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.3s ease;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
  border-color: rgba(108, 71, 166, 0.5);
}

.gallery-item-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.gallery-item-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-item-image img {
  transform: scale(1.1);
}

.gallery-item-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.view-btn-overlay {
  background: rgba(108, 71, 166, 0.9);
  border: none;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.view-btn-overlay:hover {
  background: #6c47a6;
  transform: scale(1.05);
}

.gallery-item-info {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-item-info .uploader {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #946fe3;
  font-weight: 600;
  text-transform: capitalize;
}

.image-title {
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0 0.75rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Masonry view adjustments */
.gallery-grid.masonry-view .gallery-item-info {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
}

.gallery-grid.masonry-view .image-title {
  margin: 0;
  padding: 0;
  order: 2;
}

.gallery-grid.masonry-view .uploader {
  order: 1;
}

.gallery-grid.masonry-view .upload-date {
  order: 3;
}

.uploader i {
  color: #946fe3;
}

.upload-date {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
}

/* Empty State */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-state i {
  font-size: 4rem;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 1.5rem;
}

.empty-state h2 {
  color: white;
  margin: 0 0 0.5rem 0;
  font-size: 1.8rem;
}

.empty-state p {
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 2rem 0;
  font-size: 1rem;
}

/* Load More Container */

.load-more-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 3rem 0;
  padding: 2rem;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  background: linear-gradient(135deg, #6c47a6 0%, #946fe3 100%);
  border: none;
  border-radius: 50px;
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(108, 71, 166, 0.4);
}

.load-more-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(108, 71, 166, 0.6);
}

.load-more-btn:active {
  transform: translateY(-1px);
}

.load-more-btn i {
  font-size: 1.2rem;
}

.load-more-info {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  margin: 0;
  text-align: center;
}

.load-more-info span {
  color: #946fe3;
  font-weight: 600;
}

/* Pagination (kept for compatibility but hidden) */

.pagination {
  display: none !important;
}

.page-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-btn:hover:not(:disabled) {
  background: rgba(108, 71, 166, 0.2);
  border-color: #6c47a6;
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-numbers {
  display: flex;
  gap: 0.5rem;
}

.page-number {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 45px;
}

.page-number:hover {
  background: rgba(255, 255, 255, 0.15);
}

.page-number.active {
  background: #6c47a6;
  border-color: #6c47a6;
}

/* Lightbox */

.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 20000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.lightbox-close {
  position: absolute;
  top: 2rem;
  right: 2rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 2rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 20001;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 20001;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-nav.prev {
  left: 2rem;
}

.lightbox-nav.next {
  right: 2rem;
}

.lightbox-content {
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 20001;
}

.lightbox-content img {
  max-width: 100%;
  max-height: calc(90vh - 150px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-info {
  background: rgba(40, 40, 40, 0.95);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  min-width: 400px;
  max-height: 35vh;
  overflow-y: auto;
}

.uploader-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.uploader-name {
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: capitalize;
  white-space: nowrap;
}

.upload-date {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  white-space: nowrap;
}

.lightbox-title-desc {
  width: 100%;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.lightbox-title {
  color: white;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.75rem 0;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.lightbox-description {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  line-height: 1.7;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-height: min(250px, 30vh);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.lightbox-description::-webkit-scrollbar {
  width: 6px;
}

.lightbox-description::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.lightbox-description::-webkit-scrollbar-thumb {
  background: rgba(148, 111, 227, 0.5);
  border-radius: 3px;
}

.lightbox-description::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 111, 227, 0.7);
}

.lightbox-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.action-btn {
  background: rgba(108, 71, 166, 0.2);
  border: 1px solid rgba(108, 71, 166, 0.4);
  color: #946fe3;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.1rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background: rgba(108, 71, 166, 0.3);
  transform: scale(1.1);
}

/* Error Message */

.error-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
}

.error-message i {
  font-size: 2rem;
  color: #ed4245;
  margin-bottom: 1rem;
}

.error-message p {
  color: white;
  font-size: 1.2rem;
  margin: 1rem 0 2rem 0;
}

/* Mobile Responsive */

@media (max-width: 968px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .gallery-grid.masonry-view {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (max-width: 768px) {
  .gallery-wrapper {
    padding: 1rem;
    max-width: 100%;
  }
  
  .gallery-header h1 {
    font-size: 1.8rem;
  }
  
  .gallery-actions {
    flex-direction: row;
    width: 100%;
    gap: 0.5rem;
  }
  
  .gallery-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }
  
  .gallery-search {
    width: 100%;
  }
  
  .gallery-search input {
    min-width: auto;
    flex: 1;
  }
  
  .gallery-controls {
    flex-direction: row;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem;
  }
  
  .sort-options {
    flex: 1;
    min-width: 150px;
  }
  
  .view-options {
    flex-shrink: 0;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
  
  .lightbox-nav {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
  
  .lightbox-nav.prev {
    left: 1rem;
  }
  
  .lightbox-nav.next {
    right: 1rem;
  }
  
  .lightbox-close {
    top: 1rem;
    right: 1rem;
    width: 45px;
    height: 45px;
  }
  
  .lightbox-info {
    min-width: auto;
    width: 95%;
    padding: 0.5rem 0.75rem;
    flex-direction: row;
    gap: 0.75rem;
    align-items: center;
  }
  
  .lightbox-title {
    font-size: 1.2rem;
  }
  
  .lightbox-description {
    font-size: 0.9rem;
    max-height: min(150px, 25vh);
  }
  
  .lightbox-content img {
    max-height: calc(85vh - 180px);
  }
  
  .pagination {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .gallery-wrapper {
    padding: 0.5rem;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .gallery-header {
    padding: 1rem;
  }
  
  .gallery-header h1 {
    font-size: 1.5rem;
  }
  
  .gallery-actions {
    flex-direction: column;
  }
  
  .gallery-btn {
    width: 100%;
  }
  
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .gallery-grid.masonry-view {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  
  .gallery-grid.masonry-view .gallery-item-image {
    padding-top: 100%;
  }
  
  .image-title {
    font-size: 0.9rem;
    padding: 0 0.5rem;
  }
  
  .lightbox-content {
    max-width: 95%;
    max-height: 95vh;
  }
  
  .lightbox-content img {
    max-height: calc(75vh - 150px);
  }
  
  .lightbox-info {
    width: 100%;
    padding: 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    max-height: 30vh;
  }
  
  .lightbox-title {
    font-size: 1.1rem;
  }
  
  .lightbox-description {
    font-size: 0.85rem;
    max-height: min(120px, 20vh);
  }
  
  .lightbox-nav {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
  
  .lightbox-nav.prev {
    left: 0.5rem;
  }
  
  .lightbox-nav.next {
    right: 0.5rem;
  }
  
  .lightbox-close {
    top: 0.5rem;
    right: 0.5rem;
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
  }
  
  .action-btn {
    padding: 0.6rem;
    font-size: 0.9rem;
    width: 40px;
    height: 40px;
  }
  
  .uploader-info {
    gap: 0.15rem;
  }
  
  .uploader-name {
    font-size: 0.9rem;
  }
  
  .upload-date {
    font-size: 0.75rem;
  }
  
  .lightbox-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .action-btn {
    width: 36px;
    height: 36px;
  }
}
