/* =====================================================
   near-me.css — near-me.php only
   ===================================================== */

.near-container {
  display: flex;
  height: calc(100vh - 70px);
  overflow: hidden;
  isolation: isolate;
}

/* === FILTER PANEL (animal search + chips) === */

.near-filter-panel {
  width: 10%;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e5e5e5;
  background: #fff;
  overflow: hidden;
}

.near-filter-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px;
  padding: 9px 14px;
  border: 1px solid #838383;
  border-radius: 50px;
  background: #f3f3f3;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.near-filter-search-wrap:focus-within {
  border-color: #1a7a3c;
}

.near-filter-search-wrap i {
  color: #999;
  font-size: 12px;
  flex-shrink: 0;
}

.near-filter-search-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12.5px;
  color: #333;
}

.near-filter-search-wrap input::placeholder {
  color: #999;
}

.near-animal-search-hint {
  margin: -6px 14px 12px 18px;
  font-size: 11.5px;
  color: #999;
}

.near-animal-filter {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: max-content;
  align-content: start;
  gap: 20px 10px;
  padding: 18px 10px;
  scrollbar-width: none;
}

.near-animal-filter::-webkit-scrollbar {
  display: none;
}

.near-animal-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: center;
  padding: 0;
}

.near-animal-chip-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #e5e7eb;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}

.near-animal-chip-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.near-animal-chip span {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: #444;
  word-break: break-word;
}

.near-animal-chip:hover .near-animal-chip-img {
  border-color: #86efac;
}

.near-animal-chip.active .near-animal-chip-img {
  border-color: #22c55e;
  transform: scale(1.06);
  box-shadow: 0 3px 10px rgba(34,197,94,0.28);
}

.near-animal-chip.active span {
  color: #15803d;
}

.near-animal-empty {
  font-size: 11.5px;
  color: #aaa;
  text-align: center;
  padding: 12px 4px;
  margin: 0;
}

/* === RESULTS PANEL (card list) === */

.near-results-panel {
  width: 30%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e5e5e5;
  background: #f8f9fa;
  overflow: hidden;
}

.near-results-header {
  padding: 18px 20px 14px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.near-results-header h2 {
  width: 100%;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.2px;
  margin: 0 0 3px;
  color: #111;
}

.near-attribution-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin: 12px 0 14px;
  padding: 0 16px;
}

.near-sort-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.near-sort-label {
  font-size: 12px;
  font-weight: 600;
  color: #8a8f98;
}

.near-sort-select {
  appearance: none;
  -webkit-appearance: none;
  background: #f4f5f7 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a8f98' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 9px;
  border: 1px solid #e4e6ea;
  border-radius: 999px;
  padding: 6px 26px 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: border-color 0.15s;
}

.near-sort-select:hover {
  border-color: #c9ccd1;
}

.near-sort-select:focus {
  outline: none;
  border-color: #22c55e;
}

.near-results-count {
  font-size: 13px;
  font-weight: 500;
  color: #8a8f98;
  margin: 0;
}

.near-cards-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: max-content;
  gap: 16px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: #d4d7dc transparent;
}

.near-cards-list::-webkit-scrollbar {
  width: 8px;
}

.near-cards-list::-webkit-scrollbar-thumb {
  background: #d4d7dc;
  border-radius: 8px;
}

.near-cards-list::-webkit-scrollbar-track {
  background: transparent;
}

.near-cards-list .near-empty {
  grid-column: 1 / -1;
}


.near-empty {
  text-align: center;
  color: #aaa;
  font-size: 14px;
  padding: 40px 20px;
  margin: 0;
}

/* === LEFT PANEL — MODERNIZED CARDS (near-me only, scoped) === */

.near-cards-list .card-link {
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.055);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.near-cards-list .card-link:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
  border-color: rgba(0,0,0,0.08);
}

.near-cards-list .card-image-wrapper {
  overflow: hidden;
}

.near-cards-list .card-image-wrapper img {
  height: auto;
  aspect-ratio: 4 / 3;
  transition: transform 0.35s ease;
}

