.hero-section {
  background: var(--primary);
  color: var(--white);
  padding: 4rem 0;
  position: relative;
}

.hero-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.062), rgba(212, 175, 55, 0.06));
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
}

.hero-title {
  font-size: 3rem;
  font-weight: 700; 
  line-height: 1.2;
  margin-bottom: 1rem;
}

.hero-description {
  font-size: 1.125rem;
  color: #cbd5e1;
}

/* Search Section */
.search-section {
  background: var(--white);
  border-radius: 0.9rem;
  padding: 2rem;
  margin: -2rem 0 3rem;
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.search-form {
  display: flex;
  align-items: center;
  justify-content: center;
  gap:16px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  width:100%;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.875rem 0.875rem 0.875rem 3rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  font-size: 0.95rem;
  transition: 0.2s;
  background: var(--white);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}
.search-form .search-select{
  flex-grow: 1;
}
.search-select,
.filter-select {
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  font-size: 0.95rem;
  background: var(--white);
  cursor: pointer;
  transition: 0.2s;
}

.search-select:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.filters-btn {
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.filters-btn:hover {
  border-color: var(--accent);
  background: rgba(212, 175, 55, 0.06);
}

/* Advanced Filters */
.advanced-filters {
  display: none;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  /* border-top: 1px solid var(--border); */
}

.advanced-filters.show {
  display: block;
}

.filters-grid {
  display: flex;
  align-items:center;
  flex-wrap: wrap;
  /* grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); */
  gap: 16px;
}
@media screen and (min-width:696px) {
  .filters-grid{
    flex-wrap: nowrap;
  }
}
.filter-label{
  display: block;
  width:100%;
}
.filter-group .filter-select{
  display: block;
  width: 100%;
}

.range-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-input {
  width:100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.range-input:focus {
  outline: none;
  border-color: var(--accent);
}
.filter-group{
  display: block;
  width:100%;
}

/* Results Header */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.sort-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

/* Properties Grid - GRILLE FLEXIBLE POUR DJANGO */
.properties-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
  /* Assure que la grille s'adapte automatiquement au nombre d'éléments */
  grid-auto-rows: max-content;
}

.properties-grid:has(.property-card:nth-child(1):nth-last-child(1)) {
  grid-template-columns: minmax(350px, 420px);
  justify-content: start;
}

.properties-grid:has(.property-card:nth-child(2):nth-last-child(1)) {
  grid-template-columns: repeat(2, minmax(350px, 420px));
  justify-content: start;
}

.property-card {
  background: var(--white);
  border-radius: 0.9rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  cursor: pointer;
  /* Hauteur fixe pour uniformité */
  height: fit-content;
}

.property-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.property-image {
  position: relative;
  height: 200px;
  overflow: hidden;
}

.property-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.property-card:hover .property-image img {
  transform: scale(1.05);
}

.property-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: var(--white);
  color: var(--text-primary);
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.property-content {
  padding: 1.25rem 1.5rem;
}

.property-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.property-location {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.property-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.detail-item {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: #f8fafc;
  padding: 0.25rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
}

.property-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-light);
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top:0;
  left:0;
  /* inset: 0; */
  display: none;
  place-items: center;
  /* padding: 1rem; */
  background: rgba(2, 6, 23, 0.5);
  /* backdrop-filter: blur(6px); */
  /* -webkit-backdrop-filter: blur(6px); */
  z-index: 10000;
  width:100%;
  height:100vh;
  /* opacity: 0; */
  /* visibility: hidden; */
  /* transition: opacity 0.25s ease, visibility 0.25s ease; */
}

.modal-overlay.show {
  display:grid;
}

.modal-content {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.92));
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 1rem;
  width: 100%;
  max-width: 1100px;
  /* Important: le modal est limité en hauteur et il défile en interne */
  max-height: min(92vh, calc(100dvh - 2rem));
  overflow-y: scroll; /* <- Permet de scroller dans le modal */
  -webkit-overflow-scrolling: touch; /* <- Scroll fluide sur iOS */
  overscroll-behavior: contain; /* <- Évite les rebonds vers l’arrière-plan */
  touch-action: pan-y; /* <- S’assure que le geste vertical scrolle */
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.98);
  animation: modalIn 0.3s ease forwards;
  position: relative;
  display: block; /* Pas besoin de grid ici au niveau du conteneur */
  touch-action: pan-y; /* <- S’assure que le geste vertical scrolle */
}

