/**
 * Gallery Styles – Fotogalerie mit Lightbox
 * Mobile-First Design für Remote-Gutachten
 */


/* ========================================
   GALLERY WRAPPER & CONTAINER
   ======================================== */

.gallery-wrapper {
  width: 100%;
  position: relative;
}


/* ========================================
   EMPTY STATE
   ======================================== */

.gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl) var(--spacing-md);
  text-align: center;
  color: var(--color-text-secondary);
  min-height: 100px;
}

.gallery-empty svg {
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.gallery-empty-text {
  font-size: var(--font-size-sm);
  margin: 0;
  color: var(--color-text-tertiary);
}

.gallery-empty.hidden {
  display: none;
}


/* ========================================
   THUMBNAIL STRIP
   ======================================== */

.gallery-strip {
  width: 100%;
  padding: var(--spacing-sm);
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  overflow: hidden;
}

.gallery-strip.hidden {
  display: none;
}

.gallery-thumbnails {
  display: flex;
  gap: var(--spacing-sm);
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: var(--spacing-xs);
  scroll-behavior: smooth;

  /* Custom Scrollbar für bessere UX */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-light) var(--color-bg-primary);
}

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

.gallery-thumbnails::-webkit-scrollbar-track {
  background: var(--color-bg-primary);
  border-radius: var(--radius-sm);
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
  background: var(--color-border-light);
  border-radius: var(--radius-sm);
}

.gallery-thumbnails::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}


/* ========================================
   THUMBNAILS
   ======================================== */

.gallery-thumbnail {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  background: var(--color-bg-tertiary);
}

.gallery-thumbnail:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.gallery-thumbnail:active {
  transform: scale(0.98);
}

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

/* Active State (wenn in Lightbox geöffnet) */
.gallery-thumbnail.active {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}


/* ========================================
   THUMBNAIL DELETE BUTTON
   ======================================== */

.thumbnail-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: var(--color-text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}

.gallery-thumbnail:hover .thumbnail-delete {
  opacity: 1;
}

.thumbnail-delete:hover {
  background: var(--color-error);
}

.thumbnail-delete:active {
  transform: scale(0.9);
}

.thumbnail-delete svg {
  width: 12px;
  height: 12px;
}


/* ========================================
   LIGHTBOX
   ======================================== */

.gallery-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  padding-top: max(var(--spacing-md), var(--safe-area-inset-top));
  padding-bottom: max(var(--spacing-md), var(--safe-area-inset-bottom));
}

.gallery-lightbox.hidden {
  display: none;
}


/* ========================================
   LIGHTBOX OVERLAY
   ======================================== */

.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-overlay-dark);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--transition-base);
}

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


/* ========================================
   LIGHTBOX CONTENT
   ======================================== */

.lightbox-content {
  position: relative;
  z-index: calc(var(--z-modal) + 1);
  width: 100%;
  max-width: 900px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: scaleIn var(--transition-base) var(--easing-smooth);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}


/* ========================================
   LIGHTBOX CLOSE BUTTON
   ======================================== */

.lightbox-close {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  z-index: calc(var(--z-modal) + 2);
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: var(--color-text-primary);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.lightbox-close:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.05);
}

.lightbox-close:active {
  transform: scale(0.95);
}

.lightbox-close svg {
  width: 24px;
  height: 24px;
}


/* ========================================
   LIGHTBOX IMAGE
   ======================================== */

.lightbox-image-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-video-bg);
  min-height: 300px;
  max-height: 60vh;
  overflow: hidden;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}


/* ========================================
   LIGHTBOX METADATA
   ======================================== */

.lightbox-metadata {
  padding: var(--spacing-md);
  background: var(--color-bg-primary);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.metadata-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  gap: var(--spacing-md);
}

.metadata-label {
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-medium);
  flex-shrink: 0;
}

.metadata-value {
  color: var(--color-text-primary);
  text-align: right;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ========================================
   LIGHTBOX ACTIONS
   ======================================== */

.lightbox-actions {
  padding: var(--spacing-md);
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: center;
  gap: var(--spacing-md);
}

.lightbox-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  min-height: var(--touch-target-min);
}

.btn-delete {
  background: var(--color-error);
  color: var(--color-text-primary);
}

.btn-delete:hover {
  background: var(--color-error-hover);
}

.btn-delete:active {
  transform: scale(0.98);
}

.lightbox-btn svg {
  width: 20px;
  height: 20px;
}


/* ========================================
   RESPONSIVE: TABLET & DESKTOP
   ======================================== */

@media (min-width: 768px) {
  .lightbox-content {
    max-width: 800px;
  }

  .lightbox-image-wrapper {
    max-height: 70vh;
  }

  .metadata-row {
    font-size: var(--font-size-base);
  }

  .metadata-value {
    font-size: var(--font-size-sm);
  }

  /* Thumbnails größer auf Desktop */
  .gallery-thumbnail {
    width: 72px;
    height: 72px;
  }
}

@media (min-width: 1024px) {
  .lightbox-content {
    max-width: 900px;
  }

  .lightbox-image-wrapper {
    max-height: 75vh;
  }
}


/* ========================================
   CO-VIEWING OVERLAY
   ======================================== */

.co-viewing-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--z-modal) + 10); /* Über allem */
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base) var(--easing-smooth);

  /* Safe Areas für iOS */
  padding-top: var(--safe-area-inset-top);
  padding-bottom: var(--safe-area-inset-bottom);
  padding-left: var(--safe-area-inset-left);
  padding-right: var(--safe-area-inset-right);
}

.co-viewing-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.co-viewing-photo {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity var(--transition-base) var(--easing-smooth),
              transform var(--transition-base) var(--easing-smooth);
}

.co-viewing-overlay.active .co-viewing-photo {
  opacity: 1;
  transform: scale(1);
}

.co-viewing-close-hint {
  position: absolute;
  bottom: var(--spacing-xl);
  left: 50%;
  transform: translateX(-50%);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: rgba(0, 0, 0, 0.6);
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.co-viewing-close-hint svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}


/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  .lightbox-overlay,
  .lightbox-content {
    animation: none;
  }

  .gallery-thumbnail,
  .lightbox-close,
  .lightbox-btn {
    transition: none;
  }

  .gallery-thumbnails {
    scroll-behavior: auto;
  }

  .co-viewing-overlay,
  .co-viewing-photo {
    transition: none;
  }
}
