/* =========================================================
   Stakeholders Map - Balanced Sidebar Spacing & Matching Height
   ========================================================= */

#stakeholders-map-wrapper {
  width: 100%;
  position: relative;
  z-index: 2;

  --stakeholders-accent: var(--pulse-art-pink-2, #e6007e);
  --stakeholders-pink: var(--pulse-art-pink, #e6007e);
  --stakeholders-blue: var(--pulse-art-blue, #1f4e79);
  --stakeholders-dark: #171940;
  --stakeholders-border: var(--pulse-art-border, #d1d5db);
  --stakeholders-muted-bg: #f3f4f6;
  --stakeholders-font: "Inter", "Noto Sans", sans-serif;

  font-family: var(--stakeholders-font);
  color: #333;
}

#stakeholders-map-wrapper .app-wrap {
  width: 100%;
}

/* Category Color Systems */
#stakeholders-map-wrapper .category-citizens,
#stakeholders-map-wrapper .stakeholder-result-category.category-citizens,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-citizens,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-citizens {
  --category-color: #7c3aed;
  --criteria-color: #7c3aed;
  border-left-color: #7c3aed;
}

#stakeholders-map-wrapper .category-education,
#stakeholders-map-wrapper .stakeholder-result-category.category-education,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-education,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-education {
  --category-color: #27ae60;
  --criteria-color: #27ae60;
  border-left-color: #27ae60;
}

#stakeholders-map-wrapper .category-research,
#stakeholders-map-wrapper .stakeholder-result-category.category-research,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-research,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-research {
  --category-color: #6f42c1;
  --criteria-color: #6f42c1;
  border-left-color: #6f42c1;
}

#stakeholders-map-wrapper .category-policy,
#stakeholders-map-wrapper .stakeholder-result-category.category-policy,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-policy,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-policy {
  --category-color: #f2994a;
  --criteria-color: #f2994a;
  border-left-color: #f2994a;
}

#stakeholders-map-wrapper .category-artists,
#stakeholders-map-wrapper .stakeholder-result-category.category-artists,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-artists,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-artists {
  --category-color: #c05621;
  --criteria-color: #c05621;
  border-left-color: #c05621;
}

#stakeholders-map-wrapper .category-cultural-awareness,
#stakeholders-map-wrapper .stakeholder-result-category.category-cultural-awareness,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-cultural-awareness,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-cultural-awareness {
  --category-color: #00a6a6;
  --criteria-color: #00a6a6;
  border-left-color: #00a6a6;
}

#stakeholders-map-wrapper .category-networks,
#stakeholders-map-wrapper .stakeholder-result-category.category-networks,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-networks,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-networks {
  --category-color: #171940;
  --criteria-color: #171940;
  border-left-color: #171940;
}

#stakeholders-map-wrapper .category-bauhaus,
#stakeholders-map-wrapper .stakeholder-result-category.category-bauhaus,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-bauhaus,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-bauhaus {
  --category-color: #8e44ad;
  --criteria-color: #8e44ad;
  border-left-color: #8e44ad;
}

#stakeholders-map-wrapper .category-consortium,
#stakeholders-map-wrapper .stakeholder-result-category.category-consortium,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-consortium,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-consortium {
  --category-color: #eb5757;
  --criteria-color: #eb5757;
  border-left-color: #eb5757;
}

#stakeholders-map-wrapper .category-default,
#stakeholders-map-wrapper .stakeholder-result-category.category-default,
#stakeholders-map-wrapper .criteria-chip.criteria-chip-category.category-default,
#stakeholders-map-wrapper #category.form-select.has-active-filter.category-default {
  --category-color: var(--stakeholders-accent);
  --criteria-color: var(--stakeholders-accent);
  border-left-color: var(--stakeholders-accent);
}

/* Filters & Toolbar Controls (Original Restored) */
#stakeholders-map-wrapper .controls-wrap {
  padding: 0;
  margin-bottom: 14px;
}

#stakeholders-map-wrapper .controls {
  background: #ffffff;
  border: 1px solid rgba(23, 25, 64, 0.1);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 6px 18px rgba(23, 25, 64, 0.05);
}

#stakeholders-map-wrapper .controls .form-select {
  min-height: 44px;
  border-radius: 12px;
  border-color: rgba(23, 25, 64, 0.14);
  background-color: #ffffff;
  color: var(--stakeholders-dark);
  font-family: var(--stakeholders-font);
  font-size: 0.9rem;
  font-weight: 500;
}

#stakeholders-map-wrapper .controls .form-select:focus {
  border-color: var(--stakeholders-accent);
  box-shadow: 0 0 0 0.12rem rgba(230, 0, 126, 0.12);
}

