/* ============================================================
   Property & Beyond — pb-fixes.css
   PURPOSE: Fix conflicting styles, mobile responsiveness,
            and image display issues WITHOUT touching existing code.
   Load AFTER style.css and dashboard.css.
   ============================================================ */


/* ════════════════════════════════════════════════════════════
   1. GLOBAL — prevent horizontal overflow on all screens
   ════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

img, video, iframe, embed, object {
  max-width: 100%;
  height: auto;
}

.container {
  padding-left:  max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  max-width: 100%;
}


/* ════════════════════════════════════════════════════════════
   2. FIX CONFLICTING AGENT CARD DEFINITIONS
   The first definition (line ~406) sets text-align:center and
   no image wrapper; the second block (line ~619) redesigns it.
   We lock the correct final state here so the winner is clear.
   ════════════════════════════════════════════════════════════ */

/* Canonical agent card */
.agent-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  transition: transform .3s, box-shadow .3s;
  display: flex;
  flex-direction: column;
  text-align: left; /* override the old text-align:center */
}
.agent-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }

/* Image container — controlled by the AGENT CARD IMAGE FIX block below */
.agent-card-img,
.agent-card-image {
  /* height/overflow/object-fit controlled exclusively by the fix block at bottom of file */
  background: var(--gray-100, #F7F8FA);
  flex-shrink: 0;
}

.agent-card-img img,
.agent-card-image img {
  width: 100%;
  height: auto;
  display: block;
  transition: none;
}
.agent-card:hover .agent-card-img img,
.agent-card:hover .agent-card-image img {
  transform: none;
}

/* Grid: consistent for both old and new markup */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.75rem;
}


/* ════════════════════════════════════════════════════════════
   3. FIX FOOTER-GRID — three conflicting declarations merged
      The last-declared rule wins; this file loads last.
   ════════════════════════════════════════════════════════════ */
.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: .35rem; text-align: center; }
}


/* ════════════════════════════════════════════════════════════
   4. FIX SEARCH BOX — conflicting mobile overrides consolidated
   ════════════════════════════════════════════════════════════ */
@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) !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: 58px; }
  .search-box-header { overflow-x: auto; }
  .search-tab { font-size: .7rem; padding: .75rem; white-space: nowrap; }
}


/* ════════════════════════════════════════════════════════════
   5. IMAGES — correct display on all screen sizes
   ════════════════════════════════════════════════════════════ */

/* Property card images — always cover, never distort */
.property-card-image {
  position: relative;
  height: 220px;
  overflow: hidden;
  flex-shrink: 0;
}
.property-card-image a { display: block; height: 100%; }
.property-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform .5s;
}

