/**
 * Business Directory Archive & Search Styles
 * Interactive Split-Screen Layout, Modern Filter Toolbar & Leaflet Map
 *
 * @package AllOfBD\Theme
 */

/* ── Archive Header ── */
.aofbd-archive-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--aofbd-border);
}

.aofbd-archive-header__title-area h1 {
  margin: 0 0 0.25rem 0;
  font-size: clamp(1.5rem, 2.5vw, 2.125rem);
  font-weight: 800;
  color: var(--aofbd-text-main);
  letter-spacing: -0.02em;
}

.aofbd-archive-header__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

#aofbd-toggle-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 600;
}

#aofbd-toggle-map-btn.is-active {
  background: #0d1b2a;
  color: #ffffff;
  border-color: #0d1b2a;
}

.aofbd-view-toggle {
  display: inline-flex;
  gap: 0.25rem;
}

.aofbd-view-toggle button {
  padding: 0.4375rem 0.625rem;
}

.aofbd-view-toggle button.is-active,
.aofbd-view-toggle button[aria-pressed="true"] {
  background: var(--aofbd-primary);
  border-color: var(--aofbd-primary);
  color: #ffffff;
}

/* ── Filter Bar Container ── */
.aofbd-filter-bar {
  background: #ffffff;
  border: 1px solid var(--aofbd-border);
  border-radius: var(--aofbd-radius-md);
  padding: 1.25rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.aofbd-filter-row--primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.aofbd-filter-field {
  flex: 1 1 160px;
}

.aofbd-filter-field--search {
  flex: 2 1 220px;
}

.aofbd-filter-field--price {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.aofbd-price-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--aofbd-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.aofbd-price-chips {
  display: inline-flex;
  border: 1px solid var(--aofbd-border);
  border-radius: var(--aofbd-radius-sm);
  overflow: hidden;
  background: #f8fafc;
}

.aofbd-price-chip {
  background: transparent;
  border: none;
  border-right: 1px solid var(--aofbd-border);
  padding: 0.4375rem 0.6875rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--aofbd-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.aofbd-price-chip:last-child {
  border-right: none;
}

.aofbd-price-chip:hover {
  background: #e2e8f0;
  color: var(--aofbd-text-main);
}

.aofbd-price-chip.is-selected {
  background: #0d1b2a;
  color: #f7b731;
}

.aofbd-filter-bar input[type="search"],
.aofbd-filter-bar select {
  width: 100%;
  min-height: 42px;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--aofbd-border);
  border-radius: var(--aofbd-radius-sm);
  font-size: 0.9375rem;
  color: var(--aofbd-text-main);
  background: #ffffff;
  transition: border-color 0.15s ease;
}

.aofbd-filter-bar input[type="search"]:focus,
.aofbd-filter-bar select:focus {
  border-color: var(--aofbd-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.aofbd-filter-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--aofbd-primary);
  color: #ffffff;
  font-size: 0.6875rem;
  font-weight: 800;
  border-radius: 9999px;
  padding: 0.125rem 0.4375rem;
  margin-left: 0.25rem;
}

/* ── Expandable Filter Drawer ── */
.aofbd-filter-drawer {
  display: none;
  padding-top: 1.25rem;
  margin-top: 1.25rem;
  border-top: 1px dashed var(--aofbd-border);
}

.aofbd-filter-drawer.is-open {
  display: block;
  animation: aofbdFadeDown 0.2s ease-out;
}

@keyframes aofbdFadeDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.aofbd-filter-drawer__grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
}

.aofbd-filter-drawer__heading {
  margin: 0 0 0.75rem 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--aofbd-text-main);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.aofbd-filter-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.aofbd-filter-checkboxes--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.625rem;
}

.aofbd-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--aofbd-text-main);
  cursor: pointer;
}

.aofbd-checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--aofbd-primary);
  cursor: pointer;
}

.aofbd-filter-drawer__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--aofbd-border);
}

/* ── Active Filter Chips Bar ── */
.aofbd-active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--aofbd-border);
}

.aofbd-active-filters__label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--aofbd-text-muted);
}

.aofbd-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 9999px;
  padding: 0.25rem 0.625rem;
}

.aofbd-filter-chip button {
  background: transparent;
  border: none;
  color: #1e40af;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  margin-left: 0.25rem;
  line-height: 1;
}

.aofbd-filter-chip button:hover {
  color: #b91c1c;
}

