/* ============================================
   PROPERTY SEARCH PAGE - STYLES
   ============================================ */

/* ---------- SEARCH PAGE LAYOUT ---------- */
.search-page {
  padding-top: 80px;
  min-height: 100vh;
  background: var(--bg-light);
}

/* ---------- FILTER BAR ---------- */
.filter-bar {
  background: var(--bg-white);
  border-bottom: 1px solid #e8e8e8;
  padding: 20px 0;
  position: sticky;
  top: 64px;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.filter-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-search-input {
  flex: 1;
  min-width: 200px;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
  background: var(--bg-light);
}

.filter-search-input:focus {
  border-color: var(--accent);
}

.filter-select {
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  font-family: var(--font-body);
  font-size: 0.8rem;
  outline: none;
  background: var(--bg-light);
  color: var(--text-dark);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%238a8a9a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  min-width: 130px;
  transition: var(--transition);
}

.filter-select:focus {
  border-color: var(--accent);
}

.filter-price-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-price-group span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.filter-price-input {
  width: 110px;
  padding: 12px 10px;
  border: 1px solid #e0e0e0;
  font-family: var(--font-body);
  font-size: 0.8rem;
  outline: none;
  background: var(--bg-light);
  transition: var(--transition);
}

.filter-price-input:focus {
  border-color: var(--accent);
}

.filter-btn {
  padding: 12px 24px;
  background: var(--accent);
  color: var(--text-light);
  border: none;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn:hover {
  background: var(--accent-light);
}

.filter-btn.reset {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid #e0e0e0;
}

.filter-btn.reset:hover {
  color: var(--text-dark);
  border-color: var(--text-dark);
}

.filter-toggle-advanced {
  font-size: 0.8rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  border: none;
  background: none;
  font-family: var(--font-body);
  padding: 12px 4px;
}

.filter-toggle-advanced:hover {
  text-decoration: underline;
}

.advanced-filters {
  display: none;
  padding-top: 16px;
  border-top: 1px solid #eee;
  margin-top: 12px;
}

.advanced-filters.open {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* ---------- SEARCH CONTENT: SPLIT VIEW ---------- */
.search-content {
  display: flex;
  height: calc(100vh - 160px);
  overflow: hidden;
}

/* Left: Listings Panel (Sweeney: 45vw sidebar) */
.listings-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 45vw;
  max-width: 760px;
  min-width: 360px;
  background: #fff;
  border-right: 1px solid #e8e8e8;
}

/* Right: Map Panel */
.map-panel {
  flex: 1;
  position: relative;
}

#searchMap {
  width: 100%;
  height: 100%;
}

/* Panel Toolbar */
.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
}

.results-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.results-count strong {
  color: var(--text-dark);
}

/* Toggle Switch */
.view-switch {
  display: flex;
  background: var(--bg-light);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.switch-btn {
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.switch-btn.active {
  background: var(--primary);
  color: var(--text-light);
  box-shadow: 0 2px 8px rgba(26, 26, 46, 0.25);
}

.switch-btn:hover:not(.active) {
  color: var(--text-dark);
}

/* Scrollable listing grid (Sweeney: 2-col, 20px row-gap) */
.listings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-row-gap: 20px;
  grid-column-gap: 16px;
  overflow-y: auto;
  flex: 1;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
}

.listings-grid::-webkit-scrollbar {
  width: 6px;
}

.listings-grid::-webkit-scrollbar-track {
  background: transparent;
}

.listings-grid::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}

/* --- LIST MODE: full-width, no map --- */
.search-content.list-mode {
  display: block;
  height: auto;
  min-height: calc(100vh - 160px);
  overflow: visible;
  background: var(--bg-light);
}

.search-content.list-mode .map-panel {
  display: none;
}

.search-content.list-mode .listings-panel {
  width: 100%;
  max-width: none;
  min-width: unset;
  border-right: none;
  background: var(--bg-light);
}

.search-content.list-mode .panel-toolbar {
  border-bottom: 1px solid #eee;
  background: transparent;
  padding: 20px 32px;
}

.search-content.list-mode .listings-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding: 24px 32px 60px;
  overflow: visible;
}

/* ---------- LISTING CARD (Sweeney-style) ---------- */
.listing-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  will-change: box-shadow;
  transition: box-shadow 0.2s ease;
}

.listing-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.listing-card.highlighted {
  box-shadow: 0 0 0 3px var(--accent), 0 4px 20px rgba(0,0,0,0.12);
}

/* Image */
.listing-card-img {
  position: relative;
  width: 100%;
  padding-bottom: 66%;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: 16px 16px 0 0;
}

.listing-card-img img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.listing-card:hover .listing-card-img img {
  transform: scale(1.03);
}

.listing-card-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.55rem;
  padding: 3px 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
  border-radius: 4px;
  z-index: 2;
}

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

.listing-card-price {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #000;
}

.listing-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  color: #595959;
  margin-bottom: 6px;
  font-weight: 400;
}

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

.listing-card-address {
  font-size: 0.75rem;
  color: #595959;
  margin-bottom: 6px;
  line-height: 1.4;
}

.listing-card-desc {
  font-size: 0.72rem;
  line-height: 1.45;
  color: #838383;
  margin-bottom: 6px;
  overflow: hidden;
  max-height: 2.1em;
}

.listing-card-mls {
  font-size: 0.6rem;
  color: #b2b2b2;
  margin-top: 2px;
}

/* List-mode card overrides */
.search-content.list-mode .listing-card {
  border-radius: 16px;
}

.search-content.list-mode .listing-card-body {
  padding: 18px 20px;
}