/* Gallery main image */
.gallery-main {
  border-radius: var(--radius);
  overflow: hidden;
  height: 440px;
  background: var(--gray-100, #F7F8FA);
}
.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Gallery thumbnails */
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* About page image */
.about-home-image img,
.about-img-frame img {
  width: 100%;
  object-fit: cover;
  display: block;
}

/* Agent sidebar image — show full face */
.agent-sidebar-img,
.agent-profile-img-wrap img {
  object-fit: cover;
  object-position: top center;
}

/* Circular agent avatars — contain so full face shows */
.agent-photo,
.agent-sidebar-img.rounded,
.agent-mini img {
  object-fit: cover;
  object-position: top center;
}

/* Logo images — always contain, never crop */
.nav-logo img,
.footer-logo-img,
.sidebar-brand-logo img,
.sidebar-logo img {
  object-fit: contain;
  max-width: 100%;
  height: auto;
}
.nav-logo img    { height: 36px; }
.footer-logo-img { height: 48px; }

/* Data table property thumbnails */
.data-table img {
  width: 50px;
  height: 38px;
  object-fit: cover;
  border-radius: 5px;
  display: inline-block;
}


/* ════════════════════════════════════════════════════════════
   6. MOBILE RESPONSIVENESS — screens below 768px
   ════════════════════════════════════════════════════════════ */

/* --- Navbar --- */
@media (max-width: 900px) {
  .navbar-inner { padding: 0 1rem; }
  .nav-logo img { height: 30px; }
}
@media (max-width: 380px) {
  .nav-logo img { height: 26px; }
}

/* --- Hero --- */
@media (max-width: 768px) {
  .hero { min-height: 85vh; }
  .hero-actions { flex-direction: column; align-items: center; }
  .hero-actions .btn { width: min(280px, 90%); justify-content: center; }
  .hero-stats { gap: 1.25rem; }
  .hero-stat-number { font-size: 1.6rem; }
}
@media (max-width: 480px) {
  .hero-content { padding: 1.25rem 1rem; }
  .hero-stat-number { font-size: 1.4rem; }
}

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

/* --- Section padding --- */
@media (max-width: 768px) {
  .section    { padding: 3rem 0; }
  .section-sm { padding: 2rem 0; }
}
@media (max-width: 480px) {
  .section    { padding: 2.25rem 0; }
  .section-sm { padding: 1.5rem 0; }
}

/* --- Property cards --- */
@media (max-width: 900px) {
  .properties-grid { grid-template-columns: 1fr 1fr; gap: 1.25rem; }
}
@media (max-width: 580px) {
  .properties-grid { grid-template-columns: 1fr; }
  .property-card-image { height: 200px; }
}

/* --- Agents grid --- */
@media (max-width: 900px) {
  .agents-grid { grid-template-columns: 1fr 1fr; gap: 1.25rem; }
}
@media (max-width: 520px) {
  .agents-grid { grid-template-columns: 1fr; }
  /* agent-card-img height intentionally NOT set here — controlled by the fix block below */
}

/* --- Property detail page --- */
@media (max-width: 1100px) {
  .property-details-grid { grid-template-columns: 1fr; }
  .agent-card-sidebar { position: static; }
  .gallery-thumbs { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 768px) {
  .gallery-main { height: 260px; }
  .gallery-thumbs { grid-template-columns: repeat(4, 1fr); gap: .35rem; }
  .gallery-thumb { height: 58px; }
  .property-overview { grid-template-columns: 1fr 1fr; }
  .amenities-list, .amenities-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .gallery-main { height: 220px; }
  .gallery-thumbs { grid-template-columns: repeat(3, 1fr); }
  .gallery-thumb { height: 52px; }
  .property-specs-grid { grid-template-columns: 1fr; }
  .amenities-list, .amenities-grid { grid-template-columns: 1fr; }
  .property-info-card { padding: 1.1rem; }
}

/* --- About page --- */
@media (max-width: 1100px) {
  .about-home-grid,
  .about-story-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .about-badge { left: 1rem; bottom: -1.5rem; }
  .about-img-frame img { height: 320px; }
}
@media (max-width: 768px) {
  .about-img-frame img { height: 260px; }
  .about-img-badge { left: .75rem; bottom: -1.25rem; }
  .about-hero-actions { flex-direction: column; align-items: stretch; }
  .about-hero-actions .btn { justify-content: center; }
  .about-why-grid { grid-template-columns: 1fr; }
}

/* --- Contact page --- */
@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; }
}

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

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

/* --- Listings filters --- */
@media (max-width: 768px) {
  .filters-inner { gap: .5rem; flex-wrap: wrap; }
  .filter-select { font-size: .78rem; padding: .45rem .7rem; }
  .filters-sort { margin-left: 0; width: 100%; }
}

/* --- Small screen text safety --- */
@media (max-width: 380px) {
  h1 { font-size: clamp(1.5rem, 7vw, 2rem) !important; }
  h2 { font-size: clamp(1.2rem, 5vw, 1.65rem) !important; }
  .btn-lg { padding: .75rem 1.5rem; font-size: .875rem; }
  .container { padding: 0 .75rem; }
}


/* ════════════════════════════════════════════════════════════
   7. SERVICE / SPECIALTY PAGES — mobile fixes
   ════════════════════════════════════════════════════════════ */

