:root {
  --wpim-primary: #2563eb;
  /* Deeper blue for logic/actions */
  --wpim-primary-hover: #1d4ed8;
  --wpim-text: #111827;
  --wpim-text-light: #6b7280;
  --wpim-bg-glass: rgba(255, 255, 255, 0.92);
  --wpim-bg-hover: #f9fafb;
  --wpim-border: #e5e7eb;
  --wpim-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --wpim-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --wpim-radius: 16px;
  --wpim-font: 'Inter', system-ui, -apple-system, sans-serif;
}

.wpim-map-container {
  display: block;
  /* Changed from flex to allow absolute positioning context */
  position: relative;
  height: 550px;
  max-width: 100%;
  margin: 2rem auto;
  border-radius: var(--wpim-radius);
  overflow: hidden;
  box-shadow: var(--wpim-shadow-md);
  background: #f3f4f6;
  font-family: var(--wpim-font);
}

/* Map fills the container */
.wpim-map-wrapper {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

#wpim-map {
  width: 100%;
  height: 100%;
}

/* Floating Sidebar */
.wpim-sidebar {
  position: absolute;
  top: 20px;
  bottom: 20px;
  left: 20px;
  width: 360px;
  max-width: 90%;
  /* Safety for small screens */
  background: var(--wpim-bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--wpim-radius);
  box-shadow: var(--wpim-shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  /* Above Leaflet map */
  transition: transform 0.3s ease;
}

.wpim-sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--wpim-border);
  background: transparent;
}

/* Modern Search Box */
.wpim-search-box {
  position: relative;
}

.wpim-search-input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 2.75rem;
  border: 1px solid var(--wpim-border);
  border-radius: 12px;
  font-size: 0.95rem;
  background: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  color: var(--wpim-text);
  box-sizing: border-box;
}

.wpim-search-input:focus {
  outline: none;
  border-color: var(--wpim-primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.wpim-search-input::placeholder {
  color: #9ca3af;
}

.wpim-search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  width: 1.25rem;
  height: 1.25rem;
  pointer-events: none;
}

/* Filters if we add them later */
.wpim-filters {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  scrollbar-width: none;
}

/* List Area */
.wpim-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  /* Smooth scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.wpim-list::-webkit-scrollbar {
  width: 6px;
}

.wpim-list::-webkit-scrollbar-track {
  background: transparent;
}

.wpim-list::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 20px;
}

/* Agency Card */
.wpim-agency-card {
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-radius: 12px;
  cursor: pointer;
  background: white;
  border: 1px solid transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.wpim-agency-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  border-color: var(--wpim-border);
}

.wpim-agency-card.active {
  border-color: var(--wpim-primary);
  background: #eff6ff;
  box-shadow: 0 0 0 1px var(--wpim-primary);
}

.wpim-agency-name {
  font-weight: 700;
  color: var(--wpim-text);
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.wpim-agency-address {
  font-size: 0.875rem;
  color: var(--wpim-text-light);
  line-height: 1.4;
  display: flex;
  gap: 0.5rem;
}

/* Badges */
.wpim-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.wpim-status-badge.active {
  background: #dcfce7;
  color: #166534;
}

.wpim-status-badge.inactive {
  background: #fee2e2;
  color: #991b1b;
}

/* Loading Overlay */
.wpim-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

/* Popups */
.leaflet-popup-content-wrapper {
  background: white;
  border-radius: 12px;
  box-shadow: var(--wpim-shadow-lg);
  padding: 0;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 1rem;
  width: 240px !important;
}

.wpim-popup-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--wpim-text);
  margin-bottom: 0.5rem;
}

.wpim-btn-directions {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 1rem;
  padding: 0.6rem;
  background: var(--wpim-primary);
  color: white;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.2s;
  box-sizing: border-box;
}

.wpim-btn-directions:hover {
  background: var(--wpim-primary-hover);
  color: white;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .wpim-map-container {
    height: 85vh;
    /* Taller on mobile */
    display: flex;
    flex-direction: column;
  }

  .wpim-map-wrapper {
    position: relative;
    /* Return to flex flow */
    height: 50%;
    order: 1;
    /* Map on top/bottom depending on preference, usually map top is better but let's see */
  }

  .wpim-sidebar {
    position: relative;
    /* Not floating on mobile */
    top: auto;
    left: auto;
    bottom: auto;
    width: 100%;
    max-width: 100%;
    height: 50%;
    order: 2;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--wpim-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  }
}

/* Full Width Mode */
.wpim-mode-full {
  width: 100vw;
  max-width: 100vw;
  height: 75vh;
  /* Keeps it tall but not necessarily blocking navigation if any */
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  margin-top: 0;
  margin-bottom: 0;
  border-radius: 0;
  box-shadow: none;
  /* Remove shadow efficiently to merge with page */
  border: none;
}