/* =========================================
   استایل‌های کلی Modal
========================================= */

.modal-content {
  border: none !important;
  border-radius: 20px !important;
  box-shadow: 0 20px 50px rgba(23, 32, 51, 0.15);
  max-height: 90vh;
  overflow: hidden;
  background-color: var(--surface-card);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  background-color: var(--surface-card);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin-bottom: 0;
  line-height: 1.5;
}

/* =========================================
   دکمه بستن Modal
========================================= */

.modern-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;

  color: var(--text-secondary);
  background-color: var(--surface-background);

  box-shadow: 0 4px 10px rgba(23, 32, 51, 0.1);

  display: inline-flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease,
    transform 0.3s ease;
}

.modal-header .modern-close {
  margin-right: auto !important;
  margin-left: 0 !important;
}

.modern-close::after {
  content: "";

  display: block;
  width: 100%;
  height: 100%;

  background:
    linear-gradient(currentColor 0 0) center / 16px 2px no-repeat,
    linear-gradient(currentColor 0 0) center / 2px 16px no-repeat;

  transform: rotate(45deg);

  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modern-close:hover {
  color: var(--surface-card);
  background-color: var(--color-error);
  box-shadow: 0 6px 18px rgba(214, 69, 93, 0.4);
}

.modern-close:hover::after {
  transform: rotate(135deg);
}

/* =========================================
   دکمه بستن شناور
========================================= */

.modern-close.floating {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 1060;
}

/* =========================================
   تصاویر معمولی داخل Modal
========================================= */

.modal-img-contain,
.modal-img-cover {
  width: 100%;
}

.modal-img-contain {
  max-height: 65vh;
  object-fit: contain;
  background-color: var(--surface-background);
}

.modal-img-cover {
  max-height: 65vh;
  object-fit: cover;
}

/* =========================================
   بدنه Modal معمولی
========================================= */

.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
}

/*
   فقط تصاویر مستقیم داخل modal-body
   و نه تصاویر thumbnail
*/
.modal-body > img {
  /* max-height: calc(100vh - 140px); */
  width: 100%;
  object-fit: cover;
}

/* =========================================
   محتوای متنی Modal
========================================= */

.modal-text-wrapper {
  text-align: right;
  direction: rtl;

  display: flex;
  flex-direction: column;

  justify-content: flex-start;

  height: 100%;

  padding: 1rem;
  padding-left: 0;
}

.modal-location {
  font-size: 1.1rem;
  font-weight: 700;

  color: var(--theme-color, #ff4c3b);

  margin-bottom: 1.5rem;

  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-features {
  list-style: none;
  padding: 0;
  margin: 0;
}

.modal-features li {
  position: relative;

  display: block;

  padding-right: 1.5rem;
  margin-bottom: 1rem;

  font-size: 0.95rem;
  line-height: 1.8;

  color: var(--surface-card-text, #444);
}

.modal-features li::before {
  content: "";

  position: absolute;

  right: 0;
  top: 8px;

  width: 6px;
  height: 6px;

  border-radius: 50%;

  background: var(--btb-primary, #b8860b);
}

/* =========================================
   تصویر داخل wrapper
========================================= */

.modal-image-wrapper img {
  width: 100%;
  height: 100%;

  object-fit: cover;

  border-radius: 12px;
}

/* =========================================
   Gallery Carousel
========================================= */

#villaEcommerceGallery {
  width: 100%;
}

#villaEcommerceGallery .carousel-inner {
  width: 100%;
}

#villaEcommerceGallery .carousel-item {
  height: 500px;
}

#villaEcommerceGallery .carousel-item img {
  display: block !important;

  width: 100% !important;
  height: 500px !important;

  object-fit: cover !important;

  border-radius: 0 !important;
}

/* =========================================
   Thumbnail Gallery
========================================= */

.gallery-thumbnails-container {
  border-top: 1px solid var(--border-color);

  background: #fff;

  padding: 1rem !important;

  direction: ltr;
}

.gallery-thumbnails {
  display: flex;

  gap: 10px;

  /*
     ترتیب بصری thumbnailها معکوس می‌شود
     ولی data-bs-slide-to دست‌نخورده باقی می‌ماند.
  */
  flex-direction: row-reverse;

  overflow-x: auto;
  overflow-y: hidden;

  padding-bottom: 5px;

  scroll-behavior: smooth;

  /* مخفی کردن scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.gallery-thumbnails::-webkit-scrollbar {
  display: none;
}

.thumb-img {
  width: 80px;
  height: 60px;

  flex-shrink: 0;

  object-fit: cover;

  border-radius: 8px;

  cursor: pointer;

  opacity: 0.5;

  border: 2px solid transparent;

  transition:
    opacity 0.3s ease,
    border-color 0.3s ease,
    transform 0.3s ease;
}

.thumb-img:hover {
  opacity: 0.8;
  border-color: var(--theme-color);
}

.thumb-img.active {
  opacity: 1;
  border-color: var(--theme-color);
}

/* =========================================
   دکمه‌های Carousel
========================================= */

#villaEcommerceGallery .carousel-control-prev,
#villaEcommerceGallery .carousel-control-next {
  width: 46px;
  height: 46px;

  top: 50%;
  bottom: auto;

  transform: translateY(-50%);

  background: rgba(0, 0, 0, 0.45);

  border-radius: 50%;

  opacity: 1;

  z-index: 5;

  transition:
    background-color 0.25s ease,
    transform 0.25s ease,
    box-shadow 0.25s ease;
}

