/**
 * AR Edilizia - Gallery Lightbox Modal Styles
 * Modern full-screen lightbox with smooth animations
 *
 * @version 2.0 Enhanced
 * @date October 18, 2025
 */

/* ========================================
   LIGHTBOX MODAL - BASE
   ======================================== */
.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox-modal.active {
  opacity: 1;
  visibility: visible;
}

/* Overlay Background */
.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ========================================
   LIGHTBOX CONTAINER
   ======================================== */
.lightbox-container {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* ========================================
   HEADER - Counter & Close Button
   ======================================== */
.lightbox-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 10;
}

.lightbox-counter {
  font-size: 1rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.5px;
}

.lightbox-current {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

/* ========================================
   CONTENT AREA - Image & Navigation
   ======================================== */
.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 70px 80px;
}

/* Image Wrapper */
.lightbox-image-wrapper {
  position: relative;
  max-width: 90vw;
  max-height: calc(100vh - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-image-wrapper.zoom-active {
  overflow: auto;
  cursor: grab;
}

/* Main Image */
.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: opacity 0.3s ease, transform 0.3s ease;
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.lightbox-image.zoomed {
  transform: scale(2);
  max-width: none;
  max-height: none;
  cursor: grab;
}

.lightbox-image.zoomed:active {
  cursor: grabbing;
}

/* ========================================
   LOADER / SPINNER
   ======================================== */
.lightbox-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.lightbox-loader.active {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   FOOTER - Caption & Actions
   ======================================== */
.lightbox-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
  z-index: 10;
}

.lightbox-caption {
  flex: 1;
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  max-width: 60%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

/* ========================================
   BUTTONS - Unified Styling
   ======================================== */
.lightbox-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.lightbox-btn:active {
  transform: translateY(0);
}

.lightbox-btn:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.lightbox-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* Close Button */
.lightbox-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

/* Navigation Buttons */
.lightbox-prev,
.lightbox-next {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  padding: 0;
}

.lightbox-prev {
  position: absolute;
  left: 2rem;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev:hover,
.lightbox-next:hover {
  transform: translateY(-50%) scale(1.1);
}

/* Action Buttons (Zoom, Download) */
.lightbox-zoom,
.lightbox-download {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  padding: 0;
}

/* ========================================
   GALLERY GRID - Thumbnail Display
   ======================================== */
.project-gallery-grid,
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.gallery-item {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  background: #1e293b;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

.gallery-item:focus {
  outline: 3px solid #0ea5e9;
  outline-offset: 2px;
}

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

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

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablets */
@media (max-width: 1024px) {
  .lightbox-content {
    padding: 70px 60px;
  }

  .lightbox-prev {
    left: 1rem;
  }

  .lightbox-next {
    right: 1rem;
  }

  .project-gallery-grid,
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .lightbox-header {
    padding: 0 1rem;
    height: 60px;
  }

  .lightbox-counter {
    font-size: 0.875rem;
  }

  .lightbox-current {
    font-size: 1.25rem;
  }

  .lightbox-content {
    padding: 60px 20px;
  }

  .lightbox-image-wrapper {
    max-width: 95vw;
    max-height: calc(100vh - 180px);
  }

  .lightbox-footer {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .lightbox-caption {
    max-width: 100%;
    font-size: 0.875rem;
  }

  .lightbox-actions {
    width: 100%;
    justify-content: center;
  }

  /* Navigation buttons - smaller on mobile */
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
  }

  .lightbox-prev {
    left: 0.5rem;
  }

  .lightbox-next {
    right: 0.5rem;
  }

  /* Close button */
  .lightbox-close {
    width: 36px;
    height: 36px;
  }

  /* Gallery grid - 2 columns on mobile */
  .project-gallery-grid,
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .project-gallery-grid,
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .gallery-item {
    aspect-ratio: 16 / 9;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible for keyboard navigation */
.lightbox-btn:focus-visible {
  outline: 3px solid #0ea5e9;
  outline-offset: 3px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .lightbox-modal,
  .lightbox-image,
  .lightbox-btn,
  .gallery-item,
  .gallery-item img {
    transition: none !important;
    animation: none !important;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .lightbox-modal {
    display: none !important;
  }
}

/* ========================================
   THUMBNAIL STRIP
   ======================================== */
.lightbox-thumbnails {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 1200px;
  height: 100px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  border-radius: 12px;
  z-index: 1003;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.3);
}

.lightbox-thumbnails::-webkit-scrollbar {
  height: 6px;
}

.lightbox-thumbnails::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.lightbox-thumbnail {
  flex: 0 0 80px;
  height: 80px;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid transparent;
  transition: all 0.3s ease;
  position: relative;
}

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

.lightbox-thumbnail:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.lightbox-thumbnail.active {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.5);
}

.lightbox-thumbnail.active img {
  transform: scale(1.05);
}

/* Hide thumbnails on smaller screens */
@media (max-width: 768px) {
  .lightbox-thumbnails {
    height: 70px;
    bottom: 70px;
  }

  .lightbox-thumbnail {
    flex: 0 0 60px;
    height: 60px;
  }
}

@media (max-width: 576px) {
  .lightbox-thumbnails {
    display: none; /* Hide on very small screens */
  }
}

/* Improve lightbox layout for bigger screens */
@media (min-width: 1400px) {
  .lightbox-image-wrapper {
    max-width: 90vw;
    max-height: calc(100vh - 220px);
  }

  .lightbox-image {
    max-width: 95%;
    max-height: 82vh;
  }

  .lightbox-content {
    padding: 70px 100px;
  }

  .lightbox-thumbnails {
    max-width: 1400px;
    height: 120px;
    bottom: 100px;
  }

  .lightbox-thumbnail {
    flex: 0 0 100px;
    height: 100px;
  }
}

@media (min-width: 1920px) {
  .lightbox-image-wrapper {
    max-width: 92vw;
    max-height: calc(100vh - 240px);
  }

  .lightbox-image {
    max-width: 100%;
    max-height: 88vh;
  }

  .lightbox-content {
    padding: 80px 120px;
  }

  .lightbox-thumbnails {
    max-width: 1800px;
    height: 140px;
    bottom: 110px;
  }

  .lightbox-thumbnail {
    flex: 0 0 120px;
    height: 120px;
  }

  .lightbox-header,
  .lightbox-footer {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 3rem;
  }
}

@media (min-width: 2560px) {
  .lightbox-image-wrapper {
    max-width: 94vw;
    max-height: calc(100vh - 260px);
  }

  .lightbox-image {
    max-width: 100%;
    max-height: 90vh;
  }

  .lightbox-content {
    padding: 100px 150px;
  }

  .lightbox-thumbnails {
    max-width: 2200px;
    height: 160px;
    bottom: 120px;
    gap: 12px;
  }

  .lightbox-thumbnail {
    flex: 0 0 140px;
    height: 140px;
  }

  .lightbox-header,
  .lightbox-footer {
    max-width: 2200px;
    padding: 0 4rem;
  }

  .lightbox-counter {
    font-size: 1.25rem;
  }

  .lightbox-current {
    font-size: 1.75rem;
  }

  .lightbox-caption {
    font-size: 1.125rem;
  }
}