/* Feasibility Study */
@media (max-width: 1100px) {
  .fs-hero-inner { grid-template-columns: 1fr; gap: 2rem; padding-bottom: 3rem; }
  .fs-hero-card  { max-width: 100%; width: 100%; }
  .fs-process-grid { grid-template-columns: 1fr; gap: 2rem; }
}
@media (max-width: 768px) {
  .fs-hero-text h1 { font-size: clamp(1.7rem, 6vw, 2.5rem); }
  .fs-hero-actions { flex-direction: column; align-items: stretch; }
  .fs-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; }
}
@media (max-width: 480px) {
  .fs-included-grid { grid-template-columns: 1fr; }
  .fs-cross-card { padding: 1.5rem; }
}

/* Property Management */
@media (max-width: 1100px) {
  .pm-hero-inner { grid-template-columns: 1fr; }
  .pm-package    { max-width: 100%; }
  .pm-what-grid  { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .pm-bento      { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .pm-stats { flex-wrap: wrap; justify-content: center; gap: 1rem; }
  .pm-stat-div { display: none; }
}
@media (max-width: 560px) {
  .pm-what-grid { grid-template-columns: 1fr; }
  .pm-bento     { grid-template-columns: 1fr; }
  .pm-bento-cell { padding: 1.5rem; }
}

/* Insurance */
@media (max-width: 1100px) {
  .ins-hero-inner    { grid-template-columns: 1fr; }
  .ins-hero-shield   { display: none; }
  .ins-coverage-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .ins-why-grid      { grid-template-columns: 1fr; gap: 2.5rem; }
}
@media (max-width: 768px) {
  .ins-cta-content { flex-direction: column; align-items: flex-start; }
  .ins-cta-content > a { margin-left: 0; width: 100%; justify-content: center; }
}
@media (max-width: 480px) {
  .ins-coverage-grid { grid-template-columns: 1fr; }
  .ins-hero-h1 { font-size: 2rem; }
}

/* Service showcase */
@media (max-width: 768px) {
  .svc-panels { grid-template-columns: 1fr; gap: 1rem; }
  .svc-panel--hero { grid-column: span 1; }
}


/* ════════════════════════════════════════════════════════════
   8. DASHBOARD — mobile layout stability
   ════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(260px, 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; }
}
@media (max-width: 480px) {
  .sidebar { width: 88vw; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .stat-card { padding: 1rem; }
  .stat-number { font-size: 1.35rem; }
  .page-content { padding: .75rem; }
  .card-body { padding: .9rem; }
}
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
}


/* ════════════════════════════════════════════════════════════
   9. PRELOADER STYLES
   ════════════════════════════════════════════════════════════ */
#pb-preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #231F20;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.5rem;
  transition: opacity .5s ease, visibility .5s ease;
}

#pb-preloader.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pb-loader-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}

.pb-loader-wordmark {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #fff;
}

.pb-loader-wordmark span {
  color: #00ADEF;
}

.pb-loader-bar {
  width: 160px;
  height: 2px;
  background: rgba(255,255,255,.1);
  border-radius: 2px;
  overflow: hidden;
}

.pb-loader-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ADEF, #3A4FC0);
  border-radius: 2px;
  animation: pbFill 1.4s ease forwards;
}

@keyframes pbFill {
  0%   { width: 0%; }
  60%  { width: 75%; }
  100% { width: 100%; }
}




/* ════════════════════════════════════════════════════════════
   AGENT CARD IMAGE FIX — complete portrait always visible
   Approach: no fixed height on container, image renders at
   its natural aspect ratio (800x1200 = 2:3 portrait).
   Background fills any space around it.
   ════════════════════════════════════════════════════════════ */

/* Strip ALL height from the container — let the image drive it */
.agent-card-img,
.agent-card-image {
  width: 100% !important;
  height: auto !important;
  min-height: unset !important;
  max-height: unset !important;
  aspect-ratio: unset !important;
  overflow: visible !important;
  background: #f4f5f7 !important;
  display: block !important;
  flex-shrink: 0 !important;
}

