/* ============================================
   IDX Search — Desert Editorial Theme
   ============================================ */

/* --- Filter Bar --- */
.idx-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: end;
  margin-bottom: var(--sp-8);
  padding: var(--sp-5);
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.idx-filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1;
  min-width: 140px;
}

.idx-filter-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.idx-filter-select {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--ink-1);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23544e44' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.idx-filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(138, 103, 48, 0.15);
}

/* --- Results Header --- */
.idx-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-6);
}

.idx-results-header h2 {
  margin: 0;
}

#idx-result-count {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink-3);
}

/* --- Card Overrides for IDX --- */
.card--idx .card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card--idx .card__price {
  font-family: var(--font-display);
  font-variant-numeric: lining-nums;
}

/* Zestimate */
.card__zestimate {
  font-size: 0.72rem;
  color: var(--ink-3, #687789);
  font-family: var(--font-body);
  margin-top: -0.1rem;
  margin-bottom: 0.25rem;
  font-variant-numeric: lining-nums;
}

/* Status badges */
.idx-badge--active { background: #1a7a3a; color: #fff; }
.idx-badge--pending { background: #b8860b; color: #fff; }
.idx-badge--sold { background: #8b2500; color: #fff; }

/* Source badge */
.idx-source-badge {
  position: absolute;
  top: var(--sp-3, 0.75rem);
  right: var(--sp-3, 0.75rem);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.idx-source--zillow { background: #006AFF; }

/* Days on market tag */
.idx-dom {
  position: absolute;
  bottom: var(--sp-2);
  left: var(--sp-2);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
}

/* --- Skeleton Loading --- */
.idx-skeleton {
  pointer-events: none;
}

.idx-skeleton__image {
  height: 220px;
  background: linear-gradient(90deg, var(--surface-2) 25%, #e8e3d9 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: idx-shimmer 1.5s infinite;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.idx-skeleton__line {
  background: linear-gradient(90deg, var(--surface-2) 25%, #e8e3d9 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: idx-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.idx-skeleton__price { height: 28px; width: 45%; margin-bottom: var(--sp-2); }
.idx-skeleton__title { height: 20px; width: 80%; margin-bottom: var(--sp-2); }
.idx-skeleton__text { height: 16px; width: 60%; margin-bottom: var(--sp-4); }
.idx-skeleton__details { display: flex; gap: var(--sp-3); }
.idx-skeleton__detail { height: 16px; width: 60px; }

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

/* --- Load More --- */
.idx-load-more-wrap {
  text-align: center;
  padding: var(--sp-8) 0;
}

/* --- Modal --- */
.idx-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
}

.idx-modal--open {
  visibility: visible;
  opacity: 1;
}

.idx-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.idx-modal__container {
  position: relative;
  background: var(--surface-1);
  border-radius: var(--radius-xl);
  max-width: 960px;
  width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
}

.idx-modal__close {
  position: sticky;
  top: var(--sp-3);
  float: right;
  margin: var(--sp-3);
  z-index: 10;
  background: var(--surface-1);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.idx-modal__close:hover {
  background: var(--surface-2);
}

.idx-modal__body {
  padding: var(--sp-6);
}

.idx-modal__loading {
  text-align: center;
  padding: var(--sp-12);
  color: var(--ink-3);
  font-family: var(--font-body);
}

/* --- Detail Layout --- */
.idx-detail__gallery {
  margin-bottom: var(--sp-6);
}

.idx-detail__main-img {
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  margin-bottom: var(--sp-3);
}

.idx-detail__main-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.idx-detail__thumbs {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
}

.idx-detail__thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  flex-shrink: 0;
  border: 2px solid transparent;
}

.idx-detail__thumb:hover,
.idx-detail__thumb--active {
  opacity: 1;
  border-color: var(--accent);
}

.idx-detail__more-photos {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 54px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--ink-3);
  flex-shrink: 0;
}

/* Detail Info */
.idx-detail__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.idx-detail__price {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: lining-nums;
}

.idx-detail__address {
  font-size: var(--text-lg);
  margin-bottom: var(--sp-6);
  color: var(--ink-2);
  font-weight: 400;
}

.idx-detail__stats {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.idx-detail__stat {
  text-align: center;
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  flex: 1;
}

.idx-detail__stat-value {
  display: block;
  font-weight: 700;
  font-size: var(--text-xl);
  font-variant-numeric: lining-nums;
}

.idx-detail__stat-label {
  font-size: var(--text-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.idx-detail__section {
  margin-bottom: var(--sp-6);
}

.idx-detail__section h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  margin-bottom: var(--sp-3);
  color: var(--ink-1);
}

.idx-detail__section p {
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--ink-2);
}

.idx-detail__details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2) var(--sp-6);
}

.idx-detail__details-grid > div {
  display: flex;
  justify-content: space-between;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--text-sm);
}

.idx-detail__label {
  color: var(--ink-3);
}

/* CTA Section */
.idx-detail__cta {
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-top: var(--sp-6);
  border: 1px solid var(--border-light);
}

.idx-detail__agent {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.idx-detail__courtesy {
  font-size: var(--text-xs);
  color: var(--ink-3);
  margin-top: var(--sp-4);
  font-style: italic;
}

/* --- MLS Disclaimer --- */
.idx-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  margin-top: var(--sp-8);
}

.idx-disclaimer img {
  height: 40px;
  flex-shrink: 0;
}

.idx-disclaimer p {
  font-size: var(--text-xs);
  color: var(--ink-3);
  line-height: 1.6;
  margin: 0;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  .idx-filter-bar {
    flex-direction: column;
    gap: var(--sp-3);
  }

  .idx-filter-group {
    min-width: 100%;
  }

  .idx-detail__stats {
    flex-wrap: wrap;
  }

  .idx-detail__stat {
    flex: 1 1 calc(50% - var(--sp-2));
  }

  .idx-detail__details-grid {
    grid-template-columns: 1fr;
  }

  .idx-modal__container {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .idx-detail__price {
    font-size: var(--text-2xl);
  }
}

@media (max-width: 480px) {
  .idx-detail__thumb {
    width: 48px;
    height: 36px;
  }
  .idx-detail__more-photos {
    min-width: 48px;
    height: 36px;
    font-size: 0.6rem;
  }
  .idx-detail__stat-value { font-size: var(--text-lg); }
  .idx-detail__stat-label { font-size: 0.6rem; }
  .idx-detail__section { margin-bottom: var(--sp-4); }
  .idx-detail__section h3 { font-size: var(--text-base); }
}

/* --- Tour Modal (from listing cards) --- */
.idx-tour-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
}

.idx-tour-modal.is-open {
  visibility: visible;
  opacity: 1;
}

.idx-tour-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
}

.idx-tour-modal__container {
  position: relative;
  width: 92vw;
  max-width: 1100px;
  height: 80vh;
  background: var(--surface-light, #fefefe);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}

.idx-tour-modal__header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #f1f1f1;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.idx-tour-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #3e3e3e;
  padding: 0 0.25rem;
  margin-left: 1rem;
  line-height: 1;
}

.idx-tour-modal__close:hover { color: #B44539; }

.idx-tour-modal__embed {
  flex: 1;
  position: relative;
}

.idx-tour-modal__embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

@media (max-width: 768px) {
  .idx-tour-modal__container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}