/* قبلی → راست */
#villaEcommerceGallery .carousel-control-prev {
  left: auto;
  right: 15px;
}

/* بعدی → چپ */
#villaEcommerceGallery .carousel-control-next {
  right: auto;
  left: 15px;
}

/* Hover */

#villaEcommerceGallery .carousel-control-prev:hover,
#villaEcommerceGallery .carousel-control-next:hover {
  background: rgba(0, 0, 0, 0.7);

  transform: translateY(-50%) scale(1.08);
}

/* =========================================
   آیکون‌های Carousel
========================================= */

#villaEcommerceGallery .carousel-control-prev-icon,
#villaEcommerceGallery .carousel-control-next-icon {
  position: relative;

  width: 18px;
  height: 18px;

  background-image: none !important;
}

/* ساخت فلش */

#villaEcommerceGallery .carousel-control-prev-icon::after,
#villaEcommerceGallery .carousel-control-next-icon::after {
  content: "";

  position: absolute;

  width: 10px;
  height: 10px;

  top: 50%;
  left: 50%;

  border-top: 2px solid #fff;
  border-right: 2px solid #fff;
}

/* فلش قبلی → راست */

#villaEcommerceGallery .carousel-control-prev-icon::after {
  transform: translate(-50%, -50%) rotate(45deg);
}

/* فلش بعدی → چپ */

#villaEcommerceGallery .carousel-control-next-icon::after {
  transform: translate(-50%, -50%) rotate(-135deg);
}

/* =========================================
   Modal تمام‌تصویر
========================================= */

.villa-image-modal {
  position: relative;

  width: 100%;
  height: 90vh;
  max-height: 90vh;

  padding: 0 !important;

  border: none !important;
  border-radius: 20px !important;

  overflow: hidden;

  background: #000;

  box-shadow: 0 20px 50px rgba(23, 32, 51, 0.2);
}

.villa-image-modal .modal-body {
  width: 100%;
  height: 100%;

  padding: 0 !important;

  overflow: hidden !important;

  display: flex;
  align-items: center;
  justify-content: center;
}

.villa-full-image {
  display: block;

  width: 100%;
  height: 100%;

  max-width: none;
  max-height: none;

  object-fit: cover;
}

/* دکمه بستن گالری */

.villa-image-modal .modern-close.floating {
  position: absolute;

  top: 15px;
  left: 15px;

  z-index: 10;
}

/* =========================================
   Responsive
========================================= */

@media (max-width: 768px) {
  /* تصاویر معمولی Modal */
  .modal-img-contain,
  .modal-img-cover {
    max-height: 50vh;
  }

  /* Carousel */
  #villaEcommerceGallery .carousel-item {
    height: 50vh;
  }

  #villaEcommerceGallery .carousel-item img {
    height: 50vh !important;
  }

  /* دکمه‌های Carousel */
  #villaEcommerceGallery .carousel-control-prev,
  #villaEcommerceGallery .carousel-control-next {
    width: 38px;
    height: 38px;
  }

  #villaEcommerceGallery .carousel-control-prev {
    right: 10px;
  }

  #villaEcommerceGallery .carousel-control-next {
    left: 10px;
  }

  #villaEcommerceGallery .carousel-control-prev-icon,
  #villaEcommerceGallery .carousel-control-next-icon {
    width: 16px;
    height: 16px;
  }

  /* Modal تمام‌تصویر */
  .villa-image-modal {
    width: 100%;

    height: 90vh;
    max-height: 90vh;

    border-radius: 14px !important;
  }

  .villa-full-image {
    width: 100%;
    height: 100%;

    object-fit: cover;
  }

  .villa-image-modal .modern-close.floating {
    top: 10px;
    left: 10px;
  }
}
.modal-img-fit {
  max-height: 70vh; /* محدود کردن حداکثر ارتفاع به ۷۰ درصد ارتفاع مانیتور */
  width: 100%;
  object-fit: contain; /* جلوگیری از دفرمه شدن و نمایش کامل تصویر */
  background-color: #f8f9fa; /* (اختیاری) رنگ پس‌زمینه برای فضاهای خالی اطراف تصویر */
}

/* تنظیمات بدنه مودال برای وسط‌چین کردن تصویر در صورت کوچکتر بودن عرض آن */
.modal-body--fit-content {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 0 !important;

  /* اختصاص ارتفاع دقیق به کانتینر بر اساس صفحه نمایش */
  height: calc(
    100vh - 130px
  ) !important; /* ۱۳۰ پیکسل برای هدر و حاشیه‌ها کسر می‌شود */
  overflow: hidden !important; /* جلوگیری قطعی از ایجاد اسکرول */

  /* (اختیاری) رنگ پس‌زمینه ملایم برای پر کردن فضای خالی دو طرف تصویر عمودی */
  background-color: #fcfcfc !important;
}

/* کلاس اختصاصی برای تصویر جهت جلوگیری از کش آمدن عرض و کنترل ارتفاع */
.modal-img-fit {
  height: 100% !important; /* ارتفاع دقیقاً ۱۰۰٪ کانتینر والد */
  width: auto !important; /* عرض به صورت اتوماتیک متناسب با ارتفاع تنظیم می‌شود */
  max-width: 100% !important; /* جلوگیری از بیرون‌زدگی در مانیتورهای بسیار کوچک */
  object-fit: contain !important; /* حفظ تناسب دقیق ابعاد بدون دفرمه شدن */
  margin: 0 auto !important; /* اطمینان مضاعف برای وسط‌چین شدن */
}
