/* ═══════════════════════════════════════════════════════════════
 *  gn-espocrm-idx-mobile-modern.css  v11.0.0
 *  v11: Save Search bottom-left, chat bubble bottom-right (no overlap),
 *       filter panel footer sticky, filter panel z-index 2000000
 * ═══════════════════════════════════════════════════════════════ */

:root {
  --gn-mobile-vh: 1vh;
}

html.gn-idx-mobile-filter-open,
body.gn-idx-mobile-filter-open {
  overflow: hidden !important;
  touch-action: none;
}

@media (max-width: 900px) {

  /* ── 1. Logo: scale down to fit header ── */
  #masthead .brand.has-logo-image img,
  #masthead img.custom-logo {
    max-height: 40px !important;
    width: auto !important;
    height: auto !important;
  }

  /* ── 2. Draw Area button: hide on mobile (overlaps Map/Satellite controls) ── */
  .gn-draw-btn {
    display: none !important;
  }

  /* ── Hide the floating account/signin button (header has it) ── */
  #gln-nav-signin-mobile-fallback {
    display: none !important;
  }

  /* ── Wrap: full-screen minus 56px toolbar ── */
  .gn-idx__wrap {
    flex-direction: row !important;
    height: calc(var(--gn-mobile-vh, 1vh) * 100 - 56px) !important;
    min-height: 0 !important;
    position: relative !important;
    overflow: hidden !important;
  }

  /* ── Left panel (list): hidden by default ── */
  .gn-idx__left {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    flex: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: none !important;
    z-index: 2 !important;
    background: #fff !important;
  }

  .gn-idx--list-mode .gn-idx__left {
    display: flex !important;
  }

  /* ── Right panel (map): full-screen by default ── */
  .gn-idx__right {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    flex: none !important;
    display: block !important;
    z-index: 1 !important;
  }

  .gn-idx--list-mode .gn-idx__right {
    display: none !important;
  }

  .gn-idx__map {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
  }

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

  /* ── Hide desktop FILTERS button ── */
  .gn-idx__btn--filter {
    display: none !important;
  }

  /* ── Bottom toolbar ── */
  .gn-mobile-toolbar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 56px !important;
    background: rgba(255, 255, 255, 0.97) !important;
    backdrop-filter: blur(20px) saturate(1.8) !important;
    -webkit-backdrop-filter: blur(20px) saturate(1.8) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-around !important;
    padding: 0 8px !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    z-index: 99990 !important;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08) !important;
  }

  /* ── Toolbar buttons — plain text, equal width ── */
  .gn-mobile-toolbar__btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    height: 38px !important;
    padding: 0 8px !important;
    border-radius: 999px !important;
    border: 1.5px solid rgba(0, 0, 0, 0.12) !important;
    background: #fff !important;
    color: #333 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    font-family: 'League Spartan', sans-serif !important;
    cursor: pointer !important;
    transition: background 0.15s, color 0.15s, border-color 0.15s !important;
    touch-action: manipulation !important;
    white-space: nowrap !important;
    -webkit-tap-highlight-color: transparent !important;
    letter-spacing: 0.01em !important;
    margin: 0 4px !important;
  }

  .gn-mobile-toolbar__btn--active {
    background: #007bff !important;
    color: #fff !important;
    border-color: #007bff !important;
    box-shadow: 0 2px 12px rgba(0, 123, 255, 0.30) !important;
  }

  /* ── 3. Save This Search: bottom-LEFT, above toolbar ── */
  #gln-save-search-btn {
    bottom: calc(56px + env(safe-area-inset-bottom) + 12px) !important;
    left: 12px !important;
    right: auto !important;
    position: fixed !important;
    padding: 8px 18px !important;
    font-size: 13px !important;
    max-width: 200px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    z-index: 99985 !important;
  }

  /* ── 4. Chat bubble: bottom-RIGHT, above toolbar (separate from Save Search) ── */
  #gln-chat-bubble {
    bottom: calc(56px + env(safe-area-inset-bottom) + 12px) !important;
    right: 12px !important;
    left: auto !important;
  }
  /* Tawk.to */
  #tawkchat-container,
  #tawk-bubble-container,
  .tawk-min-container,
  [id^="tawk-"] {
    bottom: calc(56px + env(safe-area-inset-bottom) + 58px) !important;
  }
  /* Common chat widget iframes and bubbles */
  iframe[title*="chat" i],
  iframe[title*="message" i],
  iframe[src*="tawk"],
  iframe[src*="crisp"],
  iframe[src*="intercom"],
  iframe[src*="drift"],
  [id*="crisp"],
  [id*="intercom"],
  [id*="drift"],
  [class*="chat-bubble"],
  [class*="chat-widget"] {
    bottom: calc(56px + env(safe-area-inset-bottom) + 58px) !important;
  }

  /* ── 5. Filter panel: full-screen slide-up (above everything) ── */
  .gn-idx__fp {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: calc(var(--gn-mobile-vh, 1vh) * 100) !important;
    max-height: none !important;
    border-radius: 0 !important;
    border-left: none !important;
    box-shadow: none !important;
    z-index: 2000000 !important;
    transform: translateY(100%) !important;
    background: rgba(245, 247, 250, 0.98) !important;
    visibility: hidden !important;
  }

  .gn-idx__fp.gn-idx__fp--anim {
    transition: transform 0.28s ease, visibility 0.28s ease !important;
  }

  .gn-idx__fp.gn-idx__fp--open {
    transform: translateY(0) !important;
    visibility: visible !important;
  }

  .gn-idx__fp-close {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid rgba(0, 0, 0, 0.10) !important;
    color: #243041 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    touch-action: manipulation !important;
  }

  /* body must shrink to leave room for footer */
  .gn-idx__fp-body {
    padding: 0 16px 18px !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .gn-idx__fp-foot {
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom)) !important;
    flex: 0 0 auto !important;
    background: rgba(245, 247, 250, 0.98) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
  }
}

/* ── Desktop: hide toolbar ── */
@media (min-width: 901px) {
  .gn-mobile-toolbar {
    display: none !important;
  }
}

html.gn-idx-mobile-gallery-open body {
  overscroll-behavior: none;
}
