/* ============================================================
   Property & Beyond — pb-responsive.css
   LOAD ORDER: After style.css and pb-fixes.css

   PURPOSE:
   1. Fix all image display (contain / cover, no cropping)
   2. Full mobile-first responsiveness
   3. Agent card image face-preservation
   4. Consistent spacing & card balance
   5. Zero PHP changes — CSS-only

   Brand: #00ADEF · #3A4FC0 · #231F20
   ============================================================ */


/* ════════════════════════════════════════════════════════════
   §0  BASE SAFETY NET
   ════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Keep body overflow default — do NOT override with visible or hidden here.
   The nav drawer fix is handled via JS (padding-right trick) and
   z-index in §10 below. Changing body overflow-x breaks layout. */
body {
  max-width: 100%;
}

/* Every media element respects its container */
img, video, iframe, embed, object, svg {
  max-width: 100%;
  display: block;
}

/* Safe-area padding on container (notched phones) */
.container {
  padding-left:  max(1.25rem, env(safe-area-inset-left,  1.25rem));
  padding-right: max(1.25rem, env(safe-area-inset-right, 1.25rem));
}


/* ════════════════════════════════════════════════════════════
   §1  PROPERTY CARD IMAGES — full visibility, no cropping
   ════════════════════════════════════════════════════════════ */

/* Container keeps a stable aspect ratio on any screen */
.property-card-image {
  position: relative;
  width: 100%;
  height: 220px;           /* desktop default */
  overflow: hidden;
  flex-shrink: 0;
  background: var(--gray-100, #F7F8FA);
}

/* Anchor must fill the container completely */
.property-card-image > a {
  display: block;
  width: 100%;
  height: 100%;
}

/* The image itself — cover keeps full width, centers vertically */
.property-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  transition: transform 0.5s ease;
}

.property-card:hover .property-card-image img {
  transform: scale(1.04);
}

/* Shrink image container slightly on small tablets */
@media (max-width: 900px) {
  .property-card-image { height: 200px; }
}

/* On single-column mobile, a taller image looks better */
@media (max-width: 560px) {
  .property-card-image { height: 210px; }
}


/* ════════════════════════════════════════════════════════════
   §2  AGENT CARD IMAGES — face ALWAYS fully visible, never cropped
   ════════════════════════════════════════════════════════════ */

/* Unify both markup variants: .agent-card-img (new) and
   .agent-card-image (legacy) */