/* Image: full width, natural height — never cropped */
.agent-card-img img,
.agent-card-image img {
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: unset !important;
  min-height: unset !important;
  object-fit: unset !important;    /* don't use object-fit at all */
  display: block !important;
  transition: none !important;
}

/* No zoom on hover */
.agent-card:hover .agent-card-img img,
.agent-card:hover .agent-card-image img {
  transform: none !important;
}

/* ════════════════════════════════════════════════════════════
   ADMIN DASHBOARD MOBILE IMPROVEMENTS
   Extra safety rules on top of dashboard.css
   ════════════════════════════════════════════════════════════ */

/* Ensure table wrappers always scroll horizontally */
.card > div[style*="overflow"] {
  -webkit-overflow-scrolling: touch;
}

/* Action button groups don't wrap awkwardly on mobile */
@media (max-width: 640px) {
  /* Agent/property action buttons in tables */
  .data-table td > div[style*="display:flex"] {
    flex-wrap: wrap;
    gap: 0.25rem !important;
  }
  /* Ensure buttons stay tappable size */
  .btn-sm {
    min-height: 32px;
    min-width: 32px;
  }
}

@media (max-width: 480px) {
  /* Stack search form fields vertically */
  .card-body form[method="GET"] > div[style*="display:flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .card-body form[method="GET"] button[type="submit"],
  .card-body form[method="GET"] a.btn {
    width: 100%;
    justify-content: center;
  }
}


/* ════════════════════════════════════════════════════════════
   PROPERTY FORM — RESPONSIVE LAYOUT (Add & Edit)
   Replaces hardcoded inline grid-template-columns on all
   property-add / property-edit pages (admin + agent).
   ════════════════════════════════════════════════════════════ */

/* ── Main layout: content + sidebar ─────────────────────── */
.prop-form-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

/* ── Inside cards: 3-col row (price / area / year) ───────── */
.prop-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

/* ── Inside cards: 4-col row (beds/baths/garage/floors) ──── */
.prop-row-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 1rem;
}

/* ── Inside cards: 2-col row (city/state, zip/country) ───── */
.prop-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Amenities grid: 3 columns ───────────────────────────── */
.prop-amenities-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

/* ── Amenity label ───────────────────────────────────────── */
.prop-amenity-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.4rem;
  border-radius: 4px;
  transition: background .15s;
}
.prop-amenity-label:hover { background: var(--gray-100); }

/* ── Tablet: sidebar drops below main content ────────────── */
@media (max-width: 960px) {
  .prop-form-layout {
    grid-template-columns: 1fr;
  }
  /* Sidebar actions row — buttons side by side */
  .prop-sidebar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .prop-sidebar-actions .btn-full { grid-column: 1 / -1; }
}

/* ── Mobile: all multi-col rows collapse to 1 or 2 ──────── */
@media (max-width: 640px) {
  .prop-row-3 {
    grid-template-columns: 1fr 1fr;  /* price+area on one row, year below */
  }
  .prop-row-4 {
    grid-template-columns: 1fr 1fr;  /* beds+baths / garage+floors */
  }
  .prop-row-2 {
    grid-template-columns: 1fr;
  }
  .prop-amenities-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 400px) {
  .prop-row-3,
  .prop-row-4 {
    grid-template-columns: 1fr;
  }
  .prop-amenities-grid {
    grid-template-columns: 1fr;
  }
  .prop-sidebar-actions {
    grid-template-columns: 1fr;
  }
}

/* ── Upload area — full tap target on mobile ─────────────── */
@media (max-width: 480px) {
  .upload-area {
    padding: 1.5rem 1rem;
  }
  .upload-area p:first-of-type {
    font-size: 0.9rem;
  }
}

/* ── Visibility toggles (admin) — stack neatly ───────────── */
.prop-visibility-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── btn-full: full-width button utility ─────────────────── */
.btn-full {
  width: 100%;
  justify-content: center;
}

/* ── prop-sidebar-actions on desktop: stack vertically ───── */
@media (min-width: 961px) {
  .prop-sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .prop-sidebar-actions .btn-full { width: 100%; }
}