#stakeholders-map-wrapper .controls .form-select:disabled,
#stakeholders-map-wrapper .form-select.muted {
  background-color: #ffffff;
  color: #777;
  opacity: 0.55;
  cursor: not-allowed;
  font-weight: 400;
  border-left: 1px solid var(--stakeholders-border);
}

#stakeholders-map-wrapper #country.form-select.has-active-filter,
#stakeholders-map-wrapper #category.form-select.has-active-filter {
  background-color: var(--stakeholders-muted-bg);
  font-weight: 700;
  opacity: 1;
  border-color: var(--stakeholders-border);
  border-left-width: 4px;
  border-left-style: solid;
  padding-left: 14px;
  box-shadow: none;
}

#stakeholders-map-wrapper #country.form-select.has-active-filter {
  border-left-color: var(--stakeholders-blue);
}

#stakeholders-map-wrapper #category.form-select.has-active-filter {
  border-left-color: var(--category-color, var(--stakeholders-accent));
}

#stakeholders-map-wrapper .badge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(230, 0, 126, 0.08) !important;
  color: var(--stakeholders-accent) !important;
  font-family: var(--stakeholders-font);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

#stakeholders-map-wrapper #clearFilter {
  min-height: 34px;
  border-radius: 999px;
  border-color: rgba(23, 25, 64, 0.22);
  color: var(--stakeholders-dark);
  background: #ffffff;
  font-family: var(--stakeholders-font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 14px;
  white-space: nowrap;
}

#stakeholders-map-wrapper #clearFilter:hover {
  border-color: var(--stakeholders-accent);
  color: var(--stakeholders-accent);
  background: rgba(230, 0, 126, 0.04);
}

/* UI Grid Layout Setup */
#stakeholders-map-wrapper .stakeholders-map-results-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: stretch; /* Forces children to match height */
  margin-top: 12px;
}

#stakeholders-map-wrapper .stakeholders-map-panel,
#stakeholders-map-wrapper .stakeholders-results-wrap {
  min-width: 0;
}

#stakeholders-map-wrapper .map-wrap {
  padding: 0;
  height: 100%;
}

/* Base Reference Element for Heights */
#stakeholders-map-wrapper #map {
  width: 100%;
  height: 68vh;
  min-height: 620px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  background: #f8f9fa;
}

#stakeholders-map-wrapper .leaflet-control-container,
#stakeholders-map-wrapper .leaflet-pane,
#stakeholders-map-wrapper .leaflet-top,
#stakeholders-map-wrapper .leaflet-bottom {
  z-index: 10;
}

/* Map Markers (Leaflet Custom Icons) */
#stakeholders-map-wrapper .marker-count {
  width: 34px !important;
  height: 34px !important;
  border-radius: 50% !important;
  background-color: var(--stakeholders-accent) !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-family: var(--stakeholders-font) !important;
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
}

#stakeholders-map-wrapper .city-label-marker {
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  background-color: rgba(255, 255, 255, 0.96) !important;
  color: var(--stakeholders-dark) !important;
  border: 2px solid var(--stakeholders-accent) !important;
  border-radius: 999px !important;
  padding: 6px 8px 6px 11px !important;
  font-family: var(--stakeholders-font) !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  line-height: 1.1 !important;
  white-space: nowrap !important;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25) !important;
  pointer-events: auto !important;
  cursor: pointer;
}

#stakeholders-map-wrapper .city-label-text {
  display: inline-flex !important;
  flex-direction: column !important;
  gap: 1px !important;
}

#stakeholders-map-wrapper .city-label-city {
  color: var(--stakeholders-dark) !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  line-height: 1.05 !important;
}

#stakeholders-map-wrapper .city-label-city::before {
  content: "\f3c5";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: var(--stakeholders-accent);
  font-size: 0.72rem;
  margin-right: 5px;
}

#stakeholders-map-wrapper .city-label-country {
  color: #666666 !important;
  font-size: 0.68rem !important;
  font-weight: 500 !important;
  line-height: 1 !important;
}

#stakeholders-map-wrapper .city-label-count {
  min-width: 22px !important;
  height: 22px !important;
  border-radius: 50% !important;
  background-color: var(--stakeholders-accent) !important;
  color: #ffffff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.75rem !important;
  padding: 0 6px !important;
}

#stakeholders-map-wrapper .stakeholder-individual-icon {
  pointer-events: auto !important;
  cursor: pointer;
}

#stakeholders-map-wrapper .individual-person-marker::after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 50%;
  width: 15px;
  height: 15px;
  background: var(--stakeholders-accent);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 3px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32);
  z-index: 1;
}

#stakeholders-map-wrapper .person-head {
  position: absolute;
  top: 2px;
  left: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--stakeholders-accent);
  border: 2px solid #ffffff;
  transform: translateX(-50%);
  z-index: 3;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

