/*
 * ============================================================
 *  MADANAPALLE PROPERTIES — Mobile & Android WebView
 *  v3.3 — Clean rewrite, no !important wars
 *  Works: Android WebView, Chrome Mobile, iOS Safari
 *  Breakpoints: <360 | 360-479 | 480-767 | 768-959 | 960+
 * ============================================================
 */

/* ============================================================
   0. GLOBAL RESETS
   ============================================================ */
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }

/* ============================================================
   1. FIXED TOP APP BAR (mobile only)
   ============================================================ */
@media (max-width: 959px) {

  #site-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    /* Cover notch on iPhone / Android */
    padding-top: env(safe-area-inset-top, 0px);
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    z-index: 1000;
  }

  #site-header.scrolled { box-shadow: 0 2px 10px rgba(0,0,0,0.12); }

  /* Hide desktop navigation — bottom nav replaces it */
  .mobile-menu-toggle,
  .mp-mobile-drawer,
  .site-nav,
  .header-cta { display: none !important; }

  .header-inner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 56px;
    gap: 0;
  }

  .logo-tagline { display: none; }
  .logo-emblem  { width: 34px; height: 34px; font-size: 15px; }
  .logo-name    { font-size: 0.875rem; }

  /* Push page content below fixed header + notch */
  body.mp-theme {
    padding-top: calc(56px + env(safe-area-inset-top, 0px));
  }
}

/* ============================================================
   2. BOTTOM NAVIGATION BAR
   ============================================================ */
