/**
 * Mapping Enterprise Map Styles
 */

.mem-container {
  width: 100%;
  max-width: 100%;
  margin: 2rem 0;
  display: flex;
  gap: 24px;
}

/* ── Filter Header (title + toggle) ── */
.mem-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mem-filter-header .mem-title {
  margin: 0;
  font-size: 24px !important;
  font-weight: 700 !important;
  color: #0D3183 !important;
  line-height: 1.3 !important;
  letter-spacing: 0 !important;
}

/* ── Filter Panel ── */
.mem-filters {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px !important;
  width: 300px;
  flex-shrink: 0;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  align-self: flex-start;
}

.mem-filter-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.mem-filter-group label {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mem-filter-group select {
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mem-filter-group select:focus {
  outline: none;
  border-color: #0D3183;
  box-shadow: 0 0 0 3px rgba(13, 49, 131, 0.12);
}

/* ── Tom Select overrides ── */
.mem-filter-group .ts-wrapper {
  width: 100%;
}

.mem-filter-group .ts-wrapper.single .ts-control {
  padding: 9px 12px;
  padding-right: 36px; /* room for clear button */
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  flex-wrap: nowrap;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mem-filter-group .ts-control > input {
  flex: 1;
  min-width: 50px;
}

.mem-filter-group .ts-control > .item {
  flex-shrink: 0;
  max-width: calc(100% - 30px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mem-filter-group .ts-control:focus,
.mem-filter-group .ts-wrapper.focus .ts-control {
  border-color: #0D3183;
  box-shadow: 0 0 0 3px rgba(13, 49, 131, 0.12);
}

.mem-filter-group .ts-dropdown {
  z-index: 1000;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.mem-filter-group .ts-dropdown .option {
  padding: 9px 12px;
  transition: background-color 0.15s;
}

.mem-filter-group .ts-dropdown .option.active {
  background-color: #f0f4ff;
  color: #0D3183;
}

/* ── Tom Select clear button (×) ── */
.mem-filter-group .ts-wrapper .clear-button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.15s, color 0.15s;
}

.mem-filter-group .ts-wrapper.has-items .clear-button,
.mem-filter-group .ts-wrapper:hover .clear-button {
  opacity: 1;
}

.mem-filter-group .ts-wrapper .clear-button:hover {
  background: #d1d5db;
  color: #374151;
}

/* ── Near-me toggle card ── */
.mem-filter-group-checkbox {
  flex-direction: row;
  align-items: stretch;
}

.mem-near-me-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.mem-near-me-toggle:hover {
  border-color: #0D3183;
  background: #f8faff;
}

.mem-near-me-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #eef2ff;
  color: #0D3183;
  transition: background-color 0.2s, color 0.2s;
}

.mem-near-me-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.mem-near-me-title {
  font-size: 14px;
  font-weight: 600;
  color: #0D3183;
  line-height: 1.2;
}

.mem-near-me-sub {
  font-size: 12px;
  font-weight: 400;
  color: #6b7280;
  line-height: 1.3;
  text-transform: none;
  letter-spacing: 0;
}

.mem-near-me-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mem-near-me-switch {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  background: #d1d5db;
  border-radius: 999px;
  transition: background-color 0.2s;
}

.mem-near-me-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.mem-near-me-checkbox:focus-visible ~ .mem-near-me-switch {
  box-shadow: 0 0 0 3px rgba(13, 49, 131, 0.18);
}

.mem-near-me-toggle:has(.mem-near-me-checkbox:checked) {
  border-color: #0D3183;
  background: #eef2ff;
}

.mem-near-me-toggle:has(.mem-near-me-checkbox:checked) .mem-near-me-icon {
  background: #0D3183;
  color: #fff;
}

.mem-near-me-checkbox:checked ~ .mem-near-me-switch {
  background: #0D3183;
}

.mem-near-me-checkbox:checked ~ .mem-near-me-switch::after {
  transform: translateX(16px);
}

/* ── Reset Button ── */
.mem-container .mem-filters button.mem-filter-reset {
  margin-top: 4px;
  padding: 10px 16px;
  background-color: transparent;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  background-image: none;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mem-container .mem-filters button.mem-filter-reset:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
  color: #374151;
}

/* Custom marker icon */
.mem-marker-icon {
  background: transparent;
  border: none;
}

/* ── Sector dropdown color indicators ── */
.mem-sector-option,
.mem-sector-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mem-sector-option,
.mem-sector-item {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.mem-sector-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Map Container */
.mem-map {
  flex: 1;
  height: 500px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}


/* Popup Styles */
.leaflet-popup {
  z-index: 1000;
}

.leaflet-popup-content {
  max-width: calc(100vw - 40px);
}

.mem-popup-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.mem-popup-thumb {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  line-height: 0;
  background: #f3f4f6;
}

.mem-popup-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mem-popup-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.mem-popup h3.mem-popup-title {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #0D3183;
  letter-spacing: 0px;
  line-height: 1.25;
}

.mem-popup-meta {
  font-size: 12px;
  color: #666;
  margin: 0;
}

.mem-popup-content {
  font-size: 13px;
  line-height: 1.5;
  color: #333;
  margin-bottom: 10px;
}

.mem-popup-content p {
  margin: 0 0 8px 0;
}

.mem-popup-content p:last-child {
  margin-bottom: 0;
}

.mem-popup-contact {
  font-size: 12px;
  line-height: 1.4;
  color: #555;
  padding-top: 10px;
}

.mem-popup-contact p {
  margin: 0 0 6px 0;
}

.mem-popup-contact p:last-child {
  margin-bottom: 0;
}

.mem-popup-contact strong {
  color: #333;
}

.mem-popup-contact a {
  color: #0D3183;
  text-decoration: none;
}

.mem-popup-contact a:hover {
  text-decoration: underline;
}

/* Custom Cluster Styles */
.mem-cluster {
  background: transparent;
  border: none;
}

.mem-cluster div {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.mem-cluster-small div {
  font-size: 11px;
}

.mem-cluster-medium div {
  font-size: 13px;
}

.mem-cluster-large div {
  font-size: 14px;
}

/* ── Locate Control Button ── */
.mem-locate-control {
  margin-bottom: 20px !important;
  margin-right: 10px !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
  overflow: hidden;
}

.mem-locate-button {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #fff;
  color: #333;
  cursor: pointer;
  text-decoration: none !important;
  transition: background-color 0.15s, color 0.15s;
}

.mem-locate-button:hover {
  background-color: #f0f4ff;
  color: #0D3183;
}

.mem-locate-button:active {
  background-color: #e0e7ff;
}

.mem-locate-button svg {
  display: block;
  width: 20px;
  height: 20px;
}

/* ── Geolocation Marker (Blue Pulsing Dot) ── */
.mem-location-marker {
  background: transparent !important;
  border: none !important;
}

.mem-location-dot {
  position: relative;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mem-location-dot::after {
  content: '';
  width: 12px;
  height: 12px;
  background: #2563eb;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(37, 99, 235, 0.5);
  position: relative;
  z-index: 2;
}

.mem-location-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: rgba(37, 99, 235, 0.3);
  border-radius: 50%;
  z-index: 1;
  animation: mem-pulse 2s ease-out infinite;
}

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

/* ── Geolocation Accuracy Circle ── */
.mem-location-accuracy {
  fill: rgba(37, 99, 235, 0.08);
  stroke: rgba(37, 99, 235, 0.3);
  stroke-width: 1;
}

/* ── Location Error Notification ── */
.mem-locate-error {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  text-align: center;
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.mem-locate-error-fade {
  opacity: 0;
}

/* ── Filter Toggle (mobile only) ── */
.mem-filter-toggle {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .mem-container {
    flex-direction: column;
  }

  .mem-container .mem-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: #fff !important;
    background-image: none !important;
    border: 1px solid #d1d5db !important;
    border-radius: 8px !important;
    color: #4b5563;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  }

  .mem-container .mem-filter-toggle svg {
    display: block;
    width: 20px;
    height: 20px;
  }

  .mem-container .mem-filter-toggle:hover {
    background: #f3f4f6 !important;
  }

  .mem-container .mem-filter-toggle-active {
    background: #0D3183 !important;
    border-color: #0D3183 !important;
    color: #fff;
  }

  .mem-filters {
    width: 100%;
    order: 1;
    border-radius: 10px;
  }

  .mem-filters .mem-filter-group,
  .mem-filters .mem-filter-reset {
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
  }

  .mem-filters .mem-filter-group-checkbox {
    max-height: 100px;
  }

  .mem-filters.mem-filters-collapsed .mem-filter-group,
  .mem-filters.mem-filters-collapsed .mem-filter-reset {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
  }

  .mem-map {
    width: 100%;
    height: 400px;
    min-height: 400px;
    order: 2;
  }
}
