/* ===============================
   POPUP (Desktop / Default)
=============================== */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #f9f6ef;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  transition: opacity 0.3s ease;
  overflow-y: auto;
}

.popup-box {
  background: #f9f6ef;
  padding: 40px;
  position: relative;
  width: 90vw;
  height: 90vh;
  max-width: 1200px;
  max-height: 800px;
  box-sizing: border-box;
}

.popup-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  height: 100%;
}

.popup-left {
  flex: 1 1 50%;
}
.popup-left img {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.popup-right {
  flex: 1 1 45%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.popup-title {
  font-size: 18px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: #615434;
  margin: 19px 50px 20px 50px;
  font-weight: 400;
  line-height: 32px;
  text-align: center;
}

.close-popup {
  position: absolute;
  top: 20px;
  right: 50px;
  width: 35px;
  height: 35px;
  background: transparent
    url("https://targetestate.co.th/wp-content/uploads/2025/08/x.svg")
    center/contain no-repeat;
  cursor: pointer;
  z-index: 10000;
}

/* ===============================
   GALLERY (Desktop / Default)
=============================== */
/* 1) Overlay */
.gallery-popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 99999;
  transition: opacity 0.3s ease;
}
.gallery-popup-overlay.active {
  display: flex;
}

/* 2) Box */
.gallery-popup-box {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: #f9f6ef;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

/* 3) Header + Close */
.gallery-popup-box-header {
  position: relative;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
  box-sizing: border-box;
}
.gallery-close {
  position: absolute;
  top: 20px;
  right: 50px;
  width: 35px;
  height: 35px;
  background-color: transparent;
  background-image: url("https://targetestate.co.th/wp-content/uploads/2025/08/x.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border: none;
  cursor: pointer;
  z-index: 10000;
}

/* 4) Image Area */
.gallery-popup-inner {
  flex-grow: 1;
  position: relative;
  width: 100%;
  height: calc(100vh - 122px);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.gallery-popup-inner .gallery-popup-img,
.gallery-popup-inner .gallery-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.35s ease;
  will-change: transform;
}
.gallery-popup-img {
  width: auto;
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 122px);
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* 5) Controls */
.gallery-controls {
  display: flex;
  align-items: center;
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  flex-wrap: nowrap;
  padding: 0 2%;
  justify-content: space-between;
}
.gallery-counter {
  font-size: 12px;
  user-select: none;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-group-arrow {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.gallery-prev,
.gallery-next {
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  background-color: transparent;
  cursor: pointer;
  margin: 0;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
}
.gallery-controls:hover .gallery-prev,
.gallery-controls:hover .gallery-next,
.gallery-prev:hover,
.gallery-next:hover,
.gallery-prev:focus,
.gallery-prev:active,
.gallery-next:focus,
.gallery-next:active {
  background-color: transparent !important;
}
.gallery-prev {
  background-image: url("https://targetestate.co.th/wp-content/uploads/2025/08/arrow-left-1.svg");
}
.gallery-next {
  background-image: url("https://targetestate.co.th/wp-content/uploads/2025/08/arrow-right-1.svg");
}

/* 6) Divider */
.divider-line {
  display: inline-block;
  width: 48px;
  height: 0.5px;
  background-color: #615434;
  vertical-align: middle;
  margin: 0 8px;
}

/* 7) Interaction helpers */
.gallery-popup-inner img {
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: auto;
}
.gallery-popup-inner {
  touch-action: pan-y;
  cursor: grab;
}
.gallery-popup-inner.dragging {
  cursor: grabbing;
}



/* ===============================
   MOBILE (≤768px) — Popup + Gallery
=============================== */
@media (max-width: 768px) {
  /* Popup */
  .popup-overlay {
    width: 100vw;
    height: 100dvh;
  }
	
	.n2-ss-widget.nextend-bar {
		padding-left: 5px !important;
	}

  .popup-box {
    width: 100vw;
    height: 100dvh;
    padding: 16px;
    border-radius: 0;
    box-shadow: none;
	align-content: center;
  }

  .popup-layout {
    flex-direction: column;
    gap: 12px;
    height: 100%;
  }

  .popup-left {
    flex: 0 0 auto;
  }
  .popup-left img {
    width: 90%;
    height: auto;
    max-height: 42dvh;
    object-fit: contain;
    border-radius: 6px;
    display: block;
    margin: 0 auto;
  }

  .popup-right {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: auto;
    padding: 0 8px;
  }

  .popup-title {
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.2em;
    margin: 8px 8px 24px 8px;
    text-align: center;
  }

   .close-popup {
    top: calc(env(safe-area-inset-top, 0) + 10px);
    right: calc(env(safe-area-inset-right, 0) + 12px);
    width: 32px;
    height: 32px;
    background-size: 18px 18px;
  }

  /* Gallery */
  .gallery-popup-overlay {
    width: 100vw;
    height: 100dvh;
  }
  .gallery-popup-box {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .gallery-popup-box-header {
    height: 56px;
    padding: 0 12px;
  }
  .gallery-close {
    top: calc(env(safe-area-inset-top, 0) + 10px);
    right: calc(env(safe-area-inset-right, 0) + 12px);
    width: 32px;
    height: 32px;
    background-size: 18px 18px;
  }
  .gallery-popup-inner {
    height: calc(100dvh - 96px);
    padding: 0 8px;
  }
  .gallery-popup-img {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 120px);
  }
  .gallery-controls {
    height: 40px;
    padding: 0 10px;
    gap: 8px;
  }
  .gallery-group-arrow {
    gap: 8px;
  }
  .gallery-prev,
  .gallery-next {
    width: 36px;
    height: 36px;
    background-size: 20px 20px;
  }

  @supports (height: 100svh) {
    .popup-overlay {
      height: 100vh;
    } 
    .popup-box {
      min-height: 100svh; 
      height: auto;
    }
    .popup-left img {
      max-height: 42svh; 
    }
  }
}
