/**
 * Branch Locator Widget - Styles
 * Version: 2.0.0
 * 
 * All styles are scoped to .bl-widget to avoid conflicts with host site.
 * Colors use CSS custom properties for easy theming.
 */

/* ===== CSS CUSTOM PROPERTIES (Theming) ===== */
.bl-widget {
  --bl-primary: #00185E;
  --bl-accent: #00d68f;
  --bl-secondary: #7fa895;
  --bl-warning: #f36f42;
  --bl-light: #f8f9fa;
  --bl-dark: #1a1a2e;
  --bl-border: #e2e8f0;
  --bl-shadow: 0 4px 20px rgba(0, 24, 94, 0.12);
  --bl-shadow-lg: 0 8px 40px rgba(0, 24, 94, 0.18);
  --bl-radius: 12px;
  --bl-radius-lg: 16px;
  --bl-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
.bl-widget {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #334155;
  box-sizing: border-box;
}

.bl-widget *,
.bl-widget *::before,
.bl-widget *::after {
  box-sizing: inherit;
}

.bl-widget button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.bl-widget input {
  font-family: inherit;
}

/* ===== MAIN CONTAINER ===== */
.bl-container {
  display: flex;
  height: 700px;
  max-height: 85vh;
  background: var(--bl-light);
  border-radius: var(--bl-radius-lg);
  overflow: hidden;
  box-shadow: var(--bl-shadow-lg);
  position: relative;
}

/* ===== SIDEBAR ===== */
.bl-sidebar {
  width: 380px;
  min-width: 380px;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--bl-border);
  z-index: 10;
  transition: var(--bl-transition);
}

.bl-sidebar.collapsed {
  margin-left: -380px;
}

/* Sidebar Toggle Button */
.bl-sidebar-toggle {
  position: absolute;
  left: 380px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  width: 28px;
  height: 56px;
  background: var(--bl-primary);
  border: 2px solid #fff;
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  transition: var(--bl-transition);
  color: #fff;
}

.bl-sidebar-toggle:hover {
  background: var(--bl-accent);
}

.bl-sidebar-toggle i {
  transition: transform 0.3s ease;
  font-size: 14px;
  color: #fff;
}

/* Mobile Drawer Handle - Hidden on desktop */
.bl-drawer-handle {
  display: none;
}

.bl-sidebar.collapsed + .bl-sidebar-toggle {
  left: 0;
  border-left: 2px solid #fff;
}

.bl-sidebar.collapsed + .bl-sidebar-toggle i {
  transform: rotate(180deg);
}

/* ===== FILTERS PANEL ===== */
.bl-filters {
  padding: 20px;
  border-bottom: 1px solid var(--bl-border);
  background: linear-gradient(135deg, #fff 0%, var(--bl-light) 100%);
}

.bl-widget .bl-mobile-filter-toggle {
  display: none;
}

.bl-filters h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--bl-primary);
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bl-filters h3 i {
  font-size: 18px;
  color: var(--bl-accent);
}

/* Search Input */
.bl-search-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.bl-search-wrapper input {
  width: 100%;
  padding: 12px 44px 12px 16px;
  border: 2px solid var(--bl-border);
  border-radius: var(--bl-radius);
  font-size: 14px;
  transition: var(--bl-transition);
  background: #fff;
}

.bl-search-wrapper input:focus {
  outline: none;
  border-color: var(--bl-primary);
  box-shadow: 0 0 0 3px rgba(0, 24, 94, 0.1);
}

.bl-search-wrapper input::placeholder {
  color: #94a3b8;
}

.bl-search-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bl-accent);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--bl-transition);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bl-search-btn:hover {
  background: var(--bl-primary);
}

.bl-search-btn i {
  color: #fff;
}

.bl-clear-search {
  position: absolute;
  right: 48px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.bl-clear-search:hover {
  background: var(--bl-light);
  color: var(--bl-primary);
}

.bl-search-wrapper.has-value .bl-clear-search {
  display: flex;
}

/* Autocomplete Dropdown */
.bl-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--bl-border);
  border-radius: var(--bl-radius);
  box-shadow: var(--bl-shadow);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  margin-top: 4px;
}

.bl-autocomplete.active {
  display: block;
}

.bl-autocomplete-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--bl-primary);
  border-bottom: 1px solid var(--bl-border);
  transition: background 0.15s ease;
}

.bl-autocomplete-item:last-child {
  border-bottom: none;
}

.bl-autocomplete-item:hover,
.bl-autocomplete-item.highlighted {
  background: var(--bl-light);
}

.bl-autocomplete-item small {
  color: #64748b;
  display: block;
  font-size: 12px;
}

/* Type Filter Toggles */
.bl-type-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 16px;
}

.bl-type-filter-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: -2px;
  border-radius: 2px;
}

.bl-type-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  background: #fff;
  border: 2px solid var(--bl-border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bl-primary);
  cursor: pointer;
  transition: var(--bl-transition);
  user-select: none;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  text-align: center;
}

.bl-type-filter:hover {
  border-color: var(--bl-primary);
  background: var(--bl-light);
}

.bl-type-filter.active {
  background: var(--bl-primary);
  border-color: var(--bl-primary);
  color: #fff;
}

.bl-type-filter.active i {
  color: var(--bl-accent);
}

.bl-type-filter.active .bl-type-filter-icon {
  filter: none;
}

.bl-type-filter input {
  display: none;
}

.bl-type-filter i {
  font-size: 14px;
}

/* Feature Filters */
.bl-feature-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.bl-feature-filter {
  padding: 6px 12px;
  background: #fff;
  border: 2px solid var(--bl-border);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--bl-primary);
  cursor: pointer;
  transition: var(--bl-transition);
}

.bl-feature-filter:hover {
  border-color: var(--bl-secondary);
  background: var(--bl-light);
}

.bl-feature-filter.active {
  background: var(--bl-secondary);
  border-color: var(--bl-secondary);
  color: #fff;
}

/* Near Me Button */
.bl-widget .bl-nearme-btn {
  width: 100%;
  padding: 12px 16px;
    background: var(--bl-primary) !important;
    box-shadow: 0 0 0 2px var(--bl-accent);
  border: none;
  border-radius: var(--bl-radius);
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--bl-transition);
}

.bl-widget .bl-nearme-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 214, 143, 0.3);
}

.bl-widget .bl-nearme-btn:active {
  transform: translateY(0);
}

.bl-widget .bl-nearme-btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.bl-widget .bl-nearme-btn.loading i {
  animation: bl-spin 1s linear infinite;
}

.bl-widget .bl-nearme-btn i {
  color: #fff !important;
}

@keyframes bl-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== BRANCH LIST HEADER ===== */
.bl-list-header {
  padding: 16px 20px;
  background: var(--bl-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bl-list-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bl-list-header h3 i {
  color: var(--bl-accent);
}

.bl-count {
  background: var(--bl-accent);
  color: #fff;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

/* ===== BRANCH LIST ===== */
.bl-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}

.bl-list::-webkit-scrollbar {
  width: 6px;
}

.bl-list::-webkit-scrollbar-track {
  background: var(--bl-light);
}

.bl-list::-webkit-scrollbar-thumb {
  background: var(--bl-border);
  border-radius: 3px;
}

.bl-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Branch List Item */
.bl-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bl-border);
  cursor: pointer;
  transition: var(--bl-transition);
  position: relative;
}

.bl-item:hover {
  background: var(--bl-light);
}

.bl-item.active {
  background: linear-gradient(90deg, rgba(0, 214, 143, 0.1) 0%, transparent 100%);
  border-left: 3px solid var(--bl-accent);
}

.bl-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bl-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--bl-primary);
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bl-badge {
  font-size: 9px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bl-badge.open {
  background: var(--bl-accent);
  color: #fff;
}

.bl-badge.closed {
  background: #dc2626;
  color: #fff;
}

.bl-item-distance {
  font-size: 13px;
  font-weight: 600;
  color: var(--bl-secondary);
  white-space: nowrap;
}

.bl-item-address {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.bl-item-features {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bl-feature-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bl-light);
  color: #64748b;
  border-radius: 4px;
}

.bl-feature-tag.atm {
  background: rgba(0, 24, 94, 0.1);
  color: var(--bl-primary);
}

/* No Results */
.bl-no-results {
  padding: 40px 20px;
  text-align: center;
  color: #64748b;
}

.bl-no-results i {
  font-size: 48px;
  color: var(--bl-border);
  margin-bottom: 16px;
  display: block;
}

.bl-no-results h4 {
  margin: 0 0 8px 0;
  color: var(--bl-primary);
}

.bl-no-results p {
  margin: 0;
  font-size: 14px;
}

/* ===== MAP CONTAINER ===== */
.bl-map-container {
  flex: 1;
  position: relative;
  background: var(--bl-light);
}

#bl-map {
  width: 100%;
  height: 100%;
}

/* ===== MAP CONTROLS ===== */
.bl-map-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bl-map-control-btn {
  width: 44px;
  height: 44px;
  background: var(--bl-primary) !important;
  border: 2px solid #fff !important;
  border-radius: var(--bl-radius);
  box-shadow: var(--bl-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff !important;
  font-size: 20px;
  transition: var(--bl-transition);
}

.bl-map-control-btn i {
  color: #ffffff !important;
  font-size: 20px !important;
}

.bl-map-control-btn:hover {
  background: var(--bl-accent) !important;
  border-color: var(--bl-accent) !important;
}

/* Layer Switcher */
.bl-layer-switcher {
  position: absolute;
  top: 16px;
  right: 70px;
  z-index: 5;
}

.bl-layer-btn {
  background: var(--bl-primary) !important;
  border: 2px solid #fff !important;
  padding: 10px 16px;
  border-radius: var(--bl-radius);
  box-shadow: var(--bl-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  transition: var(--bl-transition);
}

.bl-layer-btn i {
  color: #ffffff !important;
  font-size: 16px !important;
}

.bl-layer-btn:hover {
  background: var(--bl-accent) !important;
  border-color: var(--bl-accent) !important;
}

.bl-layer-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 2px solid var(--bl-primary);
  border-radius: var(--bl-radius);
  box-shadow: var(--bl-shadow-lg);
  overflow: hidden;
  min-width: 160px;
  display: none;
}

.bl-layer-dropdown.active {
  display: block;
}

.bl-layer-option {
  padding: 12px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--bl-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--bl-border);
}

.bl-layer-option:last-child {
  border-bottom: none;
}

.bl-layer-option:hover {
  background: var(--bl-light);
}

.bl-layer-option.active {
  background: var(--bl-primary);
  color: #fff;
  font-weight: 600;
}

.bl-layer-option.active i {
  color: var(--bl-accent);
}

.bl-layer-option i {
  width: 18px;
  font-size: 16px;
}

/* Zoom Controls */
.bl-zoom-controls {
  position: absolute;
  bottom: 100px;
  right: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--bl-primary);
  border: 2px solid #fff;
  border-radius: var(--bl-radius);
  box-shadow: var(--bl-shadow);
  overflow: hidden;
}

.bl-zoom-btn {
  width: 44px;
  height: 44px;
  background: var(--bl-primary) !important;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff !important;
  font-size: 22px;
  font-weight: 700;
  transition: var(--bl-transition);
}

.bl-zoom-btn i {
  color: #ffffff !important;
  font-size: 22px !important;
}

.bl-zoom-btn:first-child {
  border-bottom: 1px solid rgba(255,255,255,0.3);
}

.bl-zoom-btn:hover {
  background: var(--bl-accent) !important;
}

/* Attribution */
.bl-attribution {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 5;
  font-size: 10px;
  color: var(--bl-primary);
  background: rgba(255,255,255,0.95);
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.bl-attribution a {
  color: var(--bl-primary);
  font-weight: 600;
  text-decoration: underline;
}

/* ===== POPUP STYLES ===== */
.bl-popup .maplibregl-popup-content {
  padding: 0 !important;
  border-radius: var(--bl-radius-lg) !important;
  box-shadow: var(--bl-shadow-lg) !important;
  overflow: hidden;
}

.bl-popup .maplibregl-popup-close-button {
  width: 32px;
  height: 32px;
  font-size: 24px;
  color: #fff !important;
  background: var(--bl-primary) !important;
  border-radius: 50%;
  right: 8px;
  top: 8px;
  line-height: 28px;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bl-popup .maplibregl-popup-close-button:hover {
  background: var(--bl-accent) !important;
}

.bl-popup .maplibregl-popup-tip {
  border-top-color: #fff;
}

/* Popup Content */
.bl-popup-content {
  width: 320px;
}

.bl-popup-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  background: var(--bl-light);
}

.bl-popup-body {
  padding: 12px;
}

.bl-popup-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--bl-primary);
  margin: 0 0 2px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
}

.bl-popup-address {
  font-size: 11px;
  color: #64748b;
  margin: 0 0 10px 0;
}

/* Popup Tabs */
.bl-popup-tabs {
  display: flex;
  background: var(--bl-primary);
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 10px;
  gap: 3px;
}

.bl-popup-tab {
  flex: 1;
  padding: 6px 4px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: all 0.2s ease;
}

.bl-popup-tab:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.bl-popup-tab.active {
  color: var(--bl-primary);
  background: #fff;
}

/* Popup Tab Panels */
.bl-popup-panel {
  display: none;
}

.bl-popup-panel.active {
  display: block;
}

/* Details Panel */
.bl-popup-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.4;
}

.bl-popup-detail-row i {
  color: var(--bl-accent);
  width: 14px;
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 12px;
}

.bl-popup-detail-row a {
  color: var(--bl-primary);
  text-decoration: none;
  font-weight: 600;
}

.bl-popup-detail-row a:hover {
  color: var(--bl-accent);
}

/* Hours Panel */
.bl-popup-hours {
  font-size: 11px;
  color: var(--bl-primary);
  line-height: 1.5;
}

.bl-hours-section {
  margin-bottom: 8px;
  padding: 6px 8px;
  background: var(--bl-light);
  border-radius: 4px;
  border-left: 3px solid var(--bl-accent);
}

.bl-hours-section:last-child {
  margin-bottom: 0;
}

.bl-hours-section strong {
  color: var(--bl-primary);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 2px;
}

.bl-hours-section div {
  color: #64748b;
}

/* Services/Features Panel */
.bl-popup-features {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bl-popup-feature {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  background: var(--bl-primary);
  color: #fff;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bl-popup-feature i {
  font-size: 10px;
  color: var(--bl-accent);
}

/* Popup Actions */
.bl-popup-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--bl-border);
}

.bl-popup-action {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 6px;
  font-size: 9px !important;
  font-weight: 700 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  transition: var(--bl-transition);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: center;
  white-space: nowrap;
  color: #ffffff !important;
}

.bl-popup-action.primary {
  background: var(--bl-accent) !important;
}

.bl-popup-action.primary:hover {
  background: #00b377 !important;
}

.bl-popup-action.secondary {
  background: var(--bl-primary) !important;
}

.bl-popup-action.secondary:hover {
  background: #001245 !important;
}

/* ===== USER LOCATION MARKER ===== */
.bl-user-marker {
  width: 20px;
  height: 20px;
  background: var(--bl-accent);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(0, 214, 143, 0.3), 0 2px 8px rgba(0,0,0,0.2);
  animation: bl-pulse 2s infinite;
}

@keyframes bl-pulse {
  0% { box-shadow: 0 0 0 4px rgba(0, 214, 143, 0.3), 0 2px 8px rgba(0,0,0,0.2); }
  50% { box-shadow: 0 0 0 12px rgba(0, 214, 143, 0.1), 0 2px 8px rgba(0,0,0,0.2); }
  100% { box-shadow: 0 0 0 4px rgba(0, 214, 143, 0.3), 0 2px 8px rgba(0,0,0,0.2); }
}

/* ===== LOADING STATE ===== */
.bl-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.bl-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--bl-border);
  border-top-color: var(--bl-primary);
  border-radius: 50%;
  animation: bl-spin 1s linear infinite;
}

.bl-loading p {
  margin-top: 16px;
  color: var(--bl-primary);
  font-weight: 500;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  .bl-container {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    overflow: hidden;
    position: relative;
  }

  /* Map takes remaining space above drawer */
  .bl-map-container {
    order: 1;
    flex: 1;
    min-height: 40vh;
    position: relative;
  }

  /* Bottom Drawer - Shows list by default */
  .bl-sidebar {
    order: 2;
    width: 100%;
    min-width: 100%;
    max-height: 60vh;
    border-right: none;
    border-top: none;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    transition: max-height 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
  }

  /* Collapsed state - minimal peek */
  .bl-sidebar.collapsed {
    max-height: 44px;
  }

  .bl-sidebar-toggle {
    display: none;
  }

  /* Mobile Drawer Handle - Compact */
  .bl-drawer-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 6px 12px;
    cursor: pointer;
    background: var(--bl-primary);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
    min-height: 32px;
  }

  .bl-drawer-handle span {
    width: 32px;
    height: 3px;
    background: rgba(255,255,255,0.6);
    border-radius: 2px;
  }

  .bl-drawer-handle::after {
    content: "Branches";
    color: #fff;
    font-size: 12px;
    font-weight: 600;
  }

  .bl-sidebar.collapsed .bl-drawer-handle::after {
    content: "Tap to view branches";
  }

  /* Collapsible filters on mobile */
  .bl-filters {
    display: none;
    flex-direction: column;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
  }

  .bl-filters.mobile-open {
    display: flex;
    max-height: 300px;
    padding: 8px 12px;
  }

  .bl-widget .bl-mobile-filter-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bl-light);
    color: var(--bl-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-bottom: 1px solid var(--bl-border);
    width: 100%;
  }

  .bl-mobile-filter-toggle i {
    font-size: 14px;
  }

  /* Branch List Header - Very compact */
  .bl-list-header {
    padding: 6px 12px;
    flex-shrink: 0;
  }

  .bl-list-header h3 {
    font-size: 11px;
  }

  .bl-list-header h3 i {
    display: none;
  }

  .bl-count {
    font-size: 10px;
    padding: 2px 6px;
  }

  /* Branch List - Takes remaining space */
  .bl-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Compact branch items to show more */
  .bl-item {
    padding: 10px 12px;
  }

  .bl-item-header {
    gap: 8px;
  }

  .bl-item-name {
    font-size: 13px;
    margin-bottom: 2px;
  }

  .bl-item-name .bl-badge {
    font-size: 8px;
    padding: 2px 5px;
  }

  .bl-item-address {
    font-size: 11px;
    margin-bottom: 4px;
    line-height: 1.3;
  }

  .bl-item-distance {
    font-size: 11px;
    padding: 2px 6px;
  }

  /* Hide less important elements on mobile */
  .bl-item-features {
    display: none;
  }

  /* Map Controls - Top right on mobile */
  .bl-map-controls {
    top: 10px;
    right: 10px;
    bottom: auto;
    flex-direction: column;
    gap: 6px;
  }

  .bl-map-control-btn {
    width: 36px;
    height: 36px;
  }

  /* Layer switcher - Top left on mobile, icon only */
  .bl-layer-switcher {
    position: absolute;
    top: 10px;
    left: 10px;
    right: auto;
    bottom: auto;
    z-index: 10;
  }

  .bl-layer-btn {
    padding: 8px !important;
    font-size: 0 !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0 !important;
  }

  .bl-layer-btn i {
    font-size: 18px !important;
  }

  .bl-layer-dropdown {
    left: 0;
    right: auto;
  }

  /* Zoom controls */
  .bl-zoom-controls {
    position: absolute;
    top: 94px;
    right: 10px;
    bottom: auto;
  }

  .bl-zoom-btn {
    width: 32px !important;
    height: 32px !important;
    font-size: 18px !important;
  }

  /* POPUP - Bottom card style on mobile */
  .bl-popup {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 50px !important;
    top: auto !important;
    transform: none !important;
    max-width: none !important;
    width: auto !important;
    z-index: 200 !important;
  }

  .bl-popup .maplibregl-popup-tip {
    display: none !important;
  }

  .bl-popup .maplibregl-popup-content {
    padding: 0 !important;
    border-radius: 12px !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2) !important;
  }

  .bl-popup-content {
    width: 100%;
    max-width: none;
    display: flex;
    flex-direction: row;
    border-radius: 12px;
    overflow: hidden;
  }

  .bl-popup-image {
    width: 100px;
    height: auto;
    min-height: 100%;
    flex-shrink: 0;
  }

  .bl-popup-body {
    flex: 1;
    padding: 10px;
    min-width: 0;
  }

  .bl-popup-title {
    font-size: 14px;
    margin-bottom: 2px;
  }

  .bl-popup-address {
    font-size: 10px;
    margin-bottom: 6px;
  }

  .bl-popup-tabs {
    margin-bottom: 6px;
    padding: 2px;
    border-radius: 4px;
  }

  .bl-popup-tab {
    padding: 4px 6px;
    font-size: 8px;
  }

  .bl-popup-detail-row {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .bl-popup-detail-row i {
    font-size: 10px;
    width: 12px;
  }

  .bl-popup-hours {
    font-size: 9px;
  }

  .bl-hours-section {
    padding: 4px 6px;
    margin-bottom: 4px;
  }

  .bl-hours-section strong {
    font-size: 8px;
  }

  .bl-popup-feature {
    font-size: 8px;
    padding: 2px 5px;
  }

  .bl-popup-features {
    gap: 3px;
  }

  .bl-popup-actions {
    margin-top: 6px;
    padding-top: 6px;
    gap: 4px;
    flex-wrap: wrap;
  }

  .bl-popup-action {
    padding: 6px 8px !important;
    font-size: 8px !important;
    flex: 1 1 calc(50% - 2px);
    min-width: calc(50% - 2px);
  }

  /* Close button styling for mobile popup */
  .bl-popup .maplibregl-popup-close-button {
    font-size: 24px !important;
    padding: 4px 8px !important;
    right: 2px !important;
    top: 2px !important;
    color: var(--bl-primary) !important;
    background: rgba(255,255,255,0.9) !important;
    border-radius: 50% !important;
    width: 28px !important;
    height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
  }

  /* When popup is open, hide drawer completely */
  .bl-sidebar.popup-open {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .bl-sidebar {
    max-height: 55vh;
  }

  .bl-sidebar.collapsed {
    max-height: 40px;
  }

  .bl-drawer-handle {
    padding: 5px 10px;
    min-height: 28px;
  }

  .bl-drawer-handle span {
    width: 28px;
  }

  .bl-drawer-handle::after {
    font-size: 11px;
  }

  .bl-list-header {
    padding: 5px 10px;
  }

  .bl-item {
    padding: 8px 10px;
  }

  .bl-item-name {
    font-size: 12px;
  }

  .bl-item-address {
    font-size: 10px;
  }

  .bl-popup-image {
    width: 80px;
  }

  .bl-popup-body {
    padding: 8px;
  }

  .bl-popup-title {
    font-size: 13px;
  }

  .bl-popup-action {
    padding: 5px 6px !important;
    font-size: 7px !important;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .bl-sidebar {
    max-height: 35vh;
  }

  .bl-sidebar.collapsed {
    max-height: 44px;
  }

  .bl-drawer-handle {
    padding: 6px 12px;
    min-height: 32px;
  }

  .bl-popup-content {
    flex-direction: row;
  }

  .bl-popup-image {
    width: 120px;
  }
}

/* MapLibre Default Control Overrides */
.bl-widget .maplibregl-ctrl-group {
  background: var(--bl-primary) !important;
  border: 2px solid #fff !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

.bl-widget .maplibregl-ctrl-group button {
  background-color: var(--bl-primary) !important;
  border: none !important;
  width: 36px !important;
  height: 36px !important;
}

.bl-widget .maplibregl-ctrl-group button:hover {
  background-color: var(--bl-accent) !important;
}

.bl-widget .maplibregl-ctrl-group button + button {
  border-top: 1px solid rgba(255,255,255,0.3) !important;
}

.bl-widget .maplibregl-ctrl button .maplibregl-ctrl-icon {
  filter: brightness(0) invert(1) !important;
}

/* Hide default MapLibre controls (we use custom) */
.bl-widget .maplibregl-ctrl-bottom-left,
.bl-widget .maplibregl-ctrl-bottom-right {
  display: none;
}

/* Error banner */
.bl-error-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #d32f2f;
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  animation: bl-fade-in 0.2s ease;
}

.bl-error-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.8;
}

.bl-error-close:hover { opacity: 1; }

@keyframes bl-fade-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
