/**
 * Listings Styles
 * Filter badges, grid layout, and listing cards
 */

/* ============================================================
   Listings Section
   ============================================================ */
.listings-section {
  padding: 60px 0;
  background: #ffffff;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  width: 100vw;
}

.listings-header {
  text-align: center;
  padding: 48px 20px;
  box-sizing: border-box;
  min-height: 300px; /* plain gradient/title banner (directories, no-photo listings hero) */
  margin-bottom: 0;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  width: 100vw;
  background-color: var(--primary-color); /* fallback for very old browsers */
  background: linear-gradient(135deg, var(--primary-color) 0%, color-mix(in srgb, var(--primary-color) 55%, #000) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s;
}

.listings-header.loaded {
  opacity: 1;
}

.listings-header h1 {
  font-size: 2.5rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 12px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.listings-header p {
  font-size: 1.125rem;
  color: #ffffff;
  opacity: 0.95;
}

/* Photo hero: the inline style supplies "linear-gradient(scrim), url(photo)";
   here we just make it cover the band. No photo set -> the brand gradient above. */
.listings-header.has-photo {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* Only the photo hero tracks the image's 12:5 (1920×800) ratio, so a
     1920×800 photo shows WHOLE with no crop across desktop/tablet. Floored
     for phones, capped so ultrawide stays sane. Directory/title banners keep
     the modest min-height above. */
  height: 41.667vw;
  min-height: 360px;
  max-height: 800px;
}

/* Search bar living inside the hero (search-first, over the photo/gradient) */
.hero-search {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin: 28px auto 0;
}

.hero-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
  font-size: 1.05rem;
  pointer-events: none;
}

.hero-search-input {
  width: 100%;
  height: 56px;
  box-sizing: border-box;
  padding: 0 18px 0 48px;
  border: none;
  border-radius: 999px;
  font-size: 1.05rem;
  background: #fff;
  color: #1f2937;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.hero-search-input:focus {
  outline: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18), 0 0 0 3px rgba(var(--primary-color-rgb), 0.35);
}

/* ============================================================
   Filter Panel
   ============================================================ */
/* Floating white card that overlaps the bottom of the hero. */
.filters-container {
  position: relative;
  z-index: 2;
  background: #ffffff;
  border: 1px solid #eef0f3;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  padding: 22px 24px;
  margin-top: -56px;
  margin-bottom: 36px;
}

/* Top row: search + sort */
.filters-bar {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filters-search {
  position: relative;
  flex: 1 1 280px;
}

.filters-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.45;
  font-size: 0.95rem;
  pointer-events: none;
}

.filters-search-input {
  width: 100%;
  height: 46px;
  box-sizing: border-box;
  padding: 0 14px 0 42px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filters-sort {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filters-sort label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

.filters-select,
.filters-input {
  height: 44px;
  box-sizing: border-box;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 0.92rem;
  background: #fff;
  color: #1f2937;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filters-select {
  cursor: pointer;
  min-width: 170px;
  padding-right: 36px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.6' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.filters-search-input:focus,
.filters-select:focus,
.filters-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.15);
}

.filter-group {
  margin-bottom: 16px;
}

.filter-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.filter-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-badge {
  display: inline-block;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.filter-badge:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(var(--primary-color-rgb), 0.06);
}

.filter-badge.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.30);
}

.filter-badge.active:hover {
  background: var(--primary-color);
  color: #fff;
  filter: brightness(0.95);
}

/* Location + price row */
.filters-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 170px;
}

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

.filter-price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-price-inputs .filters-input {
  width: 100%;
}

.filter-price-dash {
  color: #9ca3af;
}

/* Active chips + result count */
.filters-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f3f5;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(var(--primary-color-rgb), 0.3);
  background: rgba(var(--primary-color-rgb), 0.08);
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.filter-chip:hover {
  background: rgba(var(--primary-color-rgb), 0.16);
}

.filter-chip-x {
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.7;
}

.filter-chip:hover .filter-chip-x {
  opacity: 1;
}

.filter-chip-clear {
  border: none;
  background: none;
  color: #6b7280;
  font-size: 0.82rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 6px;
}

.filter-chip-clear:hover {
  color: #374151;
}

.filter-result-count {
  font-size: 0.9rem;
  color: #6b7280;
  font-weight: 500;
  white-space: nowrap;
  margin-left: auto;
}

/* Show more */
.listings-more {
  text-align: center;
  margin-top: 32px;
}

.btn-show-more {
  padding: 12px 28px;
  border-radius: 10px;
  border: 1px solid var(--primary-color);
  background: #fff;
  color: var(--primary-color);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-show-more:hover {
  background: var(--primary-color);
  color: #fff;
}

@media (max-width: 640px) {
  .filters-container {
    padding: 18px 16px;
    margin-top: -36px;
  }
  .filters-summary {
    align-items: flex-start;
  }
  .filter-result-count {
    margin-left: 0;
  }
}

/* ============================================================
   Listings Grid
   ============================================================ */
.listings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 40px;
}