#stakeholders-map-wrapper .person-body {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 20px;
  height: 15px;
  border-radius: 14px 14px 6px 6px;
  background: var(--stakeholders-accent);
  border: 2px solid #ffffff;
  transform: translateX(-50%);
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Map Popups */
#stakeholders-map-wrapper .leaflet-popup-content,
#stakeholders-map-wrapper .stakeholder-popup {
  font-family: var(--stakeholders-font);
  color: #333;
  min-width: 210px;
}

#stakeholders-map-wrapper .stakeholder-popup-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--stakeholders-dark);
  margin-bottom: 4px;
}

#stakeholders-map-wrapper .stakeholder-popup-organisation {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--stakeholders-accent);
  margin-bottom: 6px;
}

#stakeholders-map-wrapper .stakeholder-popup-location {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.82rem;
  color: #666;
}

#stakeholders-map-wrapper .stakeholder-popup-city::after {
  content: ",";
}

#stakeholders-map-wrapper .stakeholder-popup-country {
  font-weight: 600;
  color: #333;
}

#stakeholders-map-wrapper .stakeholder-popup-link {
  display: inline-flex;
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--stakeholders-accent);
  color: #ffffff !important;
  font-family: var(--stakeholders-font);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none !important;
}

#stakeholders-map-wrapper .stakeholder-popup-link:hover {
  filter: brightness(0.95);
}

/* =========================================================
   RIGHT SIDEBAR: LOCKED TO MAP HEIGHT & MODERATE DENSITY CARDS
   ========================================================= */

#stakeholders-map-wrapper .stakeholders-results-wrap {
  margin-top: 0;
  padding: 0;
  height: 68vh;         /* Matches map height exactly */
  min-height: 620px;    /* Matches map min-height exactly */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;     /* Prevents general wrapper breakouts */
  border: 1px solid rgba(23, 25, 64, 0.1);
  border-radius: 14px; 
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(23, 25, 64, 0.05);
}

#stakeholders-map-wrapper .stakeholders-results-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0; /* Header stays locked, doesn't compress */
  margin: 0;
  padding: 14px 16px; 
  border-bottom: 1px solid rgba(23, 25, 64, 0.08);
}

#stakeholders-map-wrapper .stakeholders-results-header h2 {
  margin: 0;
  color: var(--stakeholders-dark);
  font-size: 1.05rem;
  font-weight: 500;
}

#stakeholders-map-wrapper #resultsCount {
  color: var(--stakeholders-accent);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Scroll Wrapper Area inside Sidebar Container */
#stakeholders-map-wrapper .stakeholders-results-list,
#stakeholders-map-wrapper #stakeholdersResults {
  display: grid;
  gap: 8px !important;    /* Moderate, clean gaps */
  padding: 12px !important; 
  overflow-y: auto;       /* Perfectly handles scroll bounds */
  flex-grow: 1;
}

/* Moderately Trimmed Cards */
.stakeholder-map-mini-card {
  display: grid;
  grid-template-columns: 40px 1fr; 
  gap: 12px;
  padding: 10px 12px !important;   /* Balanced reduction */
  margin-bottom: 0px !important;   
  background: #fff;
  border: 1px solid rgba(23, 25, 64, 0.08);
  border-radius: 10px;              
  box-shadow: 0 2px 6px rgba(23, 25, 64, 0.03);
  cursor: pointer;
  transition: 0.15s ease;
}

.stakeholder-map-mini-card:hover,
.stakeholder-map-mini-card.is-highlighted {
  border-color: rgba(177, 32, 121, 0.45);
  box-shadow: 0 4px 14px rgba(177, 32, 121, 0.12);
}

.stakeholder-mini-avatar {
  width: 40px;  
  height: 40px; 
  border-radius: 50%;
  background: rgba(177, 32, 121, 0.08);
  color: #b12079;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.88rem;
}

.stakeholder-mini-content h3 {
  margin: 0 0 3px 0 !important;
  font-size: 0.95rem;
  font-weight: 700;
  color: #171940;
  line-height: 1.3;
}

.stakeholder-mini-meta {
  display: flex;
  flex-direction: column;
  gap: 1px !important;
  color: #6b7280;
  font-size: 0.8rem;
  line-height: 1.35;
}

/* Category Label Clusters */
#stakeholders-map-wrapper .stakeholder-result-categories {
  display: flex !important;
  width: 100% !important;
  flex-wrap: wrap;
  gap: 8px !important;       
  margin-top: 6px !important;  
  margin-bottom: 2px !important;
}

#stakeholders-map-wrapper .stakeholder-result-category {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;       
  color: #171940 !important;
  font-size: 0.78rem !important;
  font-weight: 500 !important;
  line-height: 1.35 !important;
  padding-left: 0 !important;
}

