/* ===== Modal shell & header ===== */
.modal-content {
  border: none !important;
  border-radius: 20px !important;
  box-shadow: var(--ds-shadow-lg);
  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;
  color: var(--text-heading);
  font-weight: 700;
}

/* ===== Close button ===== */
.modern-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;

  color: var(--text-secondary);
  background-color: var(--surface-background);

  box-shadow: var(--ds-shadow-md);

  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 color-mix(in srgb, var(--color-error) 40%, transparent);
}

.modern-close:hover::after {
  transform: rotate(135deg);
}

.modern-close.floating {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 1060;
}

/* ===== Regular images ===== */
.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 body & text ===== */
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  color: var(--text-body);
}

/* Direct images only, not thumbnails */
.modal-body > img {
  width: 100%;
  object-fit: cover;
}

.modal-text-wrapper {
  text-align: right;
  direction: rtl;

  display: flex;
  flex-direction: column;

  justify-content: flex-start;

  height: 100%;

  padding: 1rem;
  padding-left: 0;
  color: var(--text-body);
}

.modal-location {
  font-size: 1.1rem;
  font-weight: 700;

  color: var(--brand-primary);

  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(--text-body);
}

.modal-features li::before {
  content: "";

  position: absolute;

  right: 0;
  top: 8px;

  width: 6px;
  height: 6px;

  border-radius: 50%;

  background: var(--brand-secondary);
}

.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;
}

/* ===== Thumbnails ===== */
.gallery-thumbnails-container {
  border-top: 1px solid var(--border-color);

  background: var(--surface-card);

  padding: 1rem !important;

  direction: ltr;
}

.gallery-thumbnails {
  display: flex;

  gap: 10px;

  /* Visual order is reversed; data-bs-slide-to stays unchanged */
  flex-direction: row-reverse;

  overflow-x: auto;
  overflow-y: hidden;

  padding-bottom: 5px;

  scroll-behavior: smooth;

  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 controls ===== */
#villaEcommerceGallery .carousel-control-prev,
#villaEcommerceGallery .carousel-control-next {
  width: 46px;
  height: 46px;

  top: 50%;
  bottom: auto;

  transform: translateY(-50%);

  background: color-mix(in srgb, var(--ds-shadow-color) 50%, transparent);

  border-radius: 50%;

  opacity: 1;

  z-index: 5;

  transition:
    background-color 0.25s ease,
    transform 0.25s ease,
    box-shadow 0.25s ease;
}

/* Prev on the right (RTL) */
#villaEcommerceGallery .carousel-control-prev {
  left: auto;
  right: 15px;
}

/* Next on the left (RTL) */
#villaEcommerceGallery .carousel-control-next {
  right: auto;
  left: 15px;
}

#villaEcommerceGallery .carousel-control-prev:hover,
#villaEcommerceGallery .carousel-control-next:hover {
  background: color-mix(in srgb, var(--ds-shadow-color) 75%, transparent);

  transform: translateY(-50%) scale(1.08);
}

#villaEcommerceGallery .carousel-control-prev-icon,
#villaEcommerceGallery .carousel-control-next-icon {
  position: relative;

  width: 18px;
  height: 18px;

  background-image: none !important;
}

/* Arrow drawn with borders */
#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 var(--text-white);
  border-right: 2px solid var(--text-white);
}

#villaEcommerceGallery .carousel-control-prev-icon::after {
  transform: translate(-50%, -50%) rotate(45deg);
}

#villaEcommerceGallery .carousel-control-next-icon::after {
  transform: translate(-50%, -50%) rotate(-135deg);
}

/* ===== Full-image 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: var(--ds-shadow-color);

  box-shadow: var(--ds-shadow-lg);
}

.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;
}

/* ===== Fit-content modal ===== */
.modal-body--fit-content {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 0 !important;

  /* Header and margins subtracted from viewport height */
  height: calc(100vh - 130px) !important;
  overflow: hidden !important;

  background-color: var(--surface-card) !important;
}

.modal-img-fit {
  max-height: 70vh;
  height: 100% !important;
  width: auto !important;
  max-width: 100% !important;
  object-fit: contain !important;
  margin: 0 auto !important;
  background-color: var(--surface-background);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .modal-img-contain,
  .modal-img-cover {
    max-height: 50vh;
  }

  #villaEcommerceGallery .carousel-item {
    height: 50vh;
  }

  #villaEcommerceGallery .carousel-item img {
    height: 50vh !important;
  }

  #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;
  }

  .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;
  }
}
