/**
 * map-widget.css
 * Scoped to #map-widget-app — no conflicts with host theme.
 * Assumes Bootstrap is already loaded globally.
 *
 * Type-specific card icon colors (.map-widget-location-card--{type})
 * use whatever type strings your data/config defines.
 * Add or swap those selectors in your instance stylesheet as needed.
 */

/* ── Variables ─────────────────────────────────────────────────── */
#map-widget-app {
  --map-widget-primary:        #1a3a6b;
  --map-widget-primary-dark:   #132d54;
  --map-widget-primary-mid:    #1e4480;
  --map-widget-accent:         #1a8a8a;
  --map-widget-accent-light:   #2ab0b0;
  --map-widget-highlight:      #f5c518;
  --map-widget-highlight-dark: #d4a800;
  --map-widget-alt:            #e07020;
  --map-widget-gray-100:       #f5f5f5;
  --map-widget-gray-200:       #e8e8e8;
  --map-widget-gray-400:       #bbb;
  --map-widget-gray-600:       #666;
  --map-widget-text:           #222;
  --map-widget-sidebar-w:      380px;
  --map-widget-bar-h:          60px;
  --map-widget-map-h:          520px;
  --map-widget-radius:         3px;
  --map-widget-ease:           0.2s ease;
}

/* ── App shell ─────────────────────────────────────────────────── */
#map-widget-app {
  position: relative;
  display: flex;
  flex-direction: column;
  font-family: 'Source Sans Pro', 'Open Sans', 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--map-widget-text);
  background: #fff;
  border: 1px solid var(--map-widget-gray-200);
  overflow: visible;
}

/* ── Search bar ────────────────────────────────────────────────── */
#map-widget-search-bar {
  display: flex;
  align-items: stretch;
  height: var(--map-widget-bar-h);
  background: var(--map-widget-primary);
  flex-shrink: 0;
}

/* Locate Me */
#map-widget-geo-btn {
  height: 100%;
  min-width: 96px;
  padding: 0 12px;
  background: var(--map-widget-highlight);
  border: none;
  border-radius: 0;
  color: var(--map-widget-primary-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--map-widget-ease);
}
#map-widget-geo-btn:hover { background: var(--map-widget-highlight-dark); }
#map-widget-geo-btn .fas  { font-size: 17px; }
#map-widget-geo-btn span  { font-size: 10px; line-height: 1; }

/* Dropdowns injection container */
#map-widget-dropdowns {
  display: contents; /* children participate in the flex row directly */
}

/* City / County / any config-driven dropdowns */
.map-widget-dropdown-wrap {
  position: relative;
  flex: 1;
  height: 100%;
  border-left: 1px solid rgba(255,255,255,0.12);
}

.map-widget-search-input {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  background: #fff;
  color: #003366;
  font-size: 14px;
  font-weight: 600;
  padding: 0 36px 0 16px;
  box-shadow: none;
  outline: none;
}
.map-widget-search-input::placeholder { color: #003366; opacity: 0.6; }
.map-widget-search-input:focus { background: #f0f4f8; color: #003366; }

.map-widget-caret {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.4);
  pointer-events: none;
  font-size: 12px;
}

/* Dropdown list */
.map-widget-dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 2000;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--map-widget-gray-400);
  border-top: none;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  list-style: none;
  margin: 0;
  padding: 0;
}
.map-widget-dropdown-list li {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--map-widget-text);
  border-bottom: 1px solid var(--map-widget-gray-100);
  transition: background var(--map-widget-ease);
}
.map-widget-dropdown-list li:last-child { border-bottom: none; }
.map-widget-dropdown-list li:hover,
.map-widget-dropdown-list li.is-active-option {
  background: #e6f5f5;
  color: var(--map-widget-accent);
}
.map-widget-dropdown-list li[hidden] { display: none; }