.aofbd-filter-clear-all {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #b91c1c;
  text-decoration: underline;
  margin-left: 0.5rem;
}

/* ── Split-Screen Layout (Results + Sticky Map) ── */
.aofbd-archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(380px, 1fr);
  gap: 2rem;
  align-items: start;
}

.aofbd-archive-layout--no-map {
  grid-template-columns: 1fr;
}

.aofbd-archive-layout--no-map .aofbd-archive-map-sidebar {
  display: none;
}

.aofbd-archive-layout--no-map #aofbd-archive-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.aofbd-archive-content {
  min-width: 0;
}

.aofbd-archive-map-sidebar {
  position: sticky;
  top: 96px;
  height: calc(100vh - 120px);
  min-height: 520px;
  border-radius: var(--aofbd-radius-md);
  overflow: hidden;
  border: 1px solid var(--aofbd-border);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

.aofbd-archive-map-container,
.aofbd-archive-map {
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

/* ── Leaflet Custom Brand Pin ── */
.aofbd-pin-marker {
  width: 28px;
  height: 38px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 38'%3E%3Cpath fill='%23b91c1c' stroke='%23ffffff' stroke-width='1.5' d='M14 0C6.27 0 0 6.27 0 14c0 10.5 14 24 14 24s14-13.5 14-24c0-7.73-6.27-14-14-14z'/%3E%3Ccircle cx='14' cy='14' r='5' fill='%23ffffff'/%3E%3C/svg%3E") no-repeat center center;
  background-size: contain;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}

.aofbd-pin-marker:hover,
.aofbd-custom-pin.is-hovered .aofbd-pin-marker {
  transform: scale(1.22) translateY(-4px);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35));
}

/* ── Leaflet Popup Card ── */
.aofbd-leaflet-popup .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}

.aofbd-leaflet-popup .leaflet-popup-content {
  margin: 0;
  width: 260px !important;
  font-family: var(--aofbd-font-sans);
}

.aofbd-map-popup__img {
  width: 100%;
  height: 120px;
  background: #f1f5f9;
  overflow: hidden;
}

.aofbd-map-popup__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.aofbd-map-popup__body {
  padding: 0.875rem;
}

.aofbd-map-popup__cat {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--aofbd-primary);
  margin-bottom: 0.25rem;
}

.aofbd-map-popup__title {
  margin: 0 0 0.375rem 0;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
}

.aofbd-map-popup__title a {
  color: var(--aofbd-text-main);
  text-decoration: none;
}

.aofbd-map-popup__title a:hover {
  color: var(--aofbd-primary);
}

.aofbd-map-popup__rating {
  font-size: 0.8125rem;
  color: var(--aofbd-text-muted);
  margin-bottom: 0.375rem;
}

.aofbd-map-popup__rating .aofbd-star {
  color: #f59e0b;
}

.aofbd-map-popup__addr,
.aofbd-map-popup__phone {
  font-size: 0.75rem;
  color: var(--aofbd-text-muted);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aofbd-map-popup__footer {
  margin-top: 0.625rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--aofbd-border);
}

.aofbd-map-popup__link {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--aofbd-primary);
  text-decoration: none;
}

.aofbd-map-popup__link:hover {
  text-decoration: underline;
}

/* ── Card Highlight on Marker Click ── */
.aofbd-card.is-highlighted-card {
  outline: 3px solid var(--aofbd-primary);
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.2);
  transform: translateY(-2px);
}

/* ── Mobile Map Floating Toggle Pill ── */
.aofbd-mobile-map-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  background: #0d1b2a;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  white-space: nowrap;
}

/* ── Responsive Adaptations ── */
@media (max-width: 1024px) {
  .aofbd-archive-layout {
    grid-template-columns: 1fr;
  }

  .aofbd-archive-map-sidebar {
    display: none;
  }

  .aofbd-archive-layout.is-mobile-map-active .aofbd-archive-content {
    display: none;
  }

  .aofbd-archive-layout.is-mobile-map-active .aofbd-archive-map-sidebar {
    display: block;
    position: fixed;
    inset: 0;
    top: 60px;
    height: calc(100vh - 60px);
    z-index: 990;
    border-radius: 0;
  }

  .aofbd-mobile-map-toggle {
    display: inline-flex;
    align-items: center;
  }

  #aofbd-toggle-map-btn {
    display: none;
  }
}

@media (max-width: 768px) {
  .aofbd-filter-drawer__grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}
