/* ============================================================
   Silva Home App — Gallery Lightbox
   Clean, modern image viewer with perfect centering
   ============================================================ */

.sha-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  animation: sha-gallery-fade-in 0.3s ease forwards;
}

@keyframes sha-gallery-fade-in {
  to { opacity: 1; }
}

/* ── Header: Close button + Counter ──────────────────────── */
.sha-gallery-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
  background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, transparent 100%);
}

.sha-gallery-counter {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.5px;
}

.sha-gallery-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.sha-gallery-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

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

/* ── Main Image Container (perfectly centered) ───────────── */
.sha-gallery-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 20px;
  position: relative;
}

.sha-gallery-image {
  max-width: 90vw;
  max-height: calc(100vh - 240px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  opacity: 0;
  animation: sha-gallery-image-in 0.3s ease 0.1s forwards;
}

@keyframes sha-gallery-image-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.sha-gallery-image.sha-gallery-image--fade {
  animation: sha-gallery-image-fade 0.2s ease;
}

@keyframes sha-gallery-image-fade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Navigation Arrows (PERFECTLY CENTERED) ──────────────── */
.sha-gallery-nav {
  position: absolute;
  top: 53%;
  transform: translateY(-50%);
  z-index: 20;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.sha-gallery-nav:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-50%) scale(1.08);
}

.sha-gallery-nav:active {
  transform: translateY(-50%) scale(0.96);
}

.sha-gallery-nav--prev {
  left: 20px;
}

.sha-gallery-nav--next {
  right: 20px;
}

.sha-gallery-nav[hidden] {
  display: none;
}

/* Desktop: larger arrows */
@media (min-width: 768px) {
  .sha-gallery-nav {
    width: 64px;
    height: 64px;
    font-size: 32px;
  }

  .sha-gallery-nav--prev {
    left: 30px;
  }

  .sha-gallery-nav--next {
    right: 30px;
  }
}

/* ── Footer: Thumbnails + Select Button ──────────────────── */
.sha-gallery-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: linear-gradient(0deg, rgba(0,0,0,0.6) 0%, transparent 100%);
  z-index: 10;
}

.sha-gallery-thumbnails {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  max-width: 90%;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}

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

.sha-gallery-thumbnails::-webkit-scrollbar-track {
  background: transparent;
}

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

.sha-gallery-thumbnail {
  width: 70px;
  height: 70px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  opacity: 0.5;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sha-gallery-thumbnail:hover {
  opacity: 0.8;
  transform: scale(1.05);
}

.sha-gallery-thumbnail.is-active {
  border-color: #fff;
  opacity: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.sha-gallery-select-btn {
  min-width: 200px;
  padding: 14px 28px;
  background: linear-gradient(180deg, #3f8746, #2f6d39);
  color: #fff;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(47, 109, 57, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sha-gallery-select-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(47, 109, 57, 0.5);
}

.sha-gallery-select-btn:active {
  transform: translateY(0);
}

.sha-gallery-select-btn[hidden] {
  display: none;
}

/* ── Mobile optimizations ─────────────────────────────────── */
@media (max-width: 767px) {
  .sha-gallery-header {
    height: 50px;
    padding: 0 12px;
  }

  .sha-gallery-counter {
    font-size: 13px;
  }

  .sha-gallery-close {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .sha-gallery-main {
    padding: 60px 12px 12px;
  }

  .sha-gallery-image {
    max-width: 95vw;
    max-height: calc(100vh - 200px);
  }

  .sha-gallery-nav {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .sha-gallery-nav--prev {
    left: 12px;
  }

  .sha-gallery-nav--next {
    right: 12px;
  }

  .sha-gallery-footer {
    padding: 12px;
    gap: 12px;
  }

  .sha-gallery-thumbnail {
    width: 60px;
    height: 60px;
  }

  .sha-gallery-select-btn {
    min-width: 160px;
    padding: 12px 24px;
    font-size: 14px;
  }
}

/* ── Keyboard navigation hint ─────────────────────────────── */
@media (min-width: 1024px) {
  .sha-gallery-nav::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0);
    transition: border-color 0.2s ease;
  }

  .sha-gallery-nav:focus-visible::after {
    border-color: rgba(255, 255, 255, 0.6);
  }
}
