/* Gallery Layouts - Scoped to avoid conflicts with header */
:root {
  --primary-color: #FF8C00; /* Orange from SENA */
  --secondary-color: #1a202c;
  --bg-light: #f8f9fa;
  --text-dark: #2d3748;
}

/* Scope all gallery styles to .gallery-container to prevent conflicts */
.gallery-container {
  padding: 2rem 0;
  margin-top: 2rem; /* Add space for header */
}

.gallery-container .gallery-header {
  text-align: center;
  margin-bottom: 3rem;
}

.gallery-container .view-switcher .btn {
  margin: 0 0.5rem;
  border-radius: 20px;
}

.gallery-container .view-switcher .btn.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Gallery Filters */
.gallery-filters {
  text-align: center;
}

.gallery-filters .badge {
  margin: 0.25rem;
  transition: all 0.3s ease;
}

.gallery-filters .badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#shuffle-btn:hover {
  background-color: #28a745 !important;
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#shuffle-btn:disabled {
  background-color: #6c757d !important;
  cursor: not-allowed;
  transform: none;
}

/* Mobile responsive for view switcher */
@media (max-width: 576px) {
  .view-switcher {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 0.25rem;
  }
  
  .view-switcher .btn {
    margin: 0;
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    flex: 1;
    text-align: center;
    min-width: 0;
    border-radius: 15px;
  }
  
  .view-switcher .btn i {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 1rem;
  }
  
  .view-switcher .btn span {
    display: none !important;
  }
}

/* Small mobile devices (extra small) */
@media (max-width: 400px) {
  .view-switcher .btn {
    padding: 0.4rem 0.2rem;
    font-size: 0.7rem;
  }
  
  .view-switcher .btn i {
    font-size: 0.9rem;
  }
}

/* 1. Grid View */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background: white;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px rgba(0,0,0,0.15);
}

.gallery-item img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  display: block;
}

.gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
  color: white;
  padding: 1.5rem 1rem 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

/* 2. Masonry View */
.gallery-masonry {
  column-count: 3;
  column-gap: 1.5rem;
}

@media (max-width: 992px) {
  .gallery-masonry { column-count: 2; }
}

@media (max-width: 576px) {
  .gallery-masonry { column-count: 1; }
}

.gallery-masonry .gallery-item {
  display: inline-block;
  width: 100%;
  margin-bottom: 1.5rem;
}

.gallery-masonry .gallery-item img {
  height: auto; /* Fluid height */
}

/* 3. Coverflow / 3D Perspective View */
.gallery-coverflow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  perspective: 1000px;
}

.gallery-coverflow .gallery-item {
  width: 300px;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.gallery-coverflow .gallery-item:hover {
  transform: scale(1.05) rotateY(0deg) !important; 
  z-index: 10;
}

/* Facts Popup */
.facts-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85); /* Dark semi-transparent */
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease;
}

.facts-popup-overlay.active {
  opacity: 1;
  visibility: visible;
}

.facts-content {
  background: white;
  padding: 3rem;
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.5s ease;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.facts-popup-overlay.active .facts-content {
  transform: translateY(0);
}

.facts-icon {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 1.5rem;
}

.facts-text {
  font-size: 1.5rem;
  line-height: 1.6;
  color: var(--text-dark);
  font-weight: 600;
  margin-bottom: 2rem;
}

.facts-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #a0aec0;
  transition: color 0.3s;
}

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

.facts-progress {
  width: 100%;
  height: 4px;
  background: #edf2f7;
  position: absolute;
  bottom: 0;
  left: 0;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
}

.facts-timer {
  height: 100%;
  background: var(--primary-color);
  width: 100%;
  transition: width 5s linear; /* Should match the JS timer */
}

/* Lightbox */
.lightbox-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.9);
}

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

.lightbox-image {
  max-height: 90vh;
  max-width: 90vw;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  color: white;
  border: none;
  padding: 1rem;
  cursor: pointer;
  font-size: 2rem;
  border-radius: 50%;
  transition: background 0.3s;
  z-index: 10001; /* Same as close button to ensure clickability */
  pointer-events: auto; /* Ensure clickable */
  user-select: none; /* Prevent text selection */
}

.lightbox-nav:hover {
  background: rgba(255,255,255,0.3);
}

.lightbox-prev { 
  left: 20px; 
  z-index: 10002; /* Higher than close button */
}

.lightbox-next { 
  right: 20px; 
  z-index: 10002; /* Higher than close button */
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 3rem;
  cursor: pointer;
  opacity: 0.8;
  z-index: 10001;
}

.lightbox-details {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  color: white;
  padding: 1rem;
  background: rgba(0,0,0,0.5);
}
