/**
 * TwinsRealEstate - Property Gallery Styles
 * Styles for the property image gallery with thumbnails and controls
 */

/* ==========================================================================
   CRITICAL: Prevent horizontal overflow on property detail pages
   This stops the gallery/hero from shifting left when touched
   ========================================================================== */
html:has(.property-gallery),
body:has(.property-gallery) {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  overscroll-behavior-x: none;
}

/* Fallback for browsers that don't support :has() */
.property-detail-page,
body.property-page {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  overscroll-behavior-x: none;
}

/* Property Gallery Section - FULLSCREEN HERO SYSTEM */
/* CRITICAL: Gallery extends under transparent navbar like other hero sections */
.property-gallery-section {
  position: relative !important;
  width: 100% !important;
  max-width: 100vw !important;
  display: block !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  --hero-image-offset-y: 62%;
  --gallery-control-offset: 32px;
  --gallery-control-offset-mobile: 24px;
  min-height: calc(100vh + var(--site-header-height, 56px)) !important;
  min-height: calc(var(--vh, 1vh) * 100 + var(--site-header-height, 56px)) !important;
  min-height: calc(100svh + var(--site-header-height, 56px)) !important;
  height: calc(100vh + var(--site-header-height, 56px)) !important;
  height: calc(var(--vh, 1vh) * 100 + var(--site-header-height, 56px)) !important;
  height: calc(100svh + var(--site-header-height, 56px)) !important;
  max-height: calc(100vh + var(--site-header-height, 56px)) !important;
  max-height: calc(var(--vh, 1vh) * 100 + var(--site-header-height, 56px)) !important;
  max-height: calc(100svh + var(--site-header-height, 56px)) !important;
  margin-top: calc(var(--site-header-height, 56px) * -1) !important;
  /* Negative margin pulls gallery under navbar - same as other hero sections */
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  /* No padding - background should extend under navbar */
  padding-bottom: 0 !important;
  background-color: var(--dark-color, #0b1220);
  /* CRITICAL FIX: Allow vertical scrolling but prevent horizontal scroll */
  overflow-x: hidden !important;
  overflow-y: visible !important;
  /* Changed from overflow: hidden to allow page scrolling */
  box-sizing: border-box !important;
  z-index: 1 !important;
  /* Ensure gallery stays BELOW navbar (navbar is 10000) */
  /* CRITICAL: Allow vertical scrolling for page, prevent horizontal scroll/shift on touch */
  touch-action: pan-y pinch-zoom !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: none;
  overscroll-behavior-y: auto;
  /* Allow vertical overscroll for natural scrolling */
}

/* Gallery Container */
/* CRITICAL: z-index must be LOWER than navbar so navbar covers gallery elements when scrolling */
.property-gallery {
  position: relative !important;
  width: 100%;
  max-width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  background-color: var(--dark-color, #0b1220);
  margin-bottom: 0 !important;
  /* Remove margin to prevent gap */
  z-index: 1;
  /* Low z-index to ensure navbar (z-index: 10000) covers it when scrolling */
  /* CRITICAL FIX: Allow vertical scrolling but prevent horizontal overflow and touch shifting */
  overflow-x: hidden !important;
  overflow-y: visible !important;
  /* Changed from overflow: hidden to allow page scrolling past gallery */
  touch-action: pan-y pinch-zoom !important;
  overscroll-behavior-x: none;
  overscroll-behavior-y: auto;
  -webkit-user-select: none;
  user-select: none;
}

/* Main Gallery */
.gallery-main {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  /* CRITICAL FIX: Allow vertical scrolling but prevent horizontal overflow */
  overflow-x: hidden !important;
  overflow-y: visible !important;
  /* Changed from overflow: hidden to allow page scrolling */
  touch-action: pan-y pinch-zoom;
}

.gallery-main-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.gallery-main-slide.active {
  opacity: 1;
  z-index: 1;
}

/* Skeleton placeholder - prevents white flash during image load */
.gallery-skeleton {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    var(--dark-color, #0b1220) 0%,
    rgba(255,255,255,0.05) 50%,
    var(--dark-color, #0b1220) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  z-index: 0;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.gallery-main-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center var(--hero-image-offset-y, 62%);
  /* CRITICAL FIX: Images are not clickable - only fullscreen button opens modal */
  cursor: default;
  pointer-events: none;
  /* Prevent any click interactions on images */
  user-select: none;
  -webkit-user-select: none;
  /* Smooth fade-in when image loads */
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.gallery-main-image.loaded {
  opacity: 1;
}

/* Thumbnails */
/* CRITICAL: z-index must be LOWER than navbar (10000) so navbar covers it when scrolling */
.gallery-thumbs {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: 96vw;
  z-index: 50 !important;
  /* Performance: Solid overlay instead of backdrop-filter blur (saves 30fps on low-end devices) */
  background-color: rgba(0, 0, 0, 0.75);
  border-radius: 8px;
  padding: 10px;
  box-sizing: border-box;
  /* CRITICAL FIX: Allow horizontal scrolling within thumbnails, but don't block vertical page scroll */
  touch-action: pan-x pan-y;
  /* Allow both horizontal (for thumbnails) and vertical (for page) scrolling */
  pointer-events: auto;
  /* Ensure thumbnails are interactive */
}

.gallery-thumbs-slider {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-color) rgba(255, 255, 255, 0.2);
  padding: 5px 0;
  /* CRITICAL FIX: Allow horizontal scrolling on thumbnails, but don't block vertical page scroll */
  touch-action: pan-x pan-y;
  /* Allow both horizontal (thumbnails) and vertical (page) scrolling */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  /* Prevent horizontal scroll chaining to parent, but allow vertical */
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  /* Allow vertical overscroll for natural page scrolling */
  /* CRITICAL FIX: Ensure thumbnails can be swiped horizontally */
  scroll-snap-type: x mandatory;
  /* Enable snap scrolling for better UX */
  -webkit-scroll-snap-type: x mandatory;
}

/* Snap each thumbnail to center when scrolling */
.gallery-thumb {
  scroll-snap-align: center;
  -webkit-scroll-snap-align: center;
}

.gallery-thumbs-slider::-webkit-scrollbar {
  height: 5px;
}

.gallery-thumbs-slider::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

.gallery-thumbs-slider::-webkit-scrollbar-thumb {
  background-color: var(--accent-color);
  border-radius: 10px;
}

.gallery-thumb {
  flex: 0 0 auto;
  width: 80px;
  height: 60px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  /* CRITICAL FIX: Remove transform from transition to prevent position shifts */
  opacity: 0.7;
  border: 2px solid transparent;
  /* CRITICAL FIX: Optimize touch for tap/click, allow parent to handle scroll */
  touch-action: manipulation;
  /* Prevent double-tap zoom but allow scrolling */
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
  /* Subtle tap highlight for better UX */
  position: relative;
  /* Ensure proper positioning */
  will-change: opacity, border-color;
  /* Optimize for animations */
}

.gallery-thumb:hover {
  opacity: 0.9;
  /* CRITICAL FIX: Use box-shadow instead of transform to avoid position shifts */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.gallery-thumb:active {
  /* CRITICAL FIX: Use opacity instead of transform to prevent position shifts */
  opacity: 0.8;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  /* Visual feedback without position change */
  transition: opacity 0.1s ease, box-shadow 0.1s ease;
}

.gallery-thumb.active {
  opacity: 1;
  border-color: var(--accent-color);
}

.gallery-thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Gallery Controls */
/* CRITICAL: z-index must be LOWER than navbar (10000) so navbar covers it when scrolling */
.gallery-controls {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  z-index: 50 !important;
  /* Lower than navbar (10000) - so navbar covers it when scrolling */
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
}

.gallery-control {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.8);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  /* CRITICAL FIX: Remove transform from transition to prevent position shifts */
  position: relative;
  /* Ensure button maintains position */
  flex-shrink: 0;
  /* Prevent button from shrinking */
  -webkit-tap-highlight-color: transparent;
  /* Remove tap highlight on mobile */
  touch-action: manipulation;
  /* Optimize for tap/click */
  /* CRITICAL FIX: Ensure button doesn't move on click */
  will-change: background-color, box-shadow;
  /* Optimize for animations without layout shifts */
}

.gallery-control:hover {
  background-color: var(--white-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  /* Use box-shadow instead of transform to avoid position shifts */
}

.gallery-control:active {
  /* CRITICAL FIX: Use opacity and box-shadow instead of transform to prevent position shifts */
  opacity: 0.8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  /* Visual feedback without position change */
  transition: opacity 0.1s ease, box-shadow 0.1s ease;
}

.gallery-control:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
  /* Accessibility focus indicator */
}

.gallery-control i {
  font-size: 1.2rem;
  color: var(--dark-color);
}

/* Gallery Status - Position below navbar */
/* CRITICAL: z-index must be LOWER than navbar (10000) so navbar covers it when scrolling */
/* NOTE: Gallery section has margin-top: -56px to pull under navbar, so we must add 2x header height */
.gallery-status,
.property-gallery .gallery-status {
  position: absolute !important;
  top: calc(var(--site-header-height, 56px) * 2 + var(--gallery-control-offset, 24px)) !important;
  /* 2x header height to account for negative margin + padding */
  right: 20px !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  color: white !important;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  z-index: 50 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

/* Fullscreen Button - Position below navbar */
/* CRITICAL: z-index must be LOWER than navbar (10000) so navbar covers it when scrolling */
/* NOTE: Gallery section has margin-top: -56px to pull under navbar, so we must add 2x header height */
.gallery-fullscreen,
.property-gallery .gallery-fullscreen {
  position: absolute !important;
  top: calc(var(--site-header-height, 56px) * 2 + var(--gallery-control-offset, 24px)) !important;
  /* 2x header height to account for negative margin + padding */
  left: 20px !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  color: white !important;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50 !important;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  visibility: visible !important;
  opacity: 1 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

.gallery-fullscreen:hover {
  background-color: rgba(0, 0, 0, 0.6);
  /* Slightly more opaque on hover */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  /* CRITICAL FIX: Use box-shadow instead of transform to prevent position shifts */
}

.gallery-fullscreen:active {
  background-color: rgba(0, 0, 0, 0.7);
  opacity: 0.9;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  /* CRITICAL FIX: Use opacity and box-shadow instead of transform to prevent position shifts */
}

/* Ensure fullscreen button is positioned relative to gallery container */
/* Position below navbar using CSS variable - account for negative margin */
.property-gallery .gallery-fullscreen {
  position: absolute !important;
  top: calc(var(--site-header-height, 56px) * 2 + var(--gallery-control-offset, 24px)) !important;
  /* 2x header height to account for negative margin + padding */
  left: 20px !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

/* Fullscreen Gallery */
.gallery-fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: var(--z-index-modal);
  display: none;
  align-items: center;
  justify-content: center;
}

.gallery-fullscreen-modal.active {
  display: flex;
}

.fullscreen-image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.fullscreen-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 11;
  transition: background-color 0.2s ease;
}

.fullscreen-close:hover {
  background-color: rgba(255, 255, 255, 0.4);
}

.fullscreen-navigation {
  position: absolute;
  width: 100%;
  bottom: 20px;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.fullscreen-nav-button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.fullscreen-nav-button:hover {
  background-color: rgba(255, 255, 255, 0.4);
}

/* Responsive Adjustments */
/* Tablet: Navbar height is still 56px, so maintain desktop positioning */
@media (max-width: 1024px) and (min-width: 769px) {
  .property-gallery-section {
    margin-top: calc(var(--site-header-height, 56px) * -1) !important;
    /* Tablet uses same navbar height as desktop */
  }

  .property-gallery {
    height: 100%;
  }

  /* Tablet: Maintain desktop spacing - account for negative margin */
  .gallery-fullscreen {
    top: calc(var(--site-header-height, 56px) * 2 + var(--gallery-control-offset, 24px)) !important;
    left: 18px !important;
  }

  .gallery-status {
    top: calc(var(--site-header-height, 56px) * 2 + var(--gallery-control-offset, 24px));
    right: 18px;
  }

  /* Tablet: Modal elements */
  .gallery-modal-close {
    top: calc(var(--site-header-height, 56px) + 18px);
    right: 18px;
  }

  .gallery-modal-status {
    top: calc(var(--site-header-height, 56px) + 18px);
    right: 75px;
    /* Slightly closer on tablet */
  }
}

/* Mobile: Navbar height is 50px */
@media (max-width: 768px) {
  .property-gallery-section {
    margin-top: calc(var(--site-header-height, 50px) * -1) !important;
    /* Mobile navbar is 50px - negative margin pulls gallery under it */
    height: calc(100vh + var(--site-header-height, 50px)) !important;
    height: calc(var(--vh, 1vh) * 100 + var(--site-header-height, 50px)) !important;
    min-height: calc(100vh + var(--site-header-height, 50px)) !important;
    min-height: calc(var(--vh, 1vh) * 100 + var(--site-header-height, 50px)) !important;
    --gallery-control-offset: var(--gallery-control-offset-mobile, 20px);
    /* CRITICAL FIX: Ensure page can scroll past gallery on mobile */
    overflow-x: hidden !important;
    overflow-y: visible !important;
    /* Allow vertical scrolling of the page */
    position: relative !important;
    /* Ensure it's in normal document flow for scrolling */
  }

  .property-gallery {
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    /* CRITICAL FIX: Allow page scrolling past gallery */
    overflow-x: hidden !important;
    overflow-y: visible !important;
  }

  .gallery-thumbs {
    width: calc(100% - 20px);
    padding: 8px;
    /* CRITICAL FIX: Ensure thumbnails don't block page scrolling */
    touch-action: pan-x pan-y;
    /* Allow both horizontal (thumbnails) and vertical (page) scrolling */
    pointer-events: auto;
    /* Make sure thumbnails are still interactive */
  }

  .gallery-thumb {
    width: 60px;
    height: 45px;
    /* Ensure thumbnails don't interfere with scrolling */
    touch-action: manipulation;
    /* Optimize touch for tap/click, allow parent to handle scroll */
  }

  .gallery-controls {
    padding: 0 15px;
    /* CRITICAL FIX: Ensure container doesn't shift when buttons are clicked */
    pointer-events: none;
    /* Allow clicks to pass through to buttons */
    touch-action: manipulation;
  }
  
  /* CRITICAL FIX: Re-enable pointer events on buttons */
  .gallery-controls .gallery-control {
    pointer-events: auto;
    /* Buttons are clickable */
  }

  .gallery-control {
    width: 40px;
    height: 40px;
    /* Ensure controls are interactive but don't block scroll */
    touch-action: manipulation;
    /* CRITICAL FIX: Prevent position shifts on mobile */
    position: relative;
    flex-shrink: 0;
    /* CRITICAL FIX: Ensure no transform on active state */
    will-change: background-color, box-shadow, opacity;
  }

  .gallery-control:active {
    /* CRITICAL FIX: Use opacity instead of transform to prevent position shifts */
    opacity: 0.7;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    /* Visual feedback without position change */
  }

  /* CRITICAL FIX: Ensure Book Now button doesn't move on mobile */
  .gallery-book-now {
    /* Maintain position on mobile */
    will-change: box-shadow, background-color, opacity;
    /* CRITICAL FIX: Transform NEVER changes - always stays the same */
    transform: translate(-50%, -50%) !important;
    /* Keep transform consistent - only for centering */
    transform-origin: center center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  .gallery-book-now:hover {
    /* CRITICAL FIX: Transform NEVER changes on hover */
    transform: translate(-50%, -50%) !important;
  }

  .gallery-book-now:active {
    /* CRITICAL FIX: Use opacity instead of transform to prevent position shifts */
    opacity: 0.85;
    box-shadow:
      0 6px 24px rgba(0, 0, 0, 0.35),
      0 0 15px rgba(212, 175, 55, 0.25);
    /* CRITICAL FIX: Transform NEVER changes - always stays the same */
    transform: translate(-50%, -50%) !important;
  }

  .gallery-book-now:focus {
    /* CRITICAL FIX: Transform NEVER changes on focus */
    transform: translate(-50%, -50%) !important;
  }

  /* Mobile: All elements positioned below navbar (50px) - handled in mobile-specific section below */
}

@media (max-width: 576px) {
  .property-gallery {
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    /* CRITICAL FIX: Ensure page can scroll past gallery on small mobile */
    overflow-x: hidden !important;
    overflow-y: visible !important;
  }

  .gallery-thumb {
    width: 50px;
    height: 40px;
    /* Ensure thumbnails don't interfere with scrolling */
    touch-action: manipulation;
  }

  /* CRITICAL FIX: Ensure thumbnails container allows page scrolling */
  .gallery-thumbs {
    touch-action: pan-x pan-y;
    /* Allow both horizontal (thumbnails) and vertical (page) scrolling */
    pointer-events: auto;
  }

  .gallery-thumbs-slider {
    touch-action: pan-x pan-y;
    /* Allow both scrolling directions */
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
  }
}

/* Dark Mode Styles */
html[data-theme="dark"] .gallery-control {
  background-color: rgba(26, 26, 26, 0.8);
  color: var(--accent-color);
}

html[data-theme="dark"] .gallery-control:hover {
  background-color: rgba(26, 26, 26, 0.9);
}

html[data-theme="dark"] .gallery-control i {
  color: var(--accent-color);
}

html[data-theme="dark"] .gallery-thumb.active {
  border-color: var(--accent-color);
}

html[data-theme="dark"] .fullscreen-close,
html[data-theme="dark"] .fullscreen-nav-button {
  background-color: rgba(50, 50, 50, 0.5);
}

html[data-theme="dark"] .fullscreen-close:hover,
html[data-theme="dark"] .fullscreen-nav-button:hover {
  background-color: rgba(70, 70, 70, 0.7);
}

/* ===============================================
   UNIFIED GALLERY MODAL SYSTEM
   =============================================== */

/* Gallery Modal Base */
/* CRITICAL: Modal must appear above navbar (navbar z-index: 10000) */
.gallery-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.98);
  z-index: 100000 !important;
  /* MUST be above navbar (10000) - use very high z-index */
  backdrop-filter: blur(10px);
}

.gallery-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  touch-action: pan-x pan-y;
  /* Allow both horizontal and vertical scrolling */
  overflow: visible;
  /* Ensure content can scroll */
}

.gallery-modal-image {
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: transparent !important;
  margin: 0 auto !important;
}

/* Modal Controls */
.gallery-modal-controls {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100001;
}

.gallery-modal-control {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.9);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.gallery-modal-control:hover {
  background-color: white;
  transform: scale(1.1);
}

.gallery-modal-control i {
  font-size: 1.4rem;
  color: var(--dark-color);
}

/* Modal Close Button - Top right corner (modal is above navbar) */
.gallery-modal-close {
  position: absolute;
  top: 20px;
  /* Fixed position from top - modal is above navbar so no need to offset */
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100001;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.gallery-modal-close:hover {
  background-color: white;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.gallery-modal-close i {
  font-size: 1.4rem;
  color: var(--dark-color);
}

/* Modal Status - Position at top-right (modal is above navbar) */
.gallery-modal-status {
  position: absolute;
  top: 20px;
  /* Fixed position from top - modal is above navbar */
  right: 80px;
  /* Position to left of close button (50px button + 20px gap + 10px spacing) */
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 18px;
  border-radius: 25px;
  font-size: 0.95rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
  z-index: 100001;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

/* Modal Thumbnails */
.gallery-modal-thumbs {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 10px;
  border-radius: 25px;
  backdrop-filter: blur(10px);
  max-width: 90%;
  overflow-x: auto !important;
  /* CRITICAL: Allow horizontal scrolling */
  overflow-y: hidden !important;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  /* Smooth scrolling on iOS */
  z-index: 100001;
  /* Ensure thumbnails are scrollable */
  touch-action: pan-x;
  cursor: grab;
  /* Custom scrollbar styling for better visibility */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.5) rgba(0, 0, 0, 0.3);
}

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

.gallery-modal-thumbs::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
}

.gallery-modal-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
}

.gallery-modal-thumbs::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.7);
}

.gallery-modal-thumbs:active {
  cursor: grabbing;
}

.gallery-modal-thumb {
  width: 50px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.6;
  border: 2px solid transparent;
  flex-shrink: 0;
}

.gallery-modal-thumb:hover {
  opacity: 0.8;
}

.gallery-modal-thumb.active {
  opacity: 1;
  border-color: var(--accent-color);
}

.gallery-modal-thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
  .gallery-modal-content {
    padding: 15px;
  }

  .gallery-modal-controls {
    padding: 0 15px;
  }

  .gallery-modal-control {
    width: 45px;
    height: 45px;
  }

  .gallery-modal-control i {
    font-size: 1.2rem;
  }

  /* Mobile: Modal close button at top right (modal is above navbar) */
  .gallery-modal-close {
    top: 15px !important;
    /* Fixed position - modal is above navbar */
    right: 15px;
    width: 45px;
    height: 45px;
  }

  .gallery-modal-close i {
    font-size: 1.2rem;
  }

  /* Mobile: Modal status counter at top right (modal is above navbar) */
  .gallery-modal-status {
    top: 15px !important;
    /* Fixed position - modal is above navbar */
    right: 70px !important;
    /* Position to left of close button on mobile */
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    font-size: 0.85rem;
    padding: 8px 14px;
  }

  .gallery-modal-thumbs {
    bottom: 50px;
    padding: 8px;
  }

  .gallery-modal-thumb {
    width: 40px;
    height: 32px;
  }

  /* Mobile: Position gallery fullscreen button below navbar - account for negative margin */
  .gallery-fullscreen {
    width: 40px !important;
    height: 40px !important;
    top: calc(var(--site-header-height, 50px) * 2 + 20px) !important;
    /* 2x header height to account for negative margin + padding */
    left: 15px !important;
    font-size: 0.9rem !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 50 !important;
    position: absolute !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  }

  .gallery-fullscreen:hover,
  .gallery-fullscreen:focus {
    background-color: rgba(0, 0, 0, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    /* CRITICAL FIX: Use box-shadow instead of transform to prevent position shifts */
  }
  
  .gallery-fullscreen:active {
    background-color: rgba(0, 0, 0, 0.7) !important;
    opacity: 0.9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5) !important;
    /* CRITICAL FIX: Use opacity and box-shadow instead of transform to prevent position shifts */
  }

  /* Mobile: Position gallery status counter below navbar - account for negative margin */
  .gallery-status {
    top: calc(var(--site-header-height, 50px) * 2 + 20px) !important;
    /* 2x header height to account for negative margin + padding */
    right: 15px;
    padding: 6px 12px;
    font-size: 0.8rem;
    background-color: rgba(0, 0, 0, 0.5) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  }
}

@media (max-width: 576px) {
  .gallery-modal-content {
    padding: 10px;
  }

  .gallery-modal-controls {
    padding: 0 10px;
  }

  .gallery-modal-control {
    width: 40px;
    height: 40px;
  }

  .gallery-modal-control i {
    font-size: 1rem;
  }

  /* Extra small mobile: Modal close button at top right (modal is above navbar) */
  .gallery-modal-close {
    top: 12px !important;
    /* Fixed position - modal is above navbar */
    right: 12px;
    width: 40px;
    height: 40px;
  }

  .gallery-modal-close i {
    font-size: 1rem;
  }

  /* Extra small mobile: Modal status counter at top right (modal is above navbar) */
  .gallery-modal-status {
    top: 12px !important;
    /* Fixed position - modal is above navbar */
    right: 60px !important;
    /* Position to left of close button on very small screens */
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  .gallery-modal-thumbs {
    display: none;
    /* Hide thumbnails on very small screens */
  }

  /* Extra small mobile: Adjust gallery fullscreen button - account for negative margin */
  .gallery-fullscreen {
    width: 38px !important;
    height: 38px !important;
    top: calc(var(--site-header-height, 50px) * 2 + 20px) !important;
    /* 2x header height to account for negative margin + padding */
    left: 12px !important;
    font-size: 0.85rem !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  }

  /* Extra small mobile: Adjust gallery status - account for negative margin */
  .gallery-status {
    top: calc(var(--site-header-height, 50px) * 2 + 20px) !important;
    /* 2x header height to account for negative margin + padding */
    right: 12px;
    font-size: 0.75rem;
    padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.5) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  }
}

/* ===============================================
   BOOK NOW CTA BUTTON - GLASSMORPHISM DESIGN
   =============================================== */

.gallery-book-now {
  position: absolute;
  top: 50%;
  left: 50%;
  /* CRITICAL FIX: Use fixed transform that never changes */
  transform: translate(-50%, -50%) !important;
  z-index: 60;

  /* Glassmorphism styling */
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;

  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50px;

  color: white;
  font-family: var(--font-family-body, 'Poppins', sans-serif);
  font-size: 1.125rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;

  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);

  /* CRITICAL FIX: Only transition properties that don't affect position */
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.2s ease;
  /* Transform is NOT in transition - it stays constant */
  cursor: pointer;
  /* CRITICAL FIX: Ensure button maintains position - transform is only for centering */
  will-change: box-shadow, background-color, opacity;
  /* Optimize for animations without layout shifts */
  -webkit-tap-highlight-color: transparent;
  /* Remove tap highlight on mobile */
  touch-action: manipulation;
  /* Optimize for tap/click */
  /* CRITICAL FIX: Ensure transform stays constant and never changes */
  transform-origin: center center;
  /* CRITICAL FIX: Prevent any layout shifts */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.gallery-book-now i {
  font-size: 1.25rem;
  transition: transform 0.3s ease;
  /* Icon can transform independently without affecting button position */
}

.gallery-book-now:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  /* CRITICAL FIX: Use box-shadow instead of transform to avoid position shifts */
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(212, 175, 55, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  color: white;
  text-decoration: none;
  /* CRITICAL FIX: Transform NEVER changes - always stays the same */
  transform: translate(-50%, -50%) !important;
}

.gallery-book-now:hover i {
  transform: scale(1.1);
  /* Icon can scale independently without affecting button position */
}

.gallery-book-now:active {
  /* CRITICAL FIX: Use opacity and box-shadow instead of transform to prevent position shifts */
  opacity: 0.85;
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.35),
    0 0 15px rgba(212, 175, 55, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  /* Visual feedback without position change */
  /* CRITICAL FIX: Transform NEVER changes - always stays the same */
  transform: translate(-50%, -50%) !important;
  transition: opacity 0.1s ease, box-shadow 0.1s ease;
  /* Transform is NOT in transition */
}

.gallery-book-now:focus {
  /* CRITICAL FIX: Transform NEVER changes even on focus */
  transform: translate(-50%, -50%) !important;
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 3px;
  /* Accessibility focus indicator */
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .gallery-book-now {
    top: 55%;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    gap: 0.625rem;
    /* CRITICAL FIX: Ensure button doesn't move on mobile */
    transform: translate(-50%, -50%) !important;
    /* Keep transform constant for centering - NEVER changes */
    transform-origin: center center;
    will-change: box-shadow, background-color, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  .gallery-book-now i {
    font-size: 1.1rem;
  }
  
  .gallery-book-now:hover {
    /* CRITICAL FIX: Transform NEVER changes on hover */
    transform: translate(-50%, -50%) !important;
  }
  
  .gallery-book-now:active {
    /* CRITICAL FIX: Use opacity instead of transform to prevent position shifts on mobile */
    opacity: 0.85;
    box-shadow:
      0 6px 24px rgba(0, 0, 0, 0.35),
      0 0 15px rgba(212, 175, 55, 0.25);
    /* CRITICAL FIX: Transform NEVER changes - always stays the same */
    transform: translate(-50%, -50%) !important;
  }

  .gallery-book-now:focus {
    /* CRITICAL FIX: Transform NEVER changes on focus */
    transform: translate(-50%, -50%) !important;
  }
}

@media (max-width: 576px) {
  .gallery-book-now {
    top: 58%;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    /* CRITICAL FIX: Ensure button doesn't move on small mobile */
    transform: translate(-50%, -50%) !important;
    /* Keep transform constant for centering - NEVER changes */
    transform-origin: center center;
    will-change: box-shadow, background-color, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  .gallery-book-now i {
    font-size: 1rem;
  }
  
  .gallery-book-now:hover {
    /* CRITICAL FIX: Transform NEVER changes on hover */
    transform: translate(-50%, -50%) !important;
  }
  
  .gallery-book-now:active {
    /* CRITICAL FIX: Use opacity instead of transform to prevent position shifts on small mobile */
    opacity: 0.85;
    box-shadow:
      0 6px 24px rgba(0, 0, 0, 0.35),
      0 0 15px rgba(212, 175, 55, 0.25);
    /* CRITICAL FIX: Transform NEVER changes - always stays the same */
    transform: translate(-50%, -50%) !important;
  }

  .gallery-book-now:focus {
    /* CRITICAL FIX: Transform NEVER changes on focus */
    transform: translate(-50%, -50%) !important;
  }
}

/* Dark mode adjustments */
html[data-theme="dark"] .gallery-book-now {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(212, 175, 55, 0.4);
}

html[data-theme="dark"] .gallery-book-now:hover {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(212, 175, 55, 0.6);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 25px rgba(212, 175, 55, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