/* Zip search */
#map-widget-zip-wrap {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.12);
}
#map-widget-zip-input {
  width: 116px;
  height: 100%;
  border: none;
  border-radius: 0;
  background: #fff;
  color: var(--map-widget-text);
  font-size: 14px;
  padding: 0 12px;
  outline: none;
}
#map-widget-zip-input::placeholder { color: #aaa; }
#map-widget-zip-btn {
  height: 100%;
  padding: 0 20px;
  background: #003366;
  border: none;
  border-left: 1px solid var(--map-widget-gray-200);
  border-radius: 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: background var(--map-widget-ease);
}
#map-widget-zip-btn:hover { background: var(--map-widget-primary-mid); }

#map-widget-clear-btn {
  height: 100%;
  padding: 0 14px;
  background: var(--map-widget-accent);
  border: none;
  border-radius: 0;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--map-widget-ease);
}
#map-widget-clear-btn:hover { background: var(--map-widget-accent-light); }

/* ── Map + sidebar row ─────────────────────────────────────────── */
#map-widget-map-wrapper {
  display: flex;
  flex-direction: row;
  height: var(--map-widget-map-h);
}

#map-widget-map-main {
  position: relative;
  flex: 1;
  min-width: 0;
}

#map-widget-map-canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ── Legend ────────────────────────────────────────────────────── */
#map-widget-legend {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.93);
  border-top: 1px solid var(--map-widget-gray-200);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 6px 16px;
  font-size: 12px;
  z-index: 5;
}
.map-widget-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.map-widget-legend-item img { width: 16px; height: auto; }

/* ── Sidebar ───────────────────────────────────────────────────── */
#map-widget-sidebar {
  width: var(--map-widget-sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid var(--map-widget-gray-200);
  position: relative;
  transition: width var(--map-widget-ease);
  overflow: hidden;
  border-top: 1px solid var(--map-widget-accent)
}
#map-widget-sidebar.map-widget-sidebar--closed { width: 0; }

#map-widget-sidebar-toggle {
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 18px;
  height: 52px;
  background: var(--map-widget-primary);
  border: none;
  border-radius: 4px 0 0 4px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
}
#map-widget-sidebar-toggle:hover { background: var(--map-widget-primary-mid); }

#map-widget-sidebar-inner {
  width: var(--map-widget-sidebar-w);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Sidebar header */
#map-widget-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 16px;
  height: 50px;
  background: #fff;
  border-bottom: 1px solid var(--map-widget-gray-200);
  flex-shrink: 0;
}

.map-widget-sidebar-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--map-widget-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.map-widget-sidebar-actions { display: flex; gap: 6px; align-items: center; }

.map-widget-btn-filters {
  background: #2e6a96;
  border: none;
  color: #fff;
  border-radius: var(--map-widget-radius);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background var(--map-widget-ease);
  white-space: nowrap;
}
.map-widget-btn-filters:hover { background: var(--map-widget-accent-light); }

/* ── Location list ─────────────────────────────────────────────── */
#map-widget-location-list {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#map-widget-location-list-inner {
  flex: 1;
  overflow-y: auto;
}

.map-widget-status-msg {
  padding: 20px 16px;
  font-size: 13px;
  color: var(--map-widget-gray-600);
  text-align: center;
}

.map-widget-scroll-btn {
  text-align: center;
  padding: 5px;
  background: var(--map-widget-gray-100);
  border-top: 1px solid var(--map-widget-gray-200);
  cursor: pointer;
  color: var(--map-widget-primary);
  font-size: 11px;
  flex-shrink: 0;
}
.map-widget-scroll-btn:hover { background: var(--map-widget-gray-200); }

/* ── Location cards ────────────────────────────────────────────── */
.map-widget-location-card {
  border-bottom: 1px solid var(--map-widget-gray-200);
  background: #fff;
}
.map-widget-location-card:last-child { border-bottom: none; }

.map-widget-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
  user-select: none;
}