@keyframes modalIn {
  to {
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  width: 42px;
  height: 42px;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.2s;
  z-index: 5;
}

.modal-close:hover {
  transform: scale(1.05);
  background: #fff;
}

.modal-body {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 0;
}

.modal-gallery {
  background: #0b1220;
  position: relative;
  min-width: 0;
}

.gallery-main {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.01);
  transition: transform 0.6s ease, opacity 0.2s ease;
}

.gallery-main:hover img {
  transform: scale(1.04);
}

.gallery-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.25),
    rgba(0, 0, 0, 0) 30%,
    rgba(0, 0, 0, 0) 60%,
    rgba(0, 0, 0, 0.35) 100%
  );
  pointer-events: none;
}

.gallery-counter {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.price-chip {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-primary);
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-primary);
  padding: 0.4rem 0.7rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  transition: 0.2s;
  backdrop-filter: blur(2px);
}

.gallery-nav:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: translateY(-50%) scale(1.03);
}

.gallery-nav.prev {
  left: 0.75rem;
}
.gallery-nav.next {
  right: 0.75rem;
}

.gallery-thumbs {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem 0.8rem;
  overflow-x: auto;
  background: linear-gradient(180deg, #0b1220, #0b1220);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.gallery-thumb {
  width: 84px;
  height: 64px;
  border-radius: 0.5rem;
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  position: relative;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9);
  transition: 0.2s;
}

.gallery-thumb:hover img {
  transform: scale(1.03);
}
.gallery-thumb.active {
  outline: 2px solid var(--accent);
}
#gallery-images-container{
  max-width: 100%;
  overflow-x: scroll;
}
#gallery-images{
  display:flex;
  width: max-content;
  overflow-x:scroll;
  padding: 12px;
  gap:12px;

}
.modal-image-container{
  width:80px;
  height: 80px;
  overflow: hidden;
}
.modal-image-container:hover{
  cursor: pointer;
  border-radius: 16px;
  
}
.modal-image-container img{
  width:100%;
  height: 100%;
  object-fit: cover;
}

.modal-info {
  padding: 1.5rem 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: #fff;
  min-width: 0;
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.25;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.type-chip {
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
}

.modal-price {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-light);
}

.modal-location {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}

.modal-location svg {
  color: var(--accent);
}

.modal-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.modal-details .detail-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  padding: 0.7rem 1rem;
  border-radius: 0.7rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.modal-details .detail-item svg {
  color: var(--accent);
}

.modal-amenities h3,
.modal-description h3,
.modal-owner h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.amenities-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.amenity-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.amenity-pill::before {
  content: "•";
  color: var(--accent);
}

.modal-description p {
  color: var(--text-secondary);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.owner-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  box-shadow: var(--shadow);
}

.owner-avatar {
  width: 52px;
  height: 52px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #f1f5f9, #ffffff);
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
}

.owner-name {
  font-weight: 700;
}

.owner-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.owner-contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  border-radius: 0.6rem;
  cursor: pointer;
  transition: 0.2s;
}

.owner-contact-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Sticky CTA */
.modal-cta {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), #fff);
  backdrop-filter: blur(4px);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  display: flex;
  gap: 0.8rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.contact-owner-btn {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 1rem 1.25rem;
  border-radius: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: 0.2s;
  box-shadow: 0 10px 24px rgba(184, 148, 31, 0.25);
}

.contact-owner-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.favorite-btn-modal {
  background: #fff;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: 0.2s;
}

.favorite-btn-modal:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.favorite-btn-modal.favorited {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

/* Responsive (modal) */
@media (max-width: 1024px) {
  .modal-body {
    grid-template-columns: 1fr;
  }
  .gallery-main {
    aspect-ratio: 16 / 11;
  }
}

@media (max-width: 480px) {
  .gallery-main {
    aspect-ratio: 4 / 3;
  }
  .gallery-thumb {
    width: 72px;
    height: 54px;
  }
  .modal-info {
    padding: 1rem 1rem 0;
  }
  .modal-title {
    font-size: 1.2rem;
  }
}

/* Pagination */
.pagination-container {
  display: flex;
  justify-content: center;
  margin-bottom: 3rem;
}

.pagination {
  display: flex;
  gap: 0.5rem;
  max-width: 300px;
  overflow-x: scroll;
}
@media screen and (min-width:496px){
  
  .pagination{
    max-width: 430px;

  }
}
@media screen and (min-width:692px){
  
  .pagination{
    max-width: 600px;

  }
}
@media screen and (min-width:992px){
  
  .pagination{
    max-width: 750px;

  }
}

.pagination-btn {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-secondary);
  border-radius: 0.5rem;
  transition: 0.2s;
  cursor: pointer;
}

.pagination-btn:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.pagination-active {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}

