/* Map Controls Bar - Compact Premium Design */

.map-controls-bar {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1000;
  display: flex;
  align-items: center; /* Center items vertically */
  gap: 8px;
  padding: 6px 10px;
  background: #1e293bf2; /* slate-800 with transparency */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid #7297F045;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
}

/* Control Group Wrapper */
.control-group {
  display: flex;
  align-items: center;
}

/* Individual Control Item (Button + Label) */
.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  position: relative; /* Ensure children popups are relative to this */
}

/* Zoom Row Layout - More compact */
.control-buttons-row {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 1px 2px;
}

/* Control Labels */
.control-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
}

.control-label svg {
  width: 8px;
  height: 8px;
  opacity: 0.6;
}

/* Map Control Buttons - Smaller */
.map-control-btn {
  background: transparent;
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px;
  padding: 0;
}

.map-control-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.map-control-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* Zoom Level Display */
.zoom-level {
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  min-width: 38px;
  text-align: center;
  user-select: none;
}

/* Vertical Divider - Taller and slimmer */
.control-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 8px;
}

/* ── Filter Dropdown ── */
.dropdown-parent {
  position: relative;
}

.map-filter-dropdown {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.map-filter-dropdown.hidden {
  display: none;
}

.map-filter-dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}

.filter-dropdown-content {
  padding: 14px 0;
}

.filter-panel-section {
  padding: 0 14px;
  margin-bottom: 16px;
}

.filter-section-title {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.mt-filter-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mt-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
}

.mt-filter-option:hover {
  color: #2563eb;
}

.mt-filter-option input[type="checkbox"] {
  display: none;
}

.fb-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid #cbd5e1;
  border-radius: 3px;
  position: relative;
  background: #fff;
}

.mt-filter-option input[type="checkbox"]:checked + .fb-checkbox {
  background: #2563eb;
  border-color: #2563eb;
}

.mt-filter-option input[type="checkbox"]:checked + .fb-checkbox::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%) rotate(45deg);
}

.filter-dropdown-footer {
  padding: 10px 14px 0;
  border-top: 1px solid #f1f5f9;
  margin-top: 4px;
}

.clear-filters-btn {
  width: 100%;
  padding: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-filters-btn:hover {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

/* ── Search Input Popup ── */
.search-input-container {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 260px;
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  padding: 8px;
  z-index: 1001;
  display: flex !important;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
  opacity: 0;
  visibility: hidden;
}

.search-input-container.active {
  opacity: 1;
  visibility: visible;
}

.search-input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  padding: 6px 10px;
  width: 100%;
  outline: none;
}

.search-result-count {
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  text-align: right;
}

.search-result-count:empty {
  display: none;
}

/* Active States */
.map-control-btn.active {
  color: #60a5fa;
  /* background check removed for blocky look */
}

/* ── Multi-Select Action Panel ── */
.multi-select-panel {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: #1e293bf2;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid #7297F045;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 13px;
  animation: ms-fade-in 0.18s ease;
}

.multi-select-panel.hidden {
  display: none;
}

@keyframes ms-fade-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.ms-count {
  padding: 0 10px;
  font-weight: 500;
  white-space: nowrap;
}

.ms-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 4px;
}

.ms-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.ms-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.ms-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.ms-btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.ms-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}

.ms-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

@media (max-width: 768px) {
  .multi-select-panel {
    top: 70px;
    left: 8px;
    right: 8px;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
    padding: 6px;
  }
  @keyframes ms-fade-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .ms-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ── Floating Action Buttons (Connect Nodes, Menu) ── */
.map-action-button {
  position: fixed;
  right: 20px;
  background: #1e293bf2;
  color: white;
  border: 2px solid #7297F045;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
  z-index: 99;
  margin: 10px 0;
  min-width: 180px;
  box-sizing: border-box;
}

.map-action-button:hover {
  border-color: #4752C4;
}

.map-action-button svg {
  flex-shrink: 0;
}

#connect-nodes-btn {
  top: 129px;
}

#map-menu-btn {
  top: 181px;
}

.map-action-button.active {
  background: #4752C4;
  border-color: #4752C4;
}

/* ── Connect Mode Status Bar ── */
.connect-mode-bar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: white;
  font-size: 14px;
  z-index: 1002;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.connect-mode-bar.hidden {
  display: none;
}

.connect-mode-cancel {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.connect-mode-cancel:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Header search button - hidden on desktop */
.header-search-btn {
  display: none;
}

/* Mobile search container - hidden by default */
.header-search-container {
  display: none;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .header-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s;
  }

  .header-search-btn:hover {
    background: rgba(255, 255, 255, 0.12);
  }

  .header-search-btn svg {
    width: 20px;
    height: 20px;
  }
  /* Controls bar: only filter + show-labels visible */
  .map-controls-bar {
    left: 12px;
    width: auto;
    bottom: 40px;
    padding: 8px;
    border-radius: 20px;
    justify-content: space-evenly;
  }

  .control-label {
    display: none;
  }

  .control-item {
    min-width: 32px;
  }

  /* Hide zoom and map toggle groups, search group (search moves to header) */
  .map-controls-bar > .control-group:first-child {
    display: none;
  }

  .map-controls-bar > .search-group {
    display: none;
  }

  /* Hide dividers */
  .control-divider {
    display: none;
  }

  /* Filter dropdown: full-width bottom sheet with slide animation */
  .map-filter-dropdown {
    position: fixed;
    bottom: -45px;
    left: -15px;
    right: 0;
    top: auto;
    width: 102vw;
    /* margin: 0; */
    padding: 0;
    border: none;
    border-bottom: none;
    transform: translateY(100%);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
    z-index: 1100;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    display: block !important;
    pointer-events: none;
  }

  .map-filter-dropdown:not(.hidden) {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
  }

  .map-filter-dropdown::after {
    display: none;
  }

  .map-action-button span {
    display: none;
  }

  .map-action-button {
    padding: 10px;
    min-width: inherit;
  }

  #connect-nodes-btn {
    top: 115px;
  }

  #map-menu-btn {
    top: 161px;
  }

  /* Search in header: full-width below header */
  .header-search-container {
    position: fixed;
    top: calc(var(--header-height, 60px) + 4px);
    left: 8px;
    right: 8px;
    z-index: 1050;
    display: none;
  }

  .header-search-container.active {
    display: flex;
  }

  .header-search-container .search-input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(12px);
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }

  .header-search-container .search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
  }

  .header-search-container .search-result-count {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
  }
}

@media (max-width: 480px) {
  .connect-mode-bar {
    left: 8px;
    right: 8px;
    transform: none;
    font-size: 12px;
    padding: 8px 12px;
  }
}
