/* ============================================
   Custom Lightbox - Fullscreen mit Zoom/Rotate/Metadaten
   ============================================ */

body.lb-disable-scrolling {
  overflow: hidden;
}

/* --- Overlay --- */
.lightboxOverlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: rgba(0, 0, 0, 0.92);
  display: none;
}

/* --- Lightbox Container --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  flex-direction: column;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox.lb-active {
  display: flex;
}

/* --- Toolbar (oben) --- */
.lb-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
  z-index: 10;
  flex-shrink: 0;
  position: relative;
}

.lb-toolbar button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  min-width: 44px;
  min-height: 44px;
  color: white;
}

.lb-toolbar button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.lb-toolbar button:active {
  background: rgba(255, 255, 255, 0.25);
}

.lb-toolbar button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: white;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-toolbar button.lb-btn-close svg {
  width: 28px;
  height: 28px;
}

.lb-toolbar .lb-zoom-level {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-family: sans-serif;
  min-width: 36px;
  text-align: center;
  pointer-events: none;
}

.lb-toolbar button.lb-active-btn {
  background: rgba(255, 255, 255, 0.2);
}

/* --- Bild-Bereich (Mitte) --- */
.lb-image-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.lb-image-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
  will-change: transform;
  transform-origin: center center;
}

.lb-image-wrapper.lb-no-transition {
  transition: none;
}

.lb-image {
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 130px);
  width: auto;
  height: auto;
  display: block;
  border-radius: 2px;
  pointer-events: none;
}

/* Bei Rotation 90/270: Bild-Max-Dimensionen tauschen */
.lb-image-wrapper.lb-rotated-90 .lb-image,
.lb-image-wrapper.lb-rotated-270 .lb-image {
  max-width: calc(100vh - 130px);
  max-height: calc(100vw - 24px);
}

/* --- Ladeanimation --- */
.lb-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
}

.lb-loader.lb-visible {
  display: block;
}

.lb-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: lb-spin 0.8s linear infinite;
}

@keyframes lb-spin {
  to { transform: rotate(360deg); }
}

/* --- Navigation Pfeile --- */
.lb-nav-prev,
.lb-nav-next {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
  padding: 0 8px;
}

.lb-image-area:hover .lb-nav-prev,
.lb-image-area:hover .lb-nav-next,
.lb-nav-prev.lb-touch-visible,
.lb-nav-next.lb-touch-visible {
  opacity: 1;
}

.lb-nav-prev {
  left: 0;
  width: 60px;
}

.lb-nav-next {
  right: 0;
  width: 60px;
}

.lb-nav-prev svg,
.lb-nav-next svg {
  width: 36px;
  height: 36px;
  fill: none;
  stroke: white;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

.lb-nav-prev:hover svg,
.lb-nav-next:hover svg {
  stroke-width: 3;
}

/* Auf Mobilgeraeten immer sichtbar */
@media (hover: none) and (pointer: coarse) {
  .lb-nav-prev,
  .lb-nav-next {
    opacity: 0.7;
    width: 48px;
  }
  .lb-nav-prev svg,
  .lb-nav-next svg {
    width: 28px;
    height: 28px;
  }
}

/* --- Caption Bar (unten) --- */
.lb-caption-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  color: white;
  font-family: sans-serif;
  z-index: 10;
  flex-shrink: 0;
  min-height: 36px;
}

.lb-caption {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  flex: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.lb-number {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  margin-left: 12px;
}

/* --- Metadata Panel (rechts) --- */
.lb-metadata-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 90vw;
  background: rgba(20, 20, 20, 0.95);
  color: white;
  font-family: sans-serif;
  z-index: 15;
  transform: translateX(100%);
  transition: transform 0.35s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
}

.lb-metadata-panel.lb-panel-open {
  transform: translateX(0);
}

.lb-meta-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.lb-meta-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.lb-meta-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.lb-meta-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: white;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Equipment-Bilder */
.lb-meta-equipment {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.lb-equip-item {
  flex: 1;
  text-align: center;
}

.lb-equip-item img {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 6px;
  background: white;
  padding: 8px;
  box-sizing: border-box;
}

.lb-equip-label {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  margin-top: 6px;
  line-height: 1.2;
}

/* EXIF-Tabelle */
.lb-meta-details {
  padding: 16px 20px;
  user-select: text;
  -webkit-user-select: text;
}

.lb-meta-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
}

.lb-meta-label {
  color: rgba(255,255,255,0.5);
  flex-shrink: 0;
  margin-right: 12px;
}

.lb-meta-value {
  text-align: right;
  word-break: break-word;
  color: rgba(255,255,255,0.9);
}

.lb-meta-comment .lb-meta-value {
  text-align: left;
  white-space: pre-wrap;
}

.lb-meta-comment {
  flex-direction: column;
  gap: 4px;
}

.lb-meta-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
  color: rgba(255,255,255,0.5);
  font-size: 14px;
}

.lb-meta-loading .lb-spinner {
  width: 24px;
  height: 24px;
  margin-right: 12px;
}

.lb-meta-empty {
  padding: 40px 20px;
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 14px;
}

/* --- Mobile Anpassungen --- */
@media (max-width: 600px) {
  .lb-toolbar {
    padding: 6px 8px;
    gap: 2px;
  }

  .lb-toolbar button {
    min-width: 40px;
    min-height: 40px;
    padding: 6px;
  }

  .lb-toolbar button svg {
    width: 20px;
    height: 20px;
  }

  .lb-image {
    max-width: 100vw;
    max-height: calc(100vh - 110px);
    border-radius: 0;
  }

  .lb-image-wrapper.lb-rotated-90 .lb-image,
  .lb-image-wrapper.lb-rotated-270 .lb-image {
    max-width: calc(100vh - 110px);
    max-height: 100vw;
  }

  .lb-caption-bar {
    padding: 6px 12px;
  }

  .lb-caption {
    font-size: 13px;
  }

  .lb-metadata-panel {
    width: 100%;
    max-width: 100vw;
  }
}

/* --- Zoom-Cursor --- */
.lb-image-area.lb-zoomed {
  cursor: grab;
}

.lb-image-area.lb-zoomed:active {
  cursor: grabbing;
}

.lb-image-area.lb-zoomed .lb-nav-prev,
.lb-image-area.lb-zoomed .lb-nav-next {
  display: none;
}
