/* =========================================================
   Image Gallery Viewer – CSS
   Supports:
   - Equal image sizing
   - Centered nav buttons
   - Smooth transforms for zoom/rotate
   - Pinch zoom gestures (touch-action: none on stage)
   - Tap-to-hide UI (topbar + nav buttons)
   - LTR isolated (safe for RTL app)
   ========================================================= */

body.no-scroll {
  overflow: hidden;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1055;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-viewer-inner {
  position: relative;
  width: 100%;
  height: 100%;
  direction: ltr;
  display: flex;
  flex-direction: column;
}

.iv-topbar {
  height: 56px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;

  transition: opacity 160ms ease;
}

.iv-topbar-spacer {
  flex: 1;
}

.iv-btn {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: inherit;
  padding: 6px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
}

.iv-btn .material-icons {
  font-size: 22px;
}

.iv-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

/* IMPORTANT: allow us to fully handle swipe+pinch ourselves */
.iv-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;

  touch-action: none;
}

.iv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;

  width: 44px;
  height: 44px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0, 0, 0, 0.45);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;

  user-select: none;

  transition: opacity 160ms ease;
}

.iv-nav:hover {
  background: rgba(0, 0, 0, 0.65);
}

.iv-nav--prev {
  left: 12px;
}

.iv-nav--next {
  right: 12px;
}

.iv-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.iv-track {
  height: 100%;
  display: flex;
  will-change: transform;
}

.iv-slide {
  height: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iv-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;

  user-select: none;
  pointer-events: none;

  -webkit-user-drag: none;

  will-change: transform;
  transition: transform 140ms ease;
}

/* Used during image swap/reset to prevent flashing */
.iv-img.iv-img--noanim {
  transition: none !important;
}

/* Tap-to-hide UI: fade out topbar + nav buttons */
.image-viewer.iv-ui-hidden .iv-topbar,
.image-viewer.iv-ui-hidden .iv-nav {
  opacity: 0;
  pointer-events: none;
}

/* Bottom sheet (optional info) */
.iv-bottom-sheet {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  background: #fff;
  z-index: 1060;
  max-height: 40vh;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  overflow: hidden;
}

.iv-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}

.iv-sheet-title {
  font-weight: 600;
}

.iv-sheet-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.iv-sheet-content {
  padding: 16px;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .iv-topbar {
    height: 52px;
  }

  .iv-btn {
    min-width: 38px;
    height: 38px;
  }

  .iv-nav {
    width: 40px;
    height: 40px;
  }
}
