/* ============================================================
   TERRANOVA - RESPONSIVE CSS
   Mobile-first supplemental responsive rules
   ============================================================ */

/* ── PROPERTY LISTINGS GRID / LIST ──────────────────────────
   Used by lands.js and buildings.js for resultsContainer.
   CRITICAL: These were missing — root cause of layout overlap.
   ─────────────────────────────────────────────────────────── */
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  width: 100%;
}

.prop-grid .property-card {
  min-width: 0;      /* prevent grid blowout */
  width: 100%;
}

.prop-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

@media (min-width: 640px) {
  .prop-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 28px; }
}
@media (min-width: 1024px) {
  .prop-grid { grid-template-columns: repeat(3, 1fr); gap: 32px; }
}
@media (max-width: 639px) {
  .prop-grid { grid-template-columns: 1fr; gap: 16px; }
}

/* ── LISTINGS LAYOUT (sidebar + results) ─────────────────── */
.listings-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 1023px) {
  .listings-layout {
    grid-template-columns: 1fr;
  }
  .filter-sidebar {
    display: none;
  }
  .filter-sidebar.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 900;
    overflow-y: auto;
    background: var(--bg-surface);
    padding: 24px;
  }
}

/* ── LIST CARD LAYOUT ────────────────────────────────────── */
.list-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.list-card:hover { border-color: var(--border-gold); box-shadow: var(--shadow-md); }
.list-card__img { width: 200px; height: 160px; object-fit: cover; display: block; }
.list-card__body { padding: 1.25rem; }
@media (max-width: 640px) {
  .list-card { grid-template-columns: 1fr; }
  .list-card__img { width: 100%; height: 180px; }
}



/* ── PREVENT GLOBAL HORIZONTAL OVERFLOW */
body { width: 100%; }

/* SECTION PADDING MOBILE FIRST */
.section { padding: var(--space-2xl) 0; }
@media (min-width: 640px) { .section { padding: var(--space-3xl) 0; } }
@media (min-width: 1024px) { .section { padding: var(--space-4xl) 0; } }

/* SECTION HEADER */
.section-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
@media (min-width: 768px) { .section-header { flex-direction: row; align-items: flex-end; } }

/* LISTING CARD MIN-WIDTH ON CAROUSEL */
.carousel-track .property-card { min-width: min(280px, 85vw); }
@media (min-width: 640px) { .carousel-track .property-card { min-width: 320px; } }

/* CARDS GRID */
.cards-grid { grid-template-columns: 1fr; }
@media (min-width: 480px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .cards-grid { grid-template-columns: repeat(3, 1fr); } }

/* HERO CONTENT */
.hero__ctas { flex-wrap: wrap; gap: 0.75rem; }
.hero__ctas .btn { flex: 1 1 140px; text-align: center; max-width: 100%; }
@media (min-width: 480px) { .hero__ctas .btn { flex: none; } }

/* NAVBAR */
.navbar { padding: var(--space-sm) 0; }
.navbar__inner { gap: var(--space-xs); }
.navbar__logo { gap: 6px; }
.navbar__logo img { width: 36px; height: 36px; }
.navbar__logo-text { font-size: 1rem; display: flex; flex-direction: column; line-height: 1.1; }
.navbar__logo-text span { font-size: 0.65rem; }
.hamburger { margin-left: auto; }

@media (min-width: 480px) { 
  .navbar__logo-text { font-size: 1.2rem; flex-direction: row; gap: 4px; } 
  .navbar__logo-text span { font-size: inherit; }
}
@media (min-width: 768px) { 
  .navbar__logo-text { font-size: 1.5rem; } 
  .navbar { padding: var(--space-md) 0; }
  .navbar__inner { gap: var(--space-md); }
  .navbar__logo { gap: 10px; }
  .navbar__logo img { width: 44px; height: 44px; }
}