.agent-card-img,
.agent-card-image {
  width: 100%;
  height: 260px;
  overflow: hidden;
  flex-shrink: 0;
  /* Neutral dark background — visible behind contain letterbox bars */
  background: #1e1c1f;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-card-img img,
.agent-card-image img {
  width: 100%;
  height: 100%;
  /* contain = entire photo always visible, ZERO cropping ever */
  object-fit: contain;
  object-position: center top;
  display: block;
  transition: transform 0.5s ease;
}

.agent-card:hover .agent-card-img img,
.agent-card:hover .agent-card-image img {
  transform: scale(1.03);
}

@media (max-width: 900px) {
  .agent-card-img,
  .agent-card-image { height: 230px; }
}

@media (max-width: 560px) {
  .agent-card-img,
  .agent-card-image { height: 210px; }
}


/* ════════════════════════════════════════════════════════════
   §3  AGENT PROFILE PAGE — image + layout
   ════════════════════════════════════════════════════════════ */

/* Profile card left column */
.agent-profile-img-wrap {
  width: 100%;
  height: 320px;
  overflow: hidden;
  background: #1e1c1f;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-profile-img-wrap img {
  width: 100%;
  height: 100%;
  /* contain so the full portrait photo is always visible */
  object-fit: contain;
  object-position: center top;
  display: block;
}

/* Circular avatar (sidebar + detail view) */
.agent-sidebar-img,
.agent-photo {
  object-fit: cover;
  object-position: center 10%;
}

/* Agent mini thumbnail in property card footer */
.agent-mini img {
  object-fit: cover;
  object-position: center 10%;
}

/* Two-column profile grid → one column on tablet */
@media (max-width: 1024px) {
  .agent-profile-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .agent-profile-card { position: static; }
  .agent-profile-img-wrap { height: 260px; }
}

@media (max-width: 600px) {
  .agent-profile-img-wrap { height: 220px; }
  .agent-profile-info { padding: 1.25rem; }
  .agent-profile-name { font-size: 1.3rem; }
  .agent-stats-row { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
}

@media (max-width: 420px) {
  .agent-profile-img-wrap { height: 190px; }
  .agent-stats-row { grid-template-columns: 1fr; }
}


/* ════════════════════════════════════════════════════════════
   §4  GALLERY IMAGES (property detail page)
   ════════════════════════════════════════════════════════════ */

.gallery-main {
  border-radius: var(--radius, 10px);
  overflow: hidden;
  height: 460px;
  background: var(--gray-100, #F7F8FA);
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  transition: opacity 0.2s, transform 0.2s;
}

.gallery-thumb {
  height: 70px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

@media (max-width: 768px) {
  .gallery-main      { height: 280px; }
  .gallery-thumbs    { grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
  .gallery-thumb     { height: 60px; }
}

@media (max-width: 480px) {
  .gallery-main      { height: 230px; }
  .gallery-thumbs    { grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
  .gallery-thumb     { height: 52px; }
}


/* ════════════════════════════════════════════════════════════
   §5  LOGO IMAGES — always contained, never distorted
   ════════════════════════════════════════════════════════════ */

.nav-logo img,
.sidebar-brand-logo img,
.sidebar-logo img {
  object-fit: contain;
  height: 36px;
  width: auto;
  max-width: 160px;
}

.footer-logo-img,
.footer-brand-logo img {
  object-fit: contain;
  height: 48px;
  width: auto;
  max-width: 180px;
}

/* Login / auth page logo */
.login-logo img {
  max-height: 56px;
  width: auto;
  object-fit: contain;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .nav-logo img { height: 30px; }
}
@media (max-width: 380px) {
  .nav-logo img { height: 26px; }
}


/* ════════════════════════════════════════════════════════════
   §6  ABOUT SECTION IMAGE
   ════════════════════════════════════════════════════════════ */

.about-home-image,
.about-img-frame {
  border-radius: var(--radius, 10px);
  overflow: hidden;
}

.about-home-image img,
.about-img-frame img {
  width: 100%;
  height: 480px;
  object-fit: cover;
  object-position: center center;
  display: block;
}

@media (max-width: 1100px) {
  .about-home-grid,
  .about-story-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .about-home-image img,
  .about-img-frame img { height: 360px; }
  .about-badge { left: 1rem; bottom: -1.5rem; }
}

@media (max-width: 768px) {
  .about-home-image img,
  .about-img-frame img { height: 280px; }
}

@media (max-width: 480px) {
  .about-home-image img,
  .about-img-frame img { height: 220px; }
}


/* ════════════════════════════════════════════════════════════
   §7  DATA TABLE THUMBNAILS (dashboard)
   ════════════════════════════════════════════════════════════ */

.data-table td img,
.data-table th img {
  width: 52px;
  height: 40px;
  object-fit: cover;
  object-position: center;
  border-radius: 5px;
  display: inline-block;
  flex-shrink: 0;
}


/* ════════════════════════════════════════════════════════════
   §8  PROPERTIES GRID — responsive columns
   ════════════════════════════════════════════════════════════ */

.properties-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.75rem;
}

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

@media (max-width: 640px) {
  .properties-grid { grid-template-columns: 1fr; gap: 1.25rem; }
}

/* Property card balance */
.property-card {
  display: flex;
  flex-direction: column;
  height: 100%;      /* equal-height cards in grid */
}

.property-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.property-card-footer {
  margin-top: auto;
}


/* ════════════════════════════════════════════════════════════
   §9  AGENTS GRID — responsive columns
   ════════════════════════════════════════════════════════════ */

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.75rem;
}

/* Agent card layout balance */
.agent-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-align: left;     /* override old centred variant */
}

.agent-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.4rem 1.25rem 1.25rem;
}

/* Push the CTA button to the bottom of every card */
.agent-card-body .btn:last-child {
  margin-top: auto;
}

@media (max-width: 900px) {
  .agents-grid { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
}

@media (max-width: 500px) {
  .agents-grid { grid-template-columns: 1fr; }
}


/* ════════════════════════════════════════════════════════════
   §10  NAVBAR — mobile safe + drawer clip fix
   ════════════════════════════════════════════════════════════ */

.navbar-inner {
  padding-left:  max(1rem, env(safe-area-inset-left,  1rem));
  padding-right: max(1rem, env(safe-area-inset-right, 1rem));
}

/* Hamburger touch target ≥ 44 × 44 px */
.hamburger {
  min-width: 44px;
  min-height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0 8px;
}

@media (max-width: 900px) {
  .hamburger { display: flex; }
}

/* Nav drawer: ensure it sits above everything including the preloader.
   style.css already sets position:fixed on .nav-menu inside @media max-width:900px
   We reinforce z-index here so it's never buried under other stacking contexts. */
@media (max-width: 900px) {
  .nav-menu {
    z-index: 9999 !important;
    /* bottom:0 ensures it fills full height on all devices */
    bottom: 0 !important;
  }
  .nav-overlay {
    z-index: 9998 !important;
  }
}


/* ════════════════════════════════════════════════════════════
   §11  HERO SECTION — mobile
   ════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .hero { min-height: 90vh; }
  .hero-content { padding: 1.75rem 1rem; }

  .hero-actions {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }
  .hero-actions .btn {
    width: min(300px, 90%);
    justify-content: center;
  }

  .hero-stats {
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  .hero-stat-number { font-size: 1.7rem; }
}

@media (max-width: 480px) {
  .hero-stat-number { font-size: 1.4rem; }
  .hero-stat-label  { font-size: 0.65rem; }
  .hero-stats       { gap: 1rem; }
}


/* ════════════════════════════════════════════════════════════
   §12  SEARCH BOX — mobile
   ════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .search-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .search-field { border-right: none !important; }
  .search-field:nth-child(odd) {
    border-right: 1px solid var(--gray-200, #E5E1E1) !important;
  }
  .search-submit { grid-column: 1 / -1; }
  .search-submit .btn { width: 100%; min-width: unset; }
}

@media (max-width: 560px) {
  .search-grid { grid-template-columns: 1fr !important; }
  .search-field { border-right: none !important; min-height: 60px; }
  .search-box-header { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .search-tab { font-size: 0.7rem; padding: 0.75rem; white-space: nowrap; }
}


/* ════════════════════════════════════════════════════════════
   §13  PROPERTY DETAIL PAGE
   ════════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .property-details-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .agent-card-sidebar {
    position: static !important;
  }
}

@media (max-width: 768px) {
  .property-overview {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .amenities-list,
  .amenities-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .property-overview    { grid-template-columns: repeat(2, 1fr); }
  .property-specs-grid  { grid-template-columns: 1fr; }
  .amenities-list,
  .amenities-grid       { grid-template-columns: 1fr; }
  .property-info-card   { padding: 1.1rem; }
  .overview-item        { padding: 0.85rem 0.5rem; }
  .overview-value       { font-size: 1.1rem; }
}


/* ════════════════════════════════════════════════════════════
   §14  FOOTER — responsive
   ════════════════════════════════════════════════════════════ */

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 2.5rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

@media (max-width: 1100px) {
  .footer-grid { grid-template-columns: 2fr 1fr 1fr; gap: 2rem; }
}
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.75rem; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
  .footer-desc { max-width: 100%; }
  .footer-bottom {
    flex-direction: column;
    gap: 0.4rem;
    text-align: center;
  }
}


/* ════════════════════════════════════════════════════════════
   §15  SECTION PADDING — mobile scale-down
   ════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .section    { padding: 3.5rem 0; }
  .section-sm { padding: 2.25rem 0; }
}
@media (max-width: 480px) {
  .section    { padding: 2.5rem 0; }
  .section-sm { padding: 1.75rem 0; }
}


/* ════════════════════════════════════════════════════════════
   §16  PAGE BANNER — mobile
   ════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .page-banner {
    padding: calc(var(--navbar-h, 60px) + 2rem) 0 2rem;
  }
  .page-banner h1 {
    font-size: clamp(1.4rem, 6vw, 2rem);
  }
}


/* ════════════════════════════════════════════════════════════
   §17  FORMS — mobile
   ════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Minimum touch target for all buttons */
.btn {
  min-height: 44px;
}

.btn-sm {
  min-height: 38px;
}


/* ════════════════════════════════════════════════════════════
   §18  CONTACT PAGE — mobile
   ════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .contact-grid { grid-template-columns: 1fr; gap: 2rem; }
}
@media (max-width: 480px) {
  .contact-icon,
  .contact-info-icon { width: 42px; height: 42px; min-width: 42px; }
  .map-container,
  .map-placeholder { height: 220px; }
}


/* ════════════════════════════════════════════════════════════
   §19  DASHBOARD SIDEBAR + CONTENT — mobile
   ════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(270px, 85vw);
    height: 100dvh;
    height: 100vh;  /* fallback */
    z-index: 400;
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.4);
  }
  .main-content { margin-left: 0 !important; }
  .edit-grid    { grid-template-columns: 1fr !important; }
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 600px) {
  .stats-grid  { grid-template-columns: 1fr 1fr !important; }
  .page-content { padding: 1rem !important; }
  .card-header  { flex-wrap: wrap; gap: 0.5rem; }
  .data-table th,
  .data-table td { padding: 0.6rem 0.75rem; font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .sidebar        { width: 88vw; }
  .stats-grid     { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .stat-card      { padding: 1rem; }
  .stat-number    { font-size: 1.35rem; }
  .page-content   { padding: 0.75rem !important; }
  .card-body      { padding: 0.9rem; }
}

@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
}


/* ════════════════════════════════════════════════════════════
   §20  CTA SECTION — mobile
   ════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .cta-section { padding: 3.5rem 0; }
  .cta-buttons {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }
  .cta-buttons .btn {
    width: min(300px, 90%);
    justify-content: center;
  }
}


/* ════════════════════════════════════════════════════════════
   §21  LISTINGS PAGE FILTERS — mobile
   ════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .filters-inner {
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .filter-select {
    font-size: 0.78rem;
    padding: 0.45rem 0.7rem;
    min-height: 44px;
  }
  .filters-sort {
    margin-left: 0;
    width: 100%;
  }
}


/* ════════════════════════════════════════════════════════════
   §22  SERVICE PAGES — mobile (Feasibility / PM / Insurance)
   ════════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .fs-hero-inner,
  .pm-hero-inner,
  .ins-hero-inner { grid-template-columns: 1fr; gap: 2rem; padding-bottom: 3rem; }
  .fs-hero-card,
  .pm-package      { max-width: 100%; width: 100%; }
  .fs-process-grid { grid-template-columns: 1fr; gap: 2rem; }
  .pm-what-grid    { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .pm-bento        { grid-template-columns: 1fr 1fr; }
  .ins-coverage-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .ins-why-grid    { grid-template-columns: 1fr; gap: 2.5rem; }
  .ins-hero-shield { display: none; }
}

@media (max-width: 768px) {
  .fs-hero-text h1 { font-size: clamp(1.7rem, 6vw, 2.5rem); }
  .fs-hero-actions,
  .about-hero-actions { flex-direction: column; align-items: stretch; }
  .fs-hero-actions .btn,
  .about-hero-actions .btn { width: 100%; justify-content: center; }
  .fs-included-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .fs-cross-grid    { grid-template-columns: 1fr; }
  .pm-stats         { flex-wrap: wrap; justify-content: center; gap: 1rem; }
  .pm-stat-div      { display: none; }
  .ins-cta-content  { flex-direction: column; align-items: flex-start; }
  .ins-cta-content > a { margin-left: 0; width: 100%; justify-content: center; }
  .svc-panels       { grid-template-columns: 1fr; gap: 1rem; }
  .svc-panel--hero  { grid-column: span 1; }
  .about-why-grid   { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .fs-included-grid  { grid-template-columns: 1fr; }
  .fs-cross-card     { padding: 1.5rem; }
  .pm-what-grid      { grid-template-columns: 1fr; }
  .pm-bento          { grid-template-columns: 1fr; }
  .pm-bento-cell     { padding: 1.5rem; }
  .ins-coverage-grid { grid-template-columns: 1fr; }
  .ins-hero-h1       { font-size: 2rem; }
}


/* ════════════════════════════════════════════════════════════
   §23  SMALL-SCREEN TYPOGRAPHY SAFETY
   ════════════════════════════════════════════════════════════ */

@media (max-width: 380px) {
  h1 { font-size: clamp(1.5rem, 8vw, 2rem) !important; }
  h2 { font-size: clamp(1.2rem, 6vw, 1.65rem) !important; }
  .btn-lg { padding: 0.75rem 1.5rem; font-size: 0.875rem; }
  .container { padding-left: 0.75rem; padding-right: 0.75rem; }
}


/* ════════════════════════════════════════════════════════════
   §24  HORIZONTAL-SCROLL PREVENTION (final catch-all)
   ════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Tables that might overflow */
  .data-table-wrap,
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Cards should never punch out of their column */
  .property-card,
  .agent-card,
  .agent-bio-card,
  .property-info-card {
    max-width: 100%;
  }

  /* Any inline element that might overflow */
  pre, code {
    white-space: pre-wrap;
    word-break: break-word;
  }
}
