/* === Listings Page Styles === */

/* ── Filters Bar ── */
.listings-filters {
  background: linear-gradient(to bottom, #ffffff 0%, var(--gray-bg) 100%);
  border-bottom: 2px solid var(--gray-lighter);
  padding: 16px 32px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 10px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.filter-group select {
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  border: 2px solid var(--gray-lighter);
  border-radius: var(--radius);
  outline: none;
  transition: all 0.3s;
  background: white;
  color: var(--text);
  min-width: 120px;
}

.filter-group select:focus {
  border-color: var(--blue-bright);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.filter-search-btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 28px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: var(--black);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
  box-shadow: var(--shadow);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  align-self: flex-end;
}

.filter-search-btn:hover {
  background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold) 100%);
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

.filter-search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ── Results Summary ── */
.listings-summary {
  padding: 10px 32px;
  font-size: 13px;
  color: var(--gray);
  border-bottom: 1px solid var(--gray-lighter);
  background: var(--gold-pale);
  font-weight: 500;
  letter-spacing: 0.3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.listings-summary .sort-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.listings-summary .sort-controls select {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--gray-lighter);
  border-radius: 4px;
  background: white;
}

/* ── Layout: Map + Grid ── */
.listings-layout {
  display: flex;
  height: calc(100vh - 240px);
  min-height: 500px;
}

.listings-map-container {
  flex: 1;
  min-width: 0;
  position: relative;
}

#listings-map {
  width: 100%;
  height: 100%;
}

.listings-grid {
  width: 420px;
  overflow-y: auto;
  border-left: 2px solid var(--gray-lighter);
  background: var(--gray-bg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Listing Card ── */
.listing-card {
  background: white;
  border-radius: var(--radius);
  border: 2px solid var(--gray-lighter);
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  flex-shrink: 0; /* prevent flex column from crushing cards */
}

.listing-card:hover {
  border-color: var(--blue-bright);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.listing-card.highlighted {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}

.listing-card-image {
  width: 100%;
  height: 180px;
  background-color: var(--gray-pale);
  position: relative;
  overflow: hidden;
}

.listing-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.listing-card-no-photo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--gray-light);
  font-weight: 500;
}

.listing-card-label {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--gold);
  color: var(--navy-dark);
}

.listing-card-price {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 20px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  font-family: var(--font-sans);
}

.listing-card-body {
  padding: 12px 14px;
}

.listing-card-address {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 2px;
  line-height: 1.3;
}

.listing-card-city {
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 8px;
}

.listing-card-details {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--text);
}

.listing-card-details span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.listing-card-details .detail-label {
  font-size: 11px;
  color: var(--gray);
  font-weight: 500;
}

.listing-card-type {
  font-size: 11px;
  color: var(--gray-light);
  margin-top: 6px;
}

/* ── Map Popup ── */
.map-popup {
  font-family: var(--font-sans);
  min-width: 200px;
}

.map-popup-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-dark);
  margin-bottom: 4px;
}

.map-popup-address {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.map-popup-city {
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 6px;
}

.map-popup-details {
  font-size: 12px;
  color: var(--gray-dark);
}

.map-popup-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue-bright);
  text-decoration: none;
}

.map-popup-link:hover {
  text-decoration: underline;
}

/* ── No Results ── */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray);
}

.no-results h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--navy);
  margin-bottom: 8px;
}

/* ── View Toggle ── */
.view-toggle {
  display: flex;
  gap: 4px;
}

.view-toggle button {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border: 1px solid var(--gray-lighter);
  background: white;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
}

.view-toggle button:first-child { border-radius: 4px 0 0 4px; }
.view-toggle button:last-child { border-radius: 0 4px 4px 0; }

.view-toggle button.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

/* ── Grid-Only View ── */
.listings-layout.grid-only .listings-map-container {
  display: none;
}

.listings-layout.grid-only .listings-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  height: auto;
  border-left: none;
  padding: 20px 32px;
  max-width: 1400px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .listings-layout {
    flex-direction: column;
    height: auto;
  }

  .listings-map-container {
    height: 350px;
  }

  .listings-grid {
    width: 100%;
    border-left: none;
    border-top: 2px solid var(--gray-lighter);
    max-height: none;
    overflow-y: visible;
  }

  .listings-filters { padding: 12px 20px; }
  .listings-summary { padding: 8px 20px; }
}

@media (max-width: 600px) {
  .listings-filters {
    flex-direction: column;
    align-items: stretch;
  }

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

  .filter-search-btn {
    width: 100%;
  }

  .listing-card-image {
    height: 150px;
  }
}

/* ── Print ── */
@media print {
  .listings-map-container,
  .listings-filters,
  .listings-summary,
  .view-toggle { display: none !important; }

  .listings-layout {
    display: block;
    height: auto;
  }

  .listings-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border: none;
    padding: 0;
  }

  .listing-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