/* PAGE HERO & MAIN HERO */
.hero__content { padding-top: clamp(120px, 16vw, 160px) !important; }
.page-hero { min-height: 40vh; padding-top: clamp(120px, 16vw, 160px); padding-bottom: var(--space-2xl); display: flex; align-items: center; }
@media (min-width: 768px) { .page-hero { min-height: 50vh; } }

/* ABOUT PAGE GRIDS */
.about-values-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media (min-width: 480px) { .about-values-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .about-values-grid { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; } }

.about-team-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media (min-width: 480px) { .about-team-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .about-team-grid { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; } }

/* CONTACT PAGE */
.contact-methods-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
@media (min-width: 640px) { .contact-methods-grid { grid-template-columns: repeat(4, 1fr); gap: 1rem; } }

.contact-section { width: 100%; padding: 48px 16px; }
@media (min-width: 1024px) { .contact-section { padding: 80px 24px; } }

.contact-container { display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; width: 100%; max-width: 1200px; margin: 0 auto; }
.contact-container > * { min-width: 0; width: 100%; max-width: 100%; }
@media (min-width: 1024px) { .contact-container { grid-template-columns: minmax(0, 1fr) minmax(320px, 520px); gap: 56px; align-items: start; } }

.form-two-col { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 480px) { .form-two-col { grid-template-columns: 1fr 1fr; } }

/* PROPERTY DETAIL MEDIA */
.detail-media-grid { grid-template-columns: 1fr !important; height: auto !important; }
.detail-media-grid img { height: 220px; width: 100%; object-fit: cover; }
@media (min-width: 600px) {
  .detail-media-grid { grid-template-columns: 1fr 1fr !important; height: 420px !important; }
  .detail-media-grid img { height: 100%; }
}

/* FLYOUT PANEL */
.flyout { width: 100%; max-width: 420px; }
@media (max-width: 480px) { .flyout { width: 100%; max-width: 100%; } }

/* TOAST CONTAINER */
@media (max-width: 480px) {
  .toast-container { left: var(--space-md); right: var(--space-md); top: var(--space-md); }
  .toast { min-width: auto; width: 100%; }
}

/* MODAL SIZING */
.modal { max-width: 480px; width: calc(100% - 2rem); }
@media (max-width: 480px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; width: 100%; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-top-left-radius: var(--radius-xl); border-top-right-radius: var(--radius-xl); padding: var(--space-xl); }
}

/* SEARCH WIDGET */
.search-field { min-width: 0; }
.search-widget { overflow: hidden; }
@media (max-width: 767px) {
  .search-widget { padding: 1rem; }
  .search-widget__row { gap: 0.75rem; }
  .search-field__input { font-size: 0.85rem; }
}

/* PILL TOGGLE */
.pill-toggle { flex-wrap: wrap; }

/* SORT BAR */
@media (max-width: 480px) {
  .sort-bar { flex-direction: column; align-items: flex-start; }
  .sort-bar select { width: 100%; max-width: 100% !important; }
}

/* FILTER TOGGLE BUTTON */
.filter-toggle-btn { display: none; }
@media (max-width: 1023px) {
  .filter-toggle-btn { display: flex; margin-bottom: 1rem; }
  .filter-sidebar { display: none; }
  .filter-sidebar.open { display: block; }
}

/* IFRAME */
iframe { max-width: 100%; }

/* SECTION HEADER WRAPPING */
.section-header > div:last-child { flex-wrap: wrap; }

/* PROPERTY TITLE ROW */
@media (max-width: 640px) {
  #propTitleRow { flex-direction: column; align-items: flex-start; }
  #propTitleRow > div:last-child { text-align: left; }
  #propTitleRow > div:last-child > div:last-child { justify-content: flex-start; }
}

/* HERO STATS */
.hero__stats { flex-wrap: wrap; gap: var(--space-lg); }
@media (max-width: 480px) { .hero__stat-value { font-size: 1.4rem; } }

/* FOOTER GRID */
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 640px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; gap: 3rem; } }