.near-cards-list .card-link:hover .card-image-wrapper img {
  transform: scale(1.06);
}

.near-cards-list .card-distance-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  color: #111;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.near-cards-list .card-distance-badge::before {
  content: '\f3c5';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 9px;
  color: #22c55e;
}

.near-cards-list .card-content {
  padding: 12px 13px 14px;
  gap: 6px;
}

.near-cards-list .card-content h2 {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.near-cards-list .card-location {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: #8a8f98;
}

.near-cards-list .card-location::before {
  content: '\f3c5';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 0.7rem;
  color: #c2c6cc;
  flex-shrink: 0;
}

.near-cards-list .card-rating {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 4px;
  background: #fff9e6;
  border-radius: 999px;
  padding: 2px 9px 2px 8px;
  font-size: 0.78rem;
}

.near-cards-list .card-reviews {
  color: #a3a3a3;
  font-size: 0.76rem;
}

.near-cards-list .card-desc {
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.45;
  -webkit-line-clamp: 2;
}

/* === CUSTOM MAP MARKERS === */

.map-pin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  width: 120px;
}

.map-pin-label {
  background: #fff;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.2);
  margin-bottom: 4px;
  text-align: center;
}

.map-pin-body {
  width: 36px;
  height: 36px;
  background: #22c55e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  position: relative;
  transition: background 0.15s, box-shadow 0.15s;
}

.map-pin-body::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid #22c55e;
  transition: border-top-color 0.15s;
}

.map-pin-body i {
  color: #000;
  font-size: 15px;
}

.map-cluster-body {
  width: 42px;
  height: 42px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

/* Active state */
.map-pin-wrap.active .map-pin-body {
  background: #fff;
  box-shadow: 0 3px 12px rgba(34,197,94,0.5);
}

.map-pin-wrap.active .map-pin-body::after {
  border-top-color: #fff;
}

/* Highlighted card in left panel (applied directly to the .card-link element) */
.near-card-active {
  border-color: #22c55e !important;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.25), 0 10px 24px rgba(0,0,0,0.12) !important;
}

/* === USER LOCATION === */

.user-location-dot {
  width: 16px;
  height: 16px;
  background: #4285f4;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(66,133,244,0.5);
  position: relative;
}

.user-location-pulse {
  width: 40px;
  height: 40px;
  background: rgba(66,133,244,0.2);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0%   { transform: translate(-50%,-50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(2);   opacity: 0; }
}

/* === CUSTOM POPUP CARD === */

.leaflet-popup-content-wrapper {
  padding: 0 !important;
  border-radius: 14px !important;
  overflow: hidden !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  padding: 0 !important;
  width: 250px !important;
}

.leaflet-popup-tip-container {
  margin-top: -1px;
}

.leaflet-popup-close-button {
  display: none !important;
}

.map-popup-card {
  width: 250px;
  overflow: hidden;
  border-radius: 14px;
  cursor: pointer;
}

.map-popup-card img {
  width: 250px;
  height: 160px;
  object-fit: cover;
  display: block;
  margin: 0;
  padding: 0;
}

.map-popup-body {
  padding: 12px 14px 14px;
  background: #fff;
}

.map-popup-body h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 5px;
  color: #111;
  line-height: 1.3;
}

.map-popup-location {
  font-size: 13px;
  color: #888;
  margin: 0 0 6px;
}

/* === RECENTER BUTTON === */

.near-map-panel .leaflet-top {
  top: 24px;
}

.map-recenter-btn {
  position: absolute;
  top: 30px;
  right: 12px;
  z-index: 1000;
  width: 36px;
  height: 36px;
  background: #fff;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
  font-size: 16px;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s;
}

.map-recenter-btn:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.28);
}

/* === MAP SEARCH === */

.map-search-wrap {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.map-search-toggle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  cursor: pointer;
  font-size: 18px;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s;
}

.map-search-toggle:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.28);
}

