/* Map page layout */
#map-page {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "search search"
    "filters map";
  height: calc(100vh - var(--app-header-h, 64px));
  /* dvh where supported: on iOS 100vh is taller than the visible area and hides Google's bottom controls */
  height: calc(100dvh - var(--app-header-h, 64px));
  position: relative; /* anchors #map-toast below the search row instead of over it */
}

#map-search   { grid-area: search; padding: 8px 12px; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; gap: 8px; position: relative; }
#map-filters  { grid-area: filters; overflow-y: auto; padding: 12px; border-right: 1px solid #e5e7eb; }
#map          { grid-area: map; }

#map-search-input { flex: 1; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; }
#map-search-error { color: #b91c1c; font-size: 0.9rem; margin-left: 8px; }

/* Search autocomplete dropdown */
.map-search-dropdown {
  position: absolute; top: calc(100% - 2px); left: 12px; right: 12px;
  margin: 0; padding: 4px 0; list-style: none;
  background: #fff; border: 1px solid #d1d5db; border-radius: 0 0 8px 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12); max-height: 60vh; overflow-y: auto;
  z-index: 1100;
}
.map-search-row { padding: 7px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.map-search-row .t { font-size: 0.92rem; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-search-row .s { font-size: 0.78rem; color: #6b7280; }
.map-search-row.active, .map-search-row:hover { background: #eff6ff; }
.map-search-empty { padding: 10px 12px; color: #6b7280; font-size: 0.88rem; }

#map-toast {
  position: absolute; top: 72px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92); color: white;
  padding: 8px 14px; border-radius: 6px; font-size: 0.9rem;
  z-index: 1000;
}

/* Cluster bubbles */
.map-cluster {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9999px; color: white; font-weight: 600;
  background: #2563eb; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  user-select: none;
}
.map-cluster-small  { width: 28px; height: 28px; font-size: 0.75rem; }
.map-cluster-medium { width: 40px; height: 40px; font-size: 0.85rem; }
.map-cluster-large  { width: 56px; height: 56px; font-size: 1rem;   }

.map-pin {
  width: 15px; height: 15px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3b82f6, #1d4ed8);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.45);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.map-pin:hover {
  transform: scale(1.25);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* Popup */
.map-popup       { font: 14px system-ui, sans-serif; min-width: 220px; }
.map-popup strong{ display: block; font-size: 1rem; margin-bottom: 4px; }
.map-popup .dba  { font-style: italic; color: #6b7280; font-size: 0.85rem; }
.map-popup .badges { display: flex; gap: 6px; margin: 6px 0; }
.map-popup .badge  { padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
/* DOT/MC numbers — green, matching the company-page header (--success-color). */
.map-popup .badge.dot { background: #1CA13B; color: #fff; }
.map-popup .badge.mc  { background: #1CA13B; color: #fff; }
/* Company type — same color scheme as the search-results badges
   (Carrier=success, Broker=info, Shipper=primary, Freight Forwarder=warning). */
.map-popup .type      { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.map-popup .type.type-carrier { background: #1CA13B; color: #fff; }
.map-popup .type.type-broker  { background: #0dcaf0; color: #083b44; }
.map-popup .type.type-shipper { background: #007BC3; color: #fff; }
.map-popup .type.type-ff      { background: #ffc107; color: #3a2f00; }
.map-popup .city      { margin: 6px 0; color: #374151; }
.map-popup a          { color: #2563eb; text-decoration: none; font-weight: 600; }

/* ZIP carrier-list popup (click a ZIP bubble) */
.map-zip-popup { font: 14px system-ui, sans-serif; min-width: 240px; max-width: 300px; }
.map-zip-popup .z-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.map-zip-popup .z-head strong { font-size: 1rem; }
.map-zip-popup .z-count { color: #6b7280; font-size: 0.8rem; white-space: nowrap; }
.map-zip-popup .z-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.map-zip-popup .z-list li { padding: 5px 0; border-top: 1px solid #f1f5f9; display: flex; flex-direction: column; gap: 1px; }
.map-zip-popup .z-list li:first-child { border-top: 0; }
.map-zip-popup .z-list a { color: #2563eb; text-decoration: none; font-weight: 600; }
.map-zip-popup .z-place { color: #6b7280; font-size: 0.78rem; }
.map-zip-popup .z-empty { color: #6b7280; }
.map-zip-popup .z-more { margin-top: 6px; color: #6b7280; font-size: 0.75rem; }

/* Filter sidebar */
.filter-group { margin-bottom: 18px; }
.filter-group label { display: block; margin: 4px 0; font-size: 0.9rem; color: #374151; }
.filter-group .range { display: flex; gap: 6px; }
.filter-group .range input { width: 50%; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 4px; font: inherit; }

/* No-script fallback */
.noscript-fallback { padding: 24px; text-align: center; color: #6b7280; }

/* Filters toggle: phone only */
.filters-toggle { display: none; }
.filters-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: 10px; background: #2563eb; color: #fff; font-size: 0.75rem; font-weight: 600;
}
.filters-count[hidden] { display: none; }

/* Mobile */
@media (max-width: 768px) {
  #map-page { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; grid-template-areas: "search" "filters" "map"; }
  #map-filters { max-height: 45vh; padding: 6px 12px; border-right: 0; border-bottom: 1px solid #e5e7eb; }
  .filters-toggle {
    display: inline-flex; align-items: center; padding: 6px 12px;
    border: 1px solid #d1d5db; border-radius: 6px; background: #fff; font: inherit; font-size: 0.9rem; color: #374151;
  }
  .filters-toggle[aria-expanded="true"] { background: #eff6ff; border-color: #93c5fd; }
  #map-filters:not(.open) .filters-body { display: none; }
  #map-filters .filters-body h3 { display: none; } /* the toggle already says "Filters" */
  #map-filters.open .filters-body { margin-top: 10px; }
}