.search-content.list-mode .listing-card-price {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.search-content.list-mode .listing-card-meta {
  font-size: 0.85rem;
  gap: 16px;
  margin-bottom: 8px;
}

.search-content.list-mode .listing-card-address {
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.search-content.list-mode .listing-card-desc {
  font-size: 0.82rem;
  max-height: 3.5em;
  margin-bottom: 8px;
}

.search-content.list-mode .listing-card-badge {
  font-size: 0.6rem;
  padding: 4px 10px;
}

.search-content.list-mode .listing-card-mls {
  font-size: 0.7rem;
}

.search-content.list-mode .listing-card-mls {
  font-size: 0.7rem;
}

/* Map fallback (no API key) */
.map-placeholder {
  width: 100%;
  height: 100%;
  background: #e8e8e8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.map-placeholder i {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 16px;
}

.map-placeholder h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 8px;
  font-weight: 400;
  color: var(--text-dark);
}

.map-placeholder p {
  font-size: 0.85rem;
  max-width: 300px;
}

/* Custom map info window */
.map-info-window {
  font-family: var(--font-body);
  max-width: 260px;
  padding: 4px;
}

.map-info-window img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  margin-bottom: 10px;
  border-radius: 4px;
}

.map-info-window h4 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  margin-bottom: 4px;
}

.map-info-window .info-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.map-info-window .info-address {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---------- PROPERTY DETAIL MODAL ---------- */
.property-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 24px;
  overflow-y: auto;
}

.property-modal-overlay.open {
  display: flex;
}

.property-modal {
  background: var(--bg-white);
  max-width: 1000px;
  width: 100%;
  position: relative;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-muted);
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-white);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-dark);
  transform: rotate(90deg);
}

/* Modal Gallery */
.modal-gallery {
  position: relative;
  height: 420px;
  overflow: hidden;
}

.modal-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.9);
  border: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-dark);
  transition: var(--transition);
}

.gallery-nav:hover {
  background: var(--accent);
  color: var(--text-light);
}

.gallery-prev { left: 16px; }
.gallery-next { right: 16px; }

.gallery-dots {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.gallery-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: var(--transition);
}

.gallery-dot.active {
  background: var(--accent);
}

/* Modal Body */
.modal-body {
  padding: 36px 40px;
}

.modal-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.modal-price {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 400;
}

.modal-mls {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 20px;
  padding: 20px 0;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
  margin-bottom: 24px;
}

.modal-meta-item {
  text-align: center;
}

.modal-meta-value {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--text-dark);
}

.modal-meta-label {
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-address {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.modal-address i {
  color: var(--accent);
  margin-right: 6px;
}

.modal-description {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #555;
  margin-bottom: 32px;
}

.modal-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.modal-feature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-feature i {
  color: var(--accent);
  width: 18px;
  text-align: center;
}

/* Modal Map */
.modal-map-section {
  margin-bottom: 32px;
}

.modal-map-section h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 400;
  margin-bottom: 16px;
}

#modalMap {
  width: 100%;
  height: 300px;
  background: #e8e8e8;
}

/* Modal Yelp Section */
.modal-yelp-section {
  margin-bottom: 32px;
}

.modal-yelp-section h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 400;
  margin-bottom: 6px;
}

.modal-yelp-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.yelp-category-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.yelp-cat-tab {
  padding: 8px 18px;
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  background: transparent;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
  font-family: var(--font-body);
}

.yelp-cat-tab.active,
.yelp-cat-tab:hover {
  background: var(--primary);
  color: var(--text-light);
  border-color: var(--primary);
}

.yelp-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.yelp-card {
  background: var(--bg-light);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}

.yelp-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.yelp-card-img {
  height: 140px;
  overflow: hidden;
}

.yelp-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

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

.yelp-card-body {
  padding: 14px;
}

.yelp-card-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.yelp-card-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.yelp-stars {
  color: var(--accent);
  letter-spacing: 1px;
}

.yelp-review-count {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.yelp-card-categories {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.yelp-card-distance {
  font-size: 0.7rem;
  color: #bbb;
}

.yelp-card-price {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}

/* Modal CTA */
.modal-cta {
  background: var(--bg-light);
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.modal-cta-text h4 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: 4px;
}

.modal-cta-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-cta-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- NO RESULTS ---------- */
.no-results {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.no-results i {
  font-size: 3rem;
  color: #ddd;
  margin-bottom: 16px;
}

.no-results h3 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.no-results p {
  font-size: 0.9rem;
}

/* ---------- LOADING ---------- */
.loading-spinner {
  text-align: center;
  padding: 60px 24px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #eee;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- SEARCH PAGE RESPONSIVE ---------- */
@media (max-width: 1024px) {
  .modal-gallery {
    height: 300px;
  }

  .modal-body {
    padding: 24px;
  }

  .search-content.list-mode .listings-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 20px 24px 40px;
  }
}

@media (max-width: 768px) {
  .filter-bar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-price-group {
    flex-wrap: wrap;
  }

  .filter-select {
    width: 100%;
  }

  /* Stack layout on mobile — listings on top, map below */
  .search-content {
    flex-direction: column;
    height: auto;
  }

  .listings-panel {
    width: 100% !important;
    min-width: unset !important;
    max-width: none !important;
    height: auto;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }

  .map-panel {
    height: 50vh;
  }

  .listings-grid {
    grid-template-columns: 1fr;
  }

  .search-content.list-mode .listings-panel {
    max-height: none;
  }

  .modal-gallery {
    height: 240px;
  }

  .modal-cta {
    flex-direction: column;
    text-align: center;
  }

  .yelp-results-grid {
    grid-template-columns: 1fr 1fr;
  }

  .search-content.list-mode .listings-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px 16px 40px;
  }
}

@media (max-width: 480px) {
  .yelp-results-grid {
    grid-template-columns: 1fr;
  }

  .panel-toolbar {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .view-switch {
    justify-content: center;
  }
}