.map-widget-card-header > .fa {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.map-widget-card-title { flex: 1; min-width: 0; line-height: 1.35; }
.map-widget-card-title strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--map-widget-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-widget-type-label { font-size: 11px; color: var(--map-widget-gray-600); }

.map-widget-card-toggle {
  background: none;
  border: none;
  color: var(--map-widget-primary);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  font-size: 17px;
  line-height: 1;
  transition: color var(--map-widget-ease);
}
.map-widget-card-toggle:hover { color: var(--map-widget-accent); }

/* Active / expanded card */
.map-widget-location-card.is-active { background: var(--map-widget-primary); }
.map-widget-location-card.is-active .map-widget-card-header > .fa { color: var(--map-widget-highlight); }
.map-widget-location-card.is-active .map-widget-card-title strong { color: #fff; }
.map-widget-location-card.is-active .map-widget-type-label { color: rgba(255,255,255,0.65); }
.map-widget-location-card.is-active .map-widget-card-toggle { color: rgba(255,255,255,0.8); }
.map-widget-location-card.is-active .map-widget-card-body { background: var(--map-widget-primary); color: rgba(255,255,255,0.9); }
.map-widget-location-card.is-active .map-widget-card-row .fa { color: var(--map-widget-highlight); }
.map-widget-location-card.is-active .map-widget-card-row a { color: #7dd8d8; }
.map-widget-location-card.is-active .map-widget-card-row a:hover { color: #fff; text-decoration: underline; }
.map-widget-location-card.is-active .map-widget-day { color: rgba(255,255,255,0.6); }
.map-widget-location-card.is-active .map-widget-card-courses p,
.map-widget-location-card.is-active .map-widget-card-courses ul { color: rgba(255,255,255,0.85); }

/* CTA buttons */
.map-widget-cta-btn {
  display: block;
  width: 100%;
  background: var(--map-widget-accent);
  color: #fff;
  text-align: center;
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  margin-top: 6px;
  transition: background var(--map-widget-ease);
}
.map-widget-cta-btn:hover { background: var(--map-widget-accent-light); color: #fff; text-decoration: none; }

/* Card body */
.map-widget-card-body {
  padding: 2px 12px 12px 42px;
  font-size: 13px;
  line-height: 1.5;
}
.map-widget-card-row {
  display: flex;
  gap: 8px;
  margin-bottom: 7px;
  align-items: flex-start;
}
.map-widget-card-row .fa {
  color: var(--map-widget-highlight-dark);
  font-size: 13px;
  margin-top: 2px;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}
.map-widget-card-row a { color: var(--map-widget-accent); text-decoration: none; word-break: break-word; }
.map-widget-card-row a:hover { text-decoration: underline; }

.map-widget-day {
  font-weight: 700;
  display: inline-block;
  width: 34px;
  font-size: 12px;
  color: var(--map-widget-gray-600);
}
.map-widget-hours-row { font-size: 12px; line-height: 1.7; }
.map-widget-card-courses ul { margin: 4px 0 0; padding-left: 14px; font-size: 12px; }
.map-widget-card-courses p { margin: 0; font-size: 12px; font-weight: 600; }

/* ── Filters panel ─────────────────────────────────────────────── */
#map-widget-filters {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: none;
}
#map-widget-filters.is-visible { display: block; }

#map-widget-close-filters {
  background: none;
  border: none;
  color: var(--map-widget-gray-600);
  cursor: pointer;
  font-size: 15px;
  padding: 0;
  line-height: 1;
}
#map-widget-close-filters:hover { color: var(--map-widget-primary); }

.map-widget-filter-group {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--map-widget-gray-200);
}
.map-widget-filter-group:last-child { border-bottom: none; }
.map-widget-filter-group > p { margin-bottom: 8px; }
.map-widget-filter-group > p strong {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--map-widget-primary);
}
.map-widget-filter-group .form-check { margin-bottom: 5px; }
.map-widget-filter-group .form-check-label { font-size: 13px; cursor: pointer; }
.map-widget-filter-group .form-check-input { cursor: pointer; }
.map-widget-filter-group .form-check-input:checked {
  background-color: var(--map-widget-accent);
  border-color: var(--map-widget-accent);
}

/* ── Active marker glow ────────────────────────────────────────── */
.map-widget-marker--active {
  filter: drop-shadow(0 0 5px rgba(26,138,138,0.9)) drop-shadow(0 0 2px rgba(0,0,0,0.4));
  z-index: 999 !important;
}

/* ── Mapbox popup ──────────────────────────────────────────────── */
.mapboxgl-popup-content {
  padding: 12px 16px;
  font-family: 'Source Sans Pro', 'Open Sans', sans-serif;
  font-size: 13px;
  border-radius: var(--map-widget-radius);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  min-width: 160px;
}
.map-widget-popup-name { font-weight: 700; color: var(--map-widget-primary); font-size: 14px; margin-bottom: 3px; }
.map-widget-popup-type { color: var(--map-widget-gray-600); font-size: 12px; margin-bottom: 8px; }
.map-widget-popup-directions {
  display: inline-block;
  background: var(--map-widget-primary);
  color: #fff !important;
  padding: 6px 12px;
  border-radius: var(--map-widget-radius);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.map-widget-popup-directions:hover { background: var(--map-widget-primary-mid); color: #fff; text-decoration: none; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #map-widget-app { --map-widget-sidebar-w: 300px; }
}

@media (max-width: 768px) {
  #map-widget-app {
    --map-widget-sidebar-w: 100%;
    --map-widget-map-h: 300px;
    --map-widget-bar-h: auto;
  }

  #map-widget-search-bar {
    flex-wrap: wrap;
    height: auto;
    padding: 6px;
    gap: 6px;
  }

  #map-widget-geo-btn {
    flex-direction: row;
    gap: 8px;
    height: 40px;
    min-width: 110px;
    flex: 0 0 auto;
  }

  /* dropdowns container: unwrap so children still flex */
  #map-widget-dropdowns {
    display: contents;
  }

  .map-widget-dropdown-wrap {
    flex: 1 1 calc(50% - 6px);
    height: 40px;
    border-left: none;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px;
  }

  .map-widget-search-input { border-radius: 3px; }

  #map-widget-zip-wrap {
    flex: 1 1 100%;
    height: 40px;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.12);
  }

  #map-widget-zip-input {
    flex: 1;
    width: auto;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px 0 0 3px;
  }

  #map-widget-zip-btn {
    border-radius: 0 3px 3px 0;
    border: 1px solid var(--map-widget-gray-200);
  }

  #map-widget-map-wrapper {
    flex-direction: column;
    height: auto;
  }

  #map-widget-map-main {
    height: 300px !important;
    min-height: 300px;
    flex-shrink: 0;
  }

  #map-widget-map-canvas {
    height: 300px !important;
  }

  #map-widget-legend {
    gap: 10px;
    padding: 5px 10px;
    font-size: 11px;
    flex-wrap: wrap;
    justify-content: center;
  }

  #map-widget-sidebar {
    position: relative;
    width: 100% !important;
    border-left: none;
    border-top: 3px solid var(--map-widget-primary);
  }

  #map-widget-sidebar-toggle {
    left: 50%;
    top: -24px;
    transform: translateX(-50%);
    width: 56px;
    height: 24px;
    border-radius: 4px 4px 0 0;
    font-size: 10px;
  }

  #map-widget-sidebar-inner {
    width: 100%;
  }

  #map-widget-sidebar.map-widget-sidebar--closed #map-widget-sidebar-inner {
    display: none;
  }

  #map-widget-location-list-inner {
    max-height: 260px;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  #map-widget-map-main,
  #map-widget-map-canvas {
    height: 240px !important;
    min-height: 240px;
  }

  .map-widget-dropdown-wrap {
    flex: 1 1 100%;
  }

  #map-widget-legend {
    display: none;
  }
}