@media (max-width: 1024px) {
  .listings-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

@media (max-width: 768px) {
  .listings-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Single listing - full width with proportional image height */
.listing-card:only-child {
  grid-column: 1 / -1; /* Span all columns to match header width */
}

.listing-card:only-child .listing-card-image {
  height: 400px; /* Proportional height for wider card */
}

.listing-card:only-child .listing-card-content {
  text-align: center; /* Center-align content for better balance */
}

.listing-card:only-child .listing-card-badges {
  justify-content: center; /* Center badges */
}

.listing-card:only-child .listing-card-location {
  justify-content: center; /* Center location */
}

.listing-card:only-child .listing-card-cta {
  margin: 0 auto; /* Center CTA button */
}

/* ============================================================
   Listing Card
   ============================================================ */
.listing-card {
  background: white;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
}

.listing-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.listing-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 3rem;
}

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

.listing-card-badge.media {
  background: transparent;
  padding: 4px 4px;
  font-size: 1.1rem;
}

.listing-card-content {
  padding: 20px;
}

.listing-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.listing-card-badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.listing-card-badge.category {
  background: #DBEAFE;
  color: #1E40AF;
}

.listing-card-badge.buy,
.listing-card-badge.sale {
  background: #D1FAE5;
  color: #065F46;
}

.listing-card-badge.lease {
  background: #FEF3C7;
  color: #92400E;
}

.listing-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1F2937;
  margin-bottom: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 48px;
}

.listing-card-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}

.listing-card-location {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #6B7280;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.listing-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: #3B82F6;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  text-decoration: none;
}

.listing-card-cta:hover {
  background: #2563EB;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #9CA3AF;
  grid-column: 1 / -1;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.empty-state-message {
  font-size: 1.125rem;
  margin-bottom: 8px;
}

.empty-state-hint {
  font-size: 0.875rem;
  color: #D1D5DB;
}

/* ============================================================
   Loading State
   ============================================================ */
.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: #9CA3AF;
  grid-column: 1 / -1;
}

/* ============================================================
   Home Contact Section
   ============================================================ */
.home-contact-section {
  padding: 60px 20px;
  background: #F9FAFB;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  width: 100vw;
  text-align: center;
}

.home-contact-section .home-contact-inner {
  max-width: 720px;
  margin: 0 auto;
}

.home-contact-section h2 {
  font-size: 2rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.home-contact-section .home-contact-name {
  font-size: 1.125rem;
  color: #374151;
  margin-bottom: 4px;
}

.home-contact-section .home-contact-tagline {
  font-size: 1rem;
  color: #6B7280;
  margin-bottom: 28px;
}

.home-contact-section .home-contact-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.home-contact-section .home-contact-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--primary-color);
  color: #ffffff;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 72px;
  transition: filter 0.15s, transform 0.05s;
}

.home-contact-section .home-contact-btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.home-contact-section .home-contact-btn:active {
  transform: scale(0.98);
}

.home-contact-section .home-contact-btn .home-contact-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.home-contact-section .home-contact-btn.whatsapp { background: #25D366; }
.home-contact-section .home-contact-btn.messenger { background: #0084FF; }
.home-contact-section .home-contact-btn.email { background: #6B7280; }

/* ============================================================
   Listing detail contact bar — small colored buttons in a card
   (same palette as the homepage contact buttons, compact + inline)
   ============================================================ */
#listingContactBar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.contact-name {
  flex-basis: 100%;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.1rem;
}

/* Reusable colored contact badge (listing detail + broker page) */
.listing-contact-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.45em 0.85em;
  border-radius: 8px;
  background: var(--primary-color);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.listing-contact-item:hover { filter: brightness(1.08); text-decoration: none; }
.listing-contact-item:active { transform: scale(0.98); }

.listing-contact-item .contact-icon { font-size: 1em; }
.listing-contact-item .contact-copy-hint { font-size: 0.78em; opacity: 0.85; font-weight: 500; }

.listing-contact-item.whatsapp { background: #25D366; }
.listing-contact-item.messenger { background: #0084FF; }
.listing-contact-item.email { background: #6B7280; }
.listing-contact-item.phone { background: var(--primary-color); }

/* ============================================================
   Standalone org listings page — the org's own branded header
   ============================================================ */
.org-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.75rem 0;
}
.org-header .container { display: flex; align-items: center; }
.org-header-link { display: inline-flex; align-items: center; text-decoration: none; }
.org-header-logo { max-height: 44px; width: auto; display: block; }
.org-header-name { font-size: 1.25rem; font-weight: 700; color: var(--primary-color); }
/* Context-scoped nav on the org/broker header (right-aligned) */
.org-header .header-nav { margin-left: auto; display: flex; gap: 1.25rem; align-items: center; }
.org-header .header-nav .nav-link { text-decoration: none; color: #374151; font-weight: 600; white-space: nowrap; }
.org-header .header-nav .nav-link:hover,
.org-header .header-nav .nav-link.active { color: var(--primary-color); }
/* Broker-identity header (photo + name) */
.broker-header-link { gap: 0.6rem; }
.broker-header-photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; }
.broker-header-noimg { width: 40px; height: 40px; border-radius: 50%; background: #eef; display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.broker-header-name { font-size: 1.15rem; font-weight: 700; color: var(--primary-color); }
