/* =====================================================================
   BMRV PROPERTIES — RESPONSIVE.CSS
   Full responsive system: Mobile-first breakpoints
   xs  < 480px  (small phones)
   sm  < 640px  (phones)
   md  < 768px  (large phones / small tablets)
   lg  < 1024px (tablets / small laptops)
   xl  ≥ 1024px (desktops — default layout)
   ===================================================================== */

/* ── Viewport meta is set in PHP headers ── */

/* =====================================================================
   BASE GLOBAL
   ===================================================================== */
html {
  scroll-behavior: smooth;
}

*, *::before, *::after {
  box-sizing: border-box;
}

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

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

/* =====================================================================
   HEADER & NAV
   ===================================================================== */

/* Hamburger menu animation */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* =====================================================================
   ADMIN SIDEBAR — MOBILE TOGGLE
   ===================================================================== */
.admin-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 42px;
  height: 42px;
  background: var(--blue-dark);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}

.admin-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.admin-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 150;
}

/* =====================================================================
   LG BREAKPOINT — Tablets (≤ 1024px)
   ===================================================================== */
@media (max-width: 1024px) {
  /* Header */
  .site-header {
    padding: 14px 20px;
    gap: 16px;
  }

  .brand-logo {
    width: 58px;
    height: 44px;
  }

  /* Grids */
  .admin-grid {
    grid-template-columns: 1fr !important;
  }

  .admin-grid.wide-form {
    grid-template-columns: 1fr !important;
  }

  .property-form {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Property showcase */
  .property-showcase .category-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 18px !important;
  }

  /* Service list */
  .service-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Tables — allow horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  /* Admin sidebar stays full-width under nav on tablets */
  .admin-body {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

/* =====================================================================
   MD BREAKPOINT — Large phones / small tablets (≤ 768px)
   ===================================================================== */
@media (max-width: 768px) {

  /* ── Nav ── */
  .nav-toggle {
    display: flex;
  }

  .site-header {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px;
  }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-bottom: 10px;
    order: 3;
  }

  .site-nav.open {
    display: flex;
  }

  .site-nav a {
    padding: 12px 10px;
    border-radius: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 1rem;
  }

  .nav-action {
    text-align: center;
    margin-top: 4px;
  }

  /* ── Admin sidebar → drawer ── */
  .admin-menu-btn {
    display: flex;
  }

  .admin-body {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100vh;
    z-index: 160;
    transition: left 0.3s ease;
    overflow-y: auto;
  }

  .admin-sidebar.sidebar-open {
    left: 0;
  }

  .admin-sidebar-overlay.visible {
    display: block;
  }

  .admin-main {
    padding: 16px;
    padding-top: 64px; /* space for floating menu btn */
  }

  /* ── Hero ── */
  .hero {
    min-height: 60vh;
  }

  .hero-content {
    padding: 40px 18px;
  }

  .hero-wrapper {
    flex-direction: column;
    min-height: auto;
  }

  .md-card {
    flex: none;
    max-width: 100%;
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 16px 18px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    gap: 14px;
  }

  .md-card-inner {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: auto;
  }

  .md-card-inner img {
    width: 70px;
    max-width: 70px;
    border-radius: 6px;
  }

  .md-label {
    border-top: none;
    padding: 0;
    background: transparent;
    border-radius: 0;
    max-width: unset;
  }

  /* ── Sections ── */
  .section {
    padding: 44px 18px;
  }

  /* ── Grids ── */
  .intro-grid,
  .split-section,
  .contact-layout {
    grid-template-columns: 1fr;
  }

  .contact-layout .form-panel {
    max-width: 100%;
    justify-self: stretch;
  }

  .category-grid,
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .stats-band {
    grid-template-columns: 1fr;
  }

  .stats-band div {
    padding: 22px 18px;
  }

  /* ── Property form ── */
  .property-form,
  .two-column-form {
    grid-template-columns: 1fr !important;
  }

  /* ── Admin ── */
  .admin-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  .admin-title h1 {
    font-size: clamp(1.6rem, 6vw, 2.4rem);
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-card strong {
    font-size: 1.6rem;
  }

  /* ── Tables ── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }

  table {
    min-width: 540px;
    font-size: 0.88rem;
  }

  th, td {
    padding: 10px 8px;
  }

  /* ── Footer ── */
  .footer-cards {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .footer-card {
    min-height: auto;
    padding: 18px;
  }

  .footer-social-bottom {
    justify-content: center;
    flex-wrap: wrap;
  }

  .footer-copy {
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
  }

  /* ── Service list ── */
  .service-list {
    grid-template-columns: 1fr !important;
  }

  .service-list article {
    display: block !important;
    min-height: auto !important;
  }

  .service-list article img {
    height: 180px !important;
    min-height: 180px !important;
    width: 100%;
    object-fit: cover;
  }

  .service-list article div {
    padding: 18px !important;
  }

  /* ── Property showcase ── */
  .property-showcase {
    padding: 40px 18px;
  }

  .property-showcase .category-grid {
    grid-template-columns: 1fr !important;
    max-width: 440px !important;
    margin: 0 auto;
  }

  .property-showcase .category-grid article {
    min-height: auto !important;
  }

  .property-showcase .category-grid article img {
    height: 180px !important;
  }

  .property-showcase .category-heading h2 {
    white-space: normal !important;
    font-size: clamp(1.6rem, 7vw, 2.4rem) !important;
  }

  /* ── Login ── */
  .login-page {
    padding: 16px;
  }

  .login-card {
    width: 100%;
  }

  /* ── Tabs ── */
  .tabs {
    gap: 6px;
  }

  .tabs a {
    padding: 8px 11px;
    font-size: 0.88rem;
  }

  /* ── Messages grid ── */
  .msg-grid {
    grid-template-columns: 1fr !important;
    padding: 0 14px 24px;
  }

  /* ── Page hero ── */
  .page-hero {
    min-height: 36vh;
    padding: 50px 18px 30px;
  }
}

/* =====================================================================
   SM BREAKPOINT — Phones (≤ 640px)
   ===================================================================== */
@media (max-width: 640px) {

  /* ── Typography scale ── */
  h1 { font-size: clamp(2rem, 9vw, 3rem) !important; }
  h2 { font-size: clamp(1.5rem, 7vw, 2.2rem) !important; }

  /* ── Hero ── */
  .hero {
    min-height: 55vh;
  }

  .hero-content p {
    font-size: 0.98rem;
  }

  .hero-actions {
    gap: 10px;
  }

  .button {
    min-height: 42px;
    padding: 10px 16px;
    font-size: 0.95rem;
  }

  /* ── Category grid → 1 column ── */
  .category-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Metric grid → 2 col still ── */
  .metric-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Admin ── */
  .admin-main {
    padding: 14px;
    padding-top: 62px;
  }

  /* ── Forms ── */
  input, select, textarea {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* ── Marquee ── */
  .welcome-marquee span {
    font-size: 0.95rem;
  }
}

/* =====================================================================
   XS BREAKPOINT — Small phones (≤ 400px)
   ===================================================================== */
@media (max-width: 400px) {

  .site-header {
    padding: 10px 12px;
  }

  .brand-logo {
    width: 48px;
    height: 38px;
  }

  .brand span {
    font-size: 0.85rem;
  }

  .metric-grid {
    grid-template-columns: 1fr !important;
  }

  .metric-card strong {
    font-size: 1.4rem;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 8px 6px;
  }

  .admin-main {
    padding: 10px;
    padding-top: 58px;
  }

  .admin-title h1 {
    font-size: 1.5rem;
  }

  .tabs a {
    font-size: 0.82rem;
    padding: 7px 9px;
  }

  .footer-social-bottom a {
    width: 30px;
    height: 30px;
  }
}

/* =====================================================================
   PRINT
   ===================================================================== */
@media print {
  .site-header,
  .site-footer,
  .admin-sidebar,
  .admin-menu-btn,
  .nav-toggle,
  .hero-actions,
  .tabs,
  .report-actions {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  table {
    min-width: unset;
    font-size: 0.82rem;
  }

  .admin-main {
    padding: 0 !important;
  }
}