.map-search-box {
  display: none;
  align-items: center;
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px 8px 18px;
  box-shadow: 0 3px 14px rgba(0,0,0,0.2);
  gap: 8px;
  width: 280px;
}

.map-search-box.open {
  display: flex;
}

.map-search-box input {
  border: none;
  outline: none;
  font-size: 16px;
  flex: 1;
  background: transparent;
}

.map-search-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}

.map-search-suggestions {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  overflow: hidden;
  width: 280px;
}

.map-suggestion {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #222;
  border-bottom: 1px solid #f0f0f0;
}

.map-suggestion:last-child {
  border-bottom: none;
}

.map-suggestion:hover {
  background: #f5f5f5;
}

/* === RIGHT PANEL === */

.near-map-panel {
  flex: 1;
  position: relative;
}

#near-map {
  position: absolute;
  inset: 0;
}

/* === MOBILE === */

.near-mobile-toggle {
  display: none;
}

@media (max-width: 900px) {
  .near-container {
    height: calc(100vh - 54px);
    position: relative;
  }

  .near-filter-panel,
  .near-results-panel {
    display: none;
  }

  .near-map-panel {
    flex: 1;
    width: 100%;
  }

  .near-map-panel .leaflet-top.leaflet-left {
    top: 16px;
    left: 16px;
  }

  .map-recenter-btn {
    top: 16px;
    right: 16px;
  }

  /* Floating map/list toggle — bottom-center, 20px above the fixed bottom nav
     bar (62px tall). `position: fixed` + `bottom` is already viewport-relative,
     so it lands correctly regardless of phone screen height on its own —
     no margin trick needed. `env(safe-area-inset-bottom)` is the one thing
     that actually varies by device: it adds the extra reserved space on
     phones with a home-indicator bar (iPhone X and later). */
  .near-mobile-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: calc(62px + 20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    background: #111;
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 12px 22px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(0,0,0,0.28);
    cursor: pointer;
    transition: bottom 0.2s ease;
  }

  /* Bottom nav bar auto-hid on scroll — drop the toggle down to where it was */
  .near-mobile-toggle.near-mobile-toggle-low {
    bottom: calc(20px + env(safe-area-inset-bottom));
  }

  /* List view: hide map, show filter + results panels stacked full-screen */
  .near-container.near-mobile-list .near-map-panel {
    display: none;
  }

  .near-container.near-mobile-list {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  /* Title/results section first, animal filter section below it */
  .near-container.near-mobile-list .near-filter-panel {
    order: 2;
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
  }

  .near-container.near-mobile-list .near-filter-search-wrap {
    width: 130px;
    flex-shrink: 0;
    margin: 10px 6px 10px 10px;
  }

  /* No room for a hint line in the horizontal mobile layout (search box +
     chips side-by-side) — revisit placement here if it's wanted on mobile too. */
  .near-container.near-mobile-list .near-animal-search-hint {
    display: none;
  }

  .near-container.near-mobile-list .near-animal-filter {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    align-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 14px 10px 0;
    gap: 16px;
  }

  .near-container.near-mobile-list .near-animal-chip {
    flex-direction: row;
    width: auto;
  }

  .near-container.near-mobile-list .near-animal-chip-img {
    width: 38px;
    height: 38px;
  }

  /* Break the results panel apart so its header can sit above the animal
     filter panel while the attribution row + card list sit below it. */
  .near-container.near-mobile-list .near-results-panel {
    display: contents;
  }

  .near-container.near-mobile-list .near-results-header {
    order: 1;
    width: 100%;
  }

  .near-container.near-mobile-list .near-attribution-row {
    order: 3;
    width: 100%;
  }

  .near-container.near-mobile-list .near-cards-list {
    order: 4;
    width: 100%;
    grid-template-columns: 1fr;
    flex: none;
    overflow-y: visible;
    padding-bottom: 140px;
  }

}

/* No Google Maps attribution styles here: this page shows a Leaflet/CARTO map, and Google's
   ToS forbids Places content near a non-Google map, so the page carries no Google rating at
   all. .near-attribution-row now holds only the sort control (see near-me.php). */