@media (max-width: 959px) {

  .mp-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    /* Covers home-bar on iPhone, gesture nav on Android */
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid #E5E7EB;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    display: flex;
    z-index: 999;
    -webkit-tap-highlight-color: transparent;
  }

  .mp-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;   /* iOS / Android minimum tap target */
    padding: 4px 2px;
    text-decoration: none;
    color: #9CA3AF;
    font-size: 9.5px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: color 150ms;
  }

  .mp-bottom-nav-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(220,38,38,0.09);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms;
  }
  .mp-bottom-nav-item:active::after { opacity: 1; }

  .bnav-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 30px;
    border-radius: 14px;
    transition: background 150ms, transform 120ms;
  }

  .mp-bottom-nav-item:active .bnav-icon-wrap {
    transform: scale(0.88);
  }

  .bnav-icon-wrap svg {
    width: 28px;
    height: 28px;
  }

  .bnav-label {
    font-size: 9.5px;
    line-height: 1;
    white-space: nowrap;
    font-weight: 500;
    letter-spacing: 0.01em;
  }

  .mp-bottom-nav-item.active       { color: #B91C1C; }
  .mp-bottom-nav-item.active .bnav-icon-wrap { background: #FFF0F0; }
  .mp-bottom-nav-item.bnav-wa      { color: #16A34A; }
  .mp-bottom-nav-item.bnav-wa .bnav-icon-wrap { background: #DCFCE7; }

  /* Hide old floating WhatsApp button */
  .whatsapp-float { display: none; }

  /* Bottom padding: nav + safe area + gap */
  body.mp-theme {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 12px);
  }
}

/* ============================================================
   3. PROPERTY GRID — responsive columns
   ============================================================ */

/* Single column: tiny phones */
@media (max-width: 479px) {
  .property-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Two columns: 480px+ phones & small tablets */
@media (min-width: 480px) and (max-width: 767px) {
  .property-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* Three columns: medium tablets */
@media (min-width: 768px) and (max-width: 959px) {
  .property-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

/* ============================================================
   4. PROPERTY CARD — mobile overrides
      Base vertical layout defined in style.css (v3.3).
      These overrides only adjust sizing per breakpoint.
   ============================================================ */

/* ── All mobile sizes ── */
@media (max-width: 959px) {

  .property-card {
    border-radius: 12px;
    /* Tap press feedback */
    transition: transform 100ms ease, box-shadow 100ms ease;
  }
  .property-card:active {
    transform: scale(0.982);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }
  /* Kill hover transform on touch screens (it "sticks" on Android) */
  @media (hover: none) {
    .property-card:hover { transform: none; }
  }

  /* Card header */
  .property-card-visual {
    padding: 8px 10px 7px;
    gap: 7px;
  }
  .property-card-icon-bg { width: 34px; height: 34px; flex: 0 0 34px; }
  .card-type-badge        { font-size: 0.6rem; padding: 0.18rem 0.45rem; max-width: 90px; }
  .card-id-badge          { font-size: 0.52rem; padding: 0.15rem 0.38rem; }

  /* Card body */
  .property-card-body { padding: 8px 10px 0; }
  .property-card-area { font-size: 0.82rem; margin-bottom: 5px; }

  /* Details */
  .prop-details-row   { gap: 3px 6px; margin-bottom: 6px; padding-bottom: 6px; }
  .prop-detail-label  { font-size: 0.55rem; }
  .prop-detail-value  { font-size: 0.73rem; }

  /* Price */
  .prop-price-row   { padding: 5px 8px; }
  .prop-price-label { font-size: 0.55rem; }
  .prop-price-value { font-size: 0.9rem; }

  /* Action buttons */
  .prop-card-side-actions { padding: 7px 10px 10px; gap: 5px; }
  .prop-side-btn          { height: 40px; font-size: 0.7rem; border-radius: 8px; gap: 4px; }
  .prop-side-btn-share    { flex: 0 0 38px; width: 38px; }
  .prop-side-btn svg      { width: 13px; height: 13px; }
}

/* ── 2-column narrow (480–767px): extra compact ── */
@media (min-width: 480px) and (max-width: 767px) {

  .property-card-icon-bg  { width: 30px; height: 30px; flex: 0 0 30px; }
  .card-type-badge        { max-width: 70px; font-size: 0.55rem; }
  .property-card-area     { font-size: 0.75rem; -webkit-line-clamp: 2; }
  .prop-detail-label      { font-size: 0.52rem; }
  .prop-detail-value      { font-size: 0.68rem; }
  .prop-price-value       { font-size: 0.82rem; }
  .prop-side-btn          { height: 36px; font-size: 0.65rem; }
  .prop-side-btn-share    { flex: 0 0 34px; width: 34px; }

  /* On very narrow 2-col cards: hide WA button text, icon only */
  .prop-side-btn-wa span:not(svg) { display: none; }
  .prop-side-btn-wa svg           { width: 16px; height: 16px; }

  /* Admin row too cramped — hide on 2-col */
  .prop-admin-row { display: none; }
}

/* ── Tiny phones 360px and below: single col but still compact ── */
@media (max-width: 359px) {
  .property-card-body { padding: 7px 8px 0; }
  .prop-price-value   { font-size: 0.85rem; }
}

/* ============================================================
   5. FILTER BAR — 2-col grid on mobile, full-width on tiny
   ============================================================ */
@media (max-width: 959px) {

  .filter-bar   { padding: 12px 12px; border-radius: 10px; margin-bottom: 12px; }
  .filter-bar-label { margin-bottom: 8px; font-size: 0.65rem; }

  /* 2-col grid: area | type on row 1, minPrice | maxPrice on row 2 */
  .filter-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    align-items: end;
  }

  /* Sort and Clear span both columns */
  .filter-form .filter-group:nth-last-child(1),
  .filter-form .filter-group:nth-last-child(2) {
    grid-column: 1 / -1;
  }

  .filter-group label {
    font-size: 0.58rem;
    margin-bottom: 3px;
  }

  /* Prevent iOS zoom on focus (must be exactly 16px) */
  .filter-group select,
  .filter-group input {
    font-size: 16px;
    padding: 9px 28px 9px 9px;
    border-radius: 8px;
    -webkit-appearance: none;
    appearance: none;
    /* Custom dropdown arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236B7280' d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
    background-size: 13px;
  }
}

/* Single col on very tiny screens */
@media (max-width: 360px) {
  .filter-form { grid-template-columns: 1fr; }
  .filter-form .filter-group:nth-last-child(1),
  .filter-form .filter-group:nth-last-child(2) { grid-column: auto; }
}

/* ============================================================
   6. ALL INPUTS — prevent iOS zoom (16px minimum everywhere)
   ============================================================ */
@media (max-width: 959px) {

  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="search"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: #DC2626;
    box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
    outline: none;
  }

  /* All tappable elements: minimum 44px */
  .btn, button, a.btn, [role="button"] { min-height: 44px; }

  /* But allow the small share icon to stay compact */
  .prop-side-btn-share { min-height: 36px; }
}

/* ============================================================
   7. REQUIREMENTS GRID
   ============================================================ */
@media (max-width: 399px) {
  .requirements-grid { grid-template-columns: 1fr; gap: 10px; }
}
@media (min-width: 400px) and (max-width: 959px) {
  .requirements-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* ============================================================
   8. HERO — compact on mobile, no horizontal overflow
   ============================================================ */
@media (max-width: 959px) {
  .hero        { padding: 20px 0 36px; overflow-x: hidden; }
  .hero-inner  { gap: 24px; }

  .hero h1,
  .hero-text h1 {
    font-size: clamp(1.4rem, 6.5vw, 2rem);
    line-height: 1.15;
  }

  .hero-badge   { flex-wrap: wrap; margin-bottom: 14px; }
  .hero-stats   { flex-wrap: wrap; gap: 10px 18px; }
  .hero-actions { flex-wrap: wrap; gap: 8px; }
  .hero-actions .btn { justify-content: center; }

  /* Quick browse pills: horizontal scroll, no wrap */
  .quick-browse {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 4px;
  }
  .quick-browse::-webkit-scrollbar { display: none; }
  .quick-browse .quick-pill { flex-shrink: 0; }
}

/* ============================================================
   9. SECTION & CONTAINER PADDING
   ============================================================ */
@media (max-width: 959px) {
  .section-pad { padding-top: 28px; padding-bottom: 28px; }
  section      { padding-top: 28px; padding-bottom: 28px; }
  .container, .container-wide {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* ============================================================
   10. SINGLE PROPERTY PAGE — stacked on mobile
   ============================================================ */
@media (max-width: 959px) {
  .sp-layout        { flex-direction: column; gap: 18px; }
  .sp-sidebar       { width: 100%; position: static; }
  .sp-title-card    { padding: 14px; }
  .sp-detail-grid   { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .sp-actions       { flex-direction: column; gap: 8px; }
  .sp-actions .btn  { width: 100%; justify-content: center; min-height: 48px; }
}

/* ============================================================
   11. FOOTER
   ============================================================ */
@media (max-width: 599px) {
  .footer-grid          { grid-template-columns: 1fr; gap: 20px; }
  .footer-bottom-inner  { flex-direction: column; gap: 6px; text-align: center; }
}

/* ============================================================
   12. ANDROID WEBVIEW PERFORMANCE
   ============================================================ */

/* Hardware-accelerate scrollable containers */
.property-grid,
.requirements-grid,
.quick-browse {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Card entrance animation */
@media (max-width: 959px) {
  @keyframes mpFadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .property-card:nth-child(1) { animation: mpFadeUp 0.25s ease both 0ms;   }
  .property-card:nth-child(2) { animation: mpFadeUp 0.25s ease both 40ms;  }
  .property-card:nth-child(3) { animation: mpFadeUp 0.25s ease both 80ms;  }
  .property-card:nth-child(n+4){ animation: mpFadeUp 0.25s ease both 120ms; }
}

/* ============================================================
   13. DARK PROPERTY CARD — mobile colour fixes
   ============================================================ */
@media (max-width: 959px) {
  /* Ensure dark card backgrounds render on Android WebView */
  .property-card {
    background: #1E2330;
    border-color: #2D3348;
  }
  .property-card-visual {
    background: #161B29;
    border-bottom-color: #2D3348;
  }
  .prop-details-row {
    border-bottom-color: #2D3348;
  }
  .prop-price-row {
    background: #0F1320;
    border-color: #3D2020;
  }
  .prop-side-btn-share {
    background: #2D3348;
    color: #8B96B4;
    border-color: #3D4560;
  }
  /* Card entrance animation on dark bg */
  @keyframes mpFadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}
