/**
 * Gallery Styles for Travelgram
 * 
 * This file contains styles for the photo gallery page including:
 * - Filter controls and dropdowns
 * - Responsive grid layout for images
 * - Modal lightbox with navigation
 * - Hover effects and transitions
 * - Touch/swipe support for mobile
 * - Loading states and animations
 * 
 * @author Admir Bjelic
 * @version 1.0
 */

/* Page Header - Stories Style */
.page-header {
  text-align: center;
  margin-bottom: 4rem;
  padding-bottom: 2rem;
}

.page-header h1 {
  font-size: 3.5rem;
  font-weight: 300;
  margin-bottom: 1rem;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.page-header p {
  font-size: 1.3rem;
  color: #666;
  font-weight: 300;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Responsive Page Header */
@media (width <= 768px) {
  .page-header h1 {
    font-size: 2.5rem;
  }

  .page-header p {
    font-size: 1.1rem;
  }
}

@media (width <= 480px) {
  .page-header {
    margin-bottom: 2rem;
  }

  .page-header h1 {
    font-size: 2rem;
  }
}

/* Dark Mode Page Header */
[data-theme="dark"] .page-header h1 {
  color: var(--primary-dark);
}

[data-theme="dark"] .page-header p {
  color: #a0a0a0;
}

/* Gallery Container - Centered with max width */
.gallery-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Filter Bar */
.gallery-filters {
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group label {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
}

.filter-select {
  padding: 0.5rem;
  border: 2px solid #e0e0e0;
  border-radius: 4px;
  background: white;
  font-family: inherit;
  transition: border-color 0.2s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Clear Filters Button */
#clear-gallery-filters {
  margin-left: auto;
  align-self: center;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgb(0 0 0 / 10%);
  cursor: pointer;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
  aspect-ratio: 4/3;
}

.gallery-item:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgb(0 0 0 / 15%);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover img {
  transform: scale(1.1);
}

/* Overlay on hover */
.gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgb(0 0 0 / 80%));
  color: white;
  padding: 1rem;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
  transform: translateY(0);
}

.gallery-overlay h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: white !important;
}

.gallery-overlay p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.9;
  color: white !important;
}

.gallery-tags {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.gallery-tag {
  background: rgb(255 255 255 / 20%);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  border: 1px solid rgb(255 255 255 / 10%);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgb(0 0 0 / 90%);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgb(0 0 0 / 30%);
}

.modal-caption {
  margin-top: 1rem;
  color: white;
  text-align: center;
  max-width: 600px;
}

.modal-caption h3 {
  color: white;
  margin-bottom: 0.5rem;
}

.modal-caption p {
  margin: 0;
  opacity: 0.9;
  line-height: 1.5;
}

/* Modal Navigation */
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgb(255 255 255 / 20%);
  border: none;
  color: white;
  font-size: 2rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-nav:hover {
  background: rgb(255 255 255 / 30%);
}

.modal-nav.prev {
  left: 20px;
}

.modal-nav.next {
  right: 20px;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgb(255 255 255 / 20%);
  border: none;
  color: white;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgb(255 255 255 / 30%);
}

/* Loading State */
.gallery-loading {
  text-align: center;
  padding: 2rem;
  color: white;
  background: rgb(0 0 0 / 80%);
  border-radius: 8px;
  margin: 1rem 0;
}

/* Responsive Design */
@media (width <= 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
  }

  .gallery-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    justify-content: space-between;
  }

  #clear-gallery-filters {
    margin-left: 0;
    margin-top: 1rem;
    align-self: stretch;
  }

  .modal-nav {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .modal-nav.prev {
    left: 10px;
  }

  .modal-nav.next {
    right: 10px;
  }

  .modal-close {
    top: 10px;
    right: 10px;
  }
}

@media (width <= 480px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-item {
    aspect-ratio: 3/2;
  }

  .modal-content {
    max-width: 95vw;
  }

  .modal-caption {
    padding: 0 1rem;
  }
}

/* Lazy Loading */
.gallery-item img.loaded {
  opacity: 1;
}

.gallery-image {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-image.loaded {
  opacity: 1;
}

/* Pagination Styles */
.gallery-pagination {
  display: flex;
  justify-content: center;
  margin: 2rem 0;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pagination-btn {
  padding: 0.5rem 1rem;
  border: 2px solid #e0e0e0;
  background: white;
  color: var(--primary);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  min-width: 40px;
  text-align: center;
}

.pagination-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.pagination-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

.pagination-btn:disabled:hover {
  background: white;
  color: var(--primary);
  border-color: #e0e0e0;
}

.pagination-ellipsis {
  padding: 0.5rem;
  color: #666;
  font-weight: 600;
}

/* Dark Mode Pagination */
[data-theme="dark"] .pagination-btn {
  background: var(--card-bg-dark);
  border-color: var(--border-dark);
  color: var(--text-dark);
}

[data-theme="dark"] .pagination-btn:hover {
  background: var(--primary-dark);
  color: white;
  border-color: var(--primary-dark);
}

[data-theme="dark"] .pagination-btn.active {
  background: var(--primary-dark);
  color: white;
  border-color: var(--primary-dark);
}

[data-theme="dark"] .pagination-btn:disabled:hover {
  background: var(--card-bg-dark);
  color: var(--text-dark);
  border-color: var(--border-dark);
}

[data-theme="dark"] .pagination-ellipsis {
  color: #a0a0a0;
}

/* Responsive Pagination */
@media (width <= 768px) {
  .pagination {
    gap: 0.25rem;
  }

  .pagination-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    min-width: 35px;
  }

  .pagination-ellipsis {
    padding: 0.4rem;
  }
}

@media (width <= 480px) {
  .pagination-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    min-width: 30px;
  }

  .pagination-ellipsis {
    padding: 0.3rem;
    font-size: 0.8rem;
  }
}

/* Smooth animations */
.gallery-item,
.modal,
.modal-nav,
.modal-close {
  will-change: transform, opacity;
}

/* Dark Mode Styles for Gallery */
[data-theme="dark"] .filter-group label {
  color: var(--primary-dark);
}

[data-theme="dark"] .filter-select {
  background: var(--card-bg-dark);
  border-color: var(--border-dark);
  color: var(--text-dark);
}

[data-theme="dark"] .filter-select:focus {
  border-color: var(--primary-dark);
}

[data-theme="dark"] .gallery-loading {
  color: white;
  background: rgb(0 0 0 / 90%);
}

[data-theme="dark"] .gallery-item {
  box-shadow: var(--shadow-dark);
}

[data-theme="dark"] .gallery-item:hover {
  box-shadow: 0 8px 24px rgb(0 0 0 / 40%);
}