/* LANDSCAPE PHONE */
@media (max-height: 480px) and (orientation: landscape) {
  .hero, .page-hero { min-height: 100svh; padding-top: 70px; }
  .hero__headline { font-size: 1.6rem; }
  .hero__search-wrap { margin-top: 1rem; }
  .mobile-nav { display: none; }
  body { padding-bottom: 0; }
}

/* OVERFLOW ON SMALL SCREENS */
.carousel-wrap { overflow: hidden; }
.subcategory-tabs { overflow-x: auto; flex-wrap: nowrap; }
@media (max-width: 767px) { .subcategory-tabs { flex-wrap: wrap; } }

/* 480px and below */
@media (max-width: 480px) {
  .hero__headline { font-size: 2rem; }
  .search-widget__row { flex-direction: column; align-items: stretch; }
  .search-divider { display: none; }
  .page-hero { min-height: 35vh !important; }
  .listing-layout { grid-template-columns: 1fr !important; }
  .filter-sidebar { position: static !important; width: 100% !important; }
  .compare-bar { border-radius: 0 !important; left: 0 !important; right: 0 !important; transform: none !important; bottom: 60px !important; }
  .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 640px; }
  .modal-overlay .modal { max-width: 100% !important; width: 100% !important; max-height: 95vh !important; margin: auto 0 0 0 !important; border-bottom-left-radius: 0 !important; border-bottom-right-radius: 0 !important; border-top-left-radius: var(--radius-xl) !important; border-top-right-radius: var(--radius-xl) !important; }
  .modal-overlay { align-items: flex-end !important; }
}

/* 412px */
@media (max-width: 412px) {
  .container { padding: 0 16px; }
  .hero__headline { font-size: 1.85rem; line-height: 1.1; }
  .hero__sub { font-size: 0.9rem; }
  .btn-lg { padding: 14px 24px; font-size: 0.9rem; }
  .property-card__meta { flex-wrap: wrap; gap: 0.35rem; }
  .stat-card { padding: 1rem; }
  .stat-card__value { font-size: 1.5rem; }
  .kanban-column { min-width: 170px !important; }
  .category-grid { gap: 1rem; }
}

/* 390px */
@media (max-width: 390px) {
  :root { --space-xl: 1.25rem; --space-2xl: 1.75rem; --space-3xl: 2.5rem; --space-4xl: 3.5rem; }
  .hero__headline { font-size: 1.75rem; }
  .section-title { font-size: 1.5rem !important; }
  .search-widget { padding: 0.875rem; }
  .search-widget__actions { flex-direction: column; }
  .search-widget__actions .btn { width: 100%; }
  .detail-media { height: 200px !important; }
  .detail-media img { height: 200px; }
  .bhk-strip { gap: 0.4rem; }
  .bhk-pill { padding: 6px 12px; font-size: 0.75rem; }
}

/* 375px */
@media (max-width: 375px) {
  .hero__headline { font-size: 1.65rem; }
  .navbar__logo-text { font-size: 0.95rem; }
  .property-card__price { font-size: 1.1rem; }
  .property-card__title { font-size: 0.85rem; }
  #wizardStepIndicator { display: none; }
  .listing-stats-grid { grid-template-columns: 1fr 1fr !important; }
}

/* 360px */
@media (max-width: 360px) {
  .container { padding: 0 12px; }
  .hero__headline { font-size: 1.5rem; }
  .hero__eyebrow { font-size: 0.65rem; }
  .btn { padding: 10px 18px; font-size: 0.8rem; }
  .btn-lg { padding: 12px 20px; }
  .subcategory-tab { padding: 8px 12px; font-size: 0.72rem; }
  .bhk-pill { padding: 5px 10px; font-size: 0.7rem; }
  .property-card__body { padding: 0.875rem; }
  .modal .modal__header h3 { font-size: 0.95rem; }
  #pipelineStats { grid-template-columns: repeat(3, 1fr) !important; }
}

/* TABLE RESPONSIVENESS */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }