/**
 * NCCR Property Map — Split-screen map view styles.
 */

/* ── Map toggle button ──────────────────────────────────── */
.nccr-map-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--nccr-border, #ddd);
  border-radius: var(--nccr-radius, 8px);
  background: var(--nccr-card-bg, #fff);
  color: var(--nccr-text, #333);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.nccr-map-toggle:hover {
  border-color: var(--nccr-accent, #2563eb);
  color: var(--nccr-accent, #2563eb);
}
.nccr-map-toggle.active {
  background: var(--nccr-accent, #2563eb);
  border-color: var(--nccr-accent, #2563eb);
  color: #fff;
}
.nccr-map-toggle.active svg {
  stroke: #fff;
}
.nccr-map-toggle-icon {
  flex-shrink: 0;
}

/* ── Split-screen layout when map is active ─────────────── */
.nccr-search-wrapper.nccr-map-active {
  max-width: 100%;
  padding: 0 16px;
}

.nccr-search-content {
  display: block;
}

.nccr-search-wrapper.nccr-map-active .nccr-search-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

/* ── List panel (left side in map mode) ─────────────────── */
.nccr-search-wrapper.nccr-map-active .nccr-list-panel {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding-right: 16px;
  scrollbar-width: thin;
}

.nccr-search-wrapper.nccr-map-active .nccr-list-panel::-webkit-scrollbar {
  width: 6px;
}
.nccr-search-wrapper.nccr-map-active .nccr-list-panel::-webkit-scrollbar-track {
  background: transparent;
}
.nccr-search-wrapper.nccr-map-active .nccr-list-panel::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* Force single-column grid in map mode so cards stack vertically */
.nccr-search-wrapper.nccr-map-active .nccr-property-grid {
  grid-template-columns: 1fr;
}

/* ── Map panel (right side) ─────────────────────────────── */
.nccr-map-panel {
  position: relative;
}

.nccr-search-wrapper.nccr-map-active .nccr-map-panel {
  position: sticky;
  top: 0;
  height: calc(100vh - 180px);
  border-radius: var(--nccr-radius, 8px);
  overflow: hidden;
}

#nccr-property-map {
  width: 100%;
  height: 100%;
  min-height: 400px;
  z-index: 1;
}

/* ── "Search as I move the map" checkbox ────────────────── */
.nccr-map-search-toggle {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.nccr-map-search-toggle input[type="checkbox"] {
  margin: 0;
  accent-color: var(--nccr-accent, #2563eb);
}

/* ── Marker styles (Airbnb-style price bubbles) ─────────── */
.nccr-map-marker {
  background: #fff;
  border: 2px solid #333;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #333;
  white-space: nowrap;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
}
.nccr-map-marker:hover,
.nccr-map-marker.nccr-marker-active {
  background: #333;
  color: #fff;
  transform: scale(1.1);
  z-index: 1000 !important;
}

/* ── Map popup ──────────────────────────────────────────── */
.nccr-map-popup {
  min-width: 220px;
  max-width: 260px;
}
.nccr-map-popup-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 6px 6px 0 0;
  display: block;
}
.nccr-map-popup-body {
  padding: 10px 12px;
}
.nccr-map-popup-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin: 0 0 4px;
  line-height: 1.3;
}
.nccr-map-popup-name a {
  color: inherit;
  text-decoration: none;
}
.nccr-map-popup-name a:hover {
  text-decoration: underline;
}
.nccr-map-popup-details {
  font-size: 12px;
  color: #666;
  margin: 0;
}
.nccr-map-popup-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--nccr-accent, #2563eb);
  margin-top: 4px;
}

/* Remove default leaflet popup styling overrides */
.leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 0;
  line-height: 1.4;
}

/* ── Card highlight when marker is clicked ──────────────── */
.nccr-card.nccr-card-highlighted {
  box-shadow: 0 0 0 3px var(--nccr-accent, #2563eb);
  transition: box-shadow 0.2s ease;
}

/* ── Mobile close button for full-screen map ────────────── */
.nccr-map-close-mobile {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1001;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 20px;
  line-height: 36px;
  text-align: center;
  cursor: pointer;
  color: #333;
}

/* ── Mobile responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .nccr-search-wrapper.nccr-map-active {
    padding: 0;
  }

  .nccr-search-wrapper.nccr-map-active .nccr-search-content {
    grid-template-columns: 1fr;
  }

  .nccr-search-wrapper.nccr-map-active .nccr-list-panel {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }

  .nccr-map-panel {
    display: none !important;
  }

  .nccr-search-wrapper.nccr-map-active .nccr-map-panel.nccr-map-mobile-visible {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 99999;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .nccr-map-mobile-visible .nccr-map-close-mobile {
    display: block;
  }

  /* In mobile map mode, hide the search-as-I-move toggle — not useful on small screens */
  .nccr-map-mobile-visible .nccr-map-search-toggle {
    display: none;
  }

  /* On mobile, the map toggle acts as a show/hide for the full-screen map */
  .nccr-search-wrapper.nccr-map-active .nccr-property-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Medium screens: narrower list panel ────────────────── */
@media (min-width: 769px) and (max-width: 1100px) {
  .nccr-search-wrapper.nccr-map-active .nccr-search-content {
    grid-template-columns: 45% 55%;
  }
}