#stakeholders-map-wrapper .stakeholder-result-category .category-border-indicator {
  display: inline-block !important;
  width: 3px !important;
  height: 12px !important;   
  background: #e6007e !important;
  border-radius: 1px !important;
  margin-top: 1px !important;
  flex-shrink: 0 !important;
}

#stakeholders-map-wrapper .stakeholder-result-category .category-text-label {
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
}

/* Action Links inside Mini Cards */
#stakeholders-map-wrapper .stakeholder-mini-link {
  display: block !important;
  width: max-content !important;
  margin-top: 4px !important; 
  margin-bottom: 0 !important;
  clear: both !important;
  color: #b12079;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.stakeholders-empty {
  padding: 16px;
  color: #666;
  background: #f8f9fa;
  border-radius: 12px;
}

/* Nesting Group Structures (Country & Cities on Right) */
.stakeholder-result-country {
  margin-bottom: 12px !important; 
}

.stakeholder-result-country > h3 {
  margin: 0 0 6px 0 !important;
  padding-bottom: 4px !important;
  border-bottom: 1px solid rgba(23, 25, 64, 0.08);
  color: #171940;
  font-size: 0.95rem;
  font-weight: 700;
}

.stakeholder-country-title small {
  margin-left: 6px;
  color: #6b7280;
  font-size: 0.8rem;
  font-weight: 600;
}

.stakeholder-result-city {
  margin-bottom: 6px !important;
}

.stakeholder-city-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0 0 4px 0 !important;
  margin-bottom: 4px !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #b12079;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
}

.city-toggle-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.city-toggle-arrow {
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}

.stakeholder-city-toggle.is-open .city-toggle-arrow {
  transform: rotate(90deg);
}

.stakeholder-city-toggle strong {
  min-width: 24px;
  height: 20px;
  border-radius: 999px;
  background: rgba(177, 32, 121, 0.08);
  color: #b12079;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
}

.stakeholder-city-members {
  display: grid;
  gap: 8px !important; 
}

/* Chip/Filter Conditionals Elements */
#stakeholders-map-wrapper .active-criteria,
#stakeholders-map-wrapper .selection-notice,
#stakeholders-map-wrapper .selected-results-actions {
  padding-left: 12px;
  padding-right: 12px;
}

#stakeholders-map-wrapper .active-criteria {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 10px;
  max-width: 100%;
}

#stakeholders-map-wrapper .active-criteria[hidden] {
  display: none;
}

#stakeholders-map-wrapper .selection-notice {
  margin: 6px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

#stakeholders-map-wrapper .selected-results-actions {
  margin: 0 0 10px;
}

#stakeholders-map-wrapper .back-to-results-btn {
  border: 1px solid var(--stakeholders-border);
  background: #ffffff;
  color: #111827;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

#stakeholders-map-wrapper .back-to-results-btn:hover {
  border-color: var(--stakeholders-accent);
  color: var(--stakeholders-accent);
  background: #ffffff;
}

#stakeholders-map-wrapper .criteria-chip {
  --criteria-color: var(--pulse-art-grey, #9ca3af);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  border-left: 3px solid var(--criteria-color) !important;
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--stakeholders-muted-bg);
  color: #374151;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

#stakeholders-map-wrapper .criteria-chip-label {
  flex: 0 0 auto;
  color: #4b5563;
  font-weight: 700;
}

#stakeholders-map-wrapper .criteria-chip strong {
  min-width: 0;
  color: #111827;
  font-weight: 800;
  overflow-wrap: anywhere;
}

#stakeholders-map-wrapper .criteria-chip-country,
#stakeholders-map-wrapper .criteria-chip-location {
  --criteria-color: var(--stakeholders-blue);
}

#stakeholders-map-wrapper .criteria-chip-selected {
  --criteria-color: var(--pulse-art-grey, #9ca3af);
  background: #f8fafc;
}

/* =========================================================
   Layout Polishing Framework Handles
   ========================================================= */

#stakeholders-map-wrapper svg.custom-section-curved-top-7,
#stakeholders-map-wrapper svg.custom-page-header-curved-top-1,
svg.custom-section-curved-top-7,
svg.custom-page-header-curved-top-1,
.custom-circle {
  pointer-events: none !important;
}

body .main {
  border-bottom: none !important;
}

body footer,
body #footer {
  border-top: none !important;
}

body #footer::before,
body #footer::after {
  display: none !important;
}

/* Responsive Media Queries */
@media (max-width: 991px) {
  #stakeholders-map-wrapper .stakeholders-map-results-layout {
    grid-template-columns: 1fr;
  }

  #stakeholders-map-wrapper #map {
    height: 56vh;
    min-height: 380px;
  }

  #stakeholders-map-wrapper .stakeholders-results-wrap {
    height: auto;
    max-height: none;
  }
}