/*
 * BW Distributors - store locator
 *
 * This is the project's existing locator stylesheet, unchanged except for two
 * things:
 *   1. the fixed 600px heights became --dimex-list-height / --dimex-map-height
 *      custom properties (same 600px default) so the shortcode and the Map
 *      Settings screen can adjust them;
 *   2. a new block at the end for the search bar, the empty-result message and
 *      the hidden-item behaviour. Nothing above that block was restyled.
 *
 * The Figtree @import was dropped on purpose: the Bricks theme already loads
 * Figtree site-wide, and an @import inside an enqueued stylesheet is an extra
 * render-blocking request. If the locator ever renders in the fallback stack,
 * enqueue the webfont with the bw_distributors_font_url filter instead.
 *
 * ASCII only, deliberately - non-ASCII in this repo has been corrupted by
 * non-UTF-8 saves before.
 */

.dimex-store-locator,
.dimex-store-locator * {
  box-sizing: border-box;
  font-family: "Figtree", sans-serif;
}

.dimex-store-locator {
  display: flex;
  align-items: stretch;
  gap: 20px;
  width: 100%;
}

/*
 * Distributor list
 */
.dimex-store-list {
  position: relative;
  width: 320px;
  max-width: 100%;
  height: var(--dimex-list-height, 600px);
  overflow-y: auto;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.dimex-store-list-header {
  position: sticky;
  top: 0;
  z-index: 500;
  padding: 14px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  border-radius: 12px 12px 0 0;
}

.dimex-store-list-header h3 {
  margin: 0;
  color: #001a3a;
  font-size: 18px;
  font-weight: 600;
}

.dimex-store-items {
  padding: 8px;
}

.dimex-store-item {
  padding: 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 8px;
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease;
}

.dimex-store-item:last-child {
  border-bottom: 0;
}

.dimex-store-item:hover {
  background: #f8fafc;
}

.dimex-store-item:focus-visible {
  background: #f8fafc;
  box-shadow: inset 0 0 0 2px #001a3a;
  outline: none;
}

.dimex-store-item.active {
  background: #f1f5f9;
}

.dimex-store-country {
  margin: 0 0 4px;
  color: #001a3a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.4;
  text-transform: uppercase;
}

.dimex-store-name {
  margin: 0 0 6px;
  color: #2b2b2b;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.dimex-store-address {
  margin: 0 0 5px;
  color: #6b7280;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  white-space: pre-line;
}

.dimex-store-phone,
.dimex-store-email,
.dimex-store-website {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

.dimex-store-phone a,
.dimex-store-email a,
.dimex-store-website a {
  color: inherit;
  text-decoration: none;
}

.dimex-store-phone a:hover,
.dimex-store-email a:hover,
.dimex-store-website a:hover {
  color: #001a3a;
  text-decoration: underline;
}

/*
 * Leaflet map
 */
.dimex-store-map {
  flex: 1;
  min-width: 0;
  height: var(--dimex-map-height, 600px);
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

/*
 * Leaflet popups
 */
.dimex-store-locator .leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 15%);
}

.dimex-store-locator .leaflet-popup-content {
  min-width: 220px;
  margin: 14px 16px;
  color: #2b2b2b;
  font-family: "Figtree", sans-serif;
  line-height: 1.5;
}

.dimex-popup-country {
  margin: 0 0 4px;
  color: #001a3a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.dimex-popup-name {
  margin: 0 0 10px;
  color: #2b2b2b;
  font-size: 14px;
  font-weight: 600;
}

.dimex-popup-text {
  margin: 0 0 6px;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.5;
}

.dimex-popup-text:last-child {
  margin-bottom: 0;
}

.dimex-popup-text strong {
  color: #2b2b2b;
  font-weight: 600;
}

.dimex-popup-text a {
  color: #6b7280;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.dimex-popup-text a:hover {
  color: #001a3a;
  text-decoration: underline;
}

.dimex-popup-address {
  white-space: pre-line;
}

/*
 * Custom marker
 */
.dimex-store-locator .leaflet-marker-icon,
.dimex-custom-marker {
  background: transparent !important;
  border: 0 !important;
}

.dimex-marker-wrap {
  position: relative;
  width: 46px;
  height: 56px;
}

.dimex-marker-circle {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  overflow: hidden;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgb(0 0 0 / 18%);
}

.dimex-marker-circle img {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.dimex-marker-fallback {
  color: #001a3a;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.dimex-marker-pointer {
  position: absolute;
  bottom: 4px;
  left: 50%;
  z-index: 1;
  width: 13px;
  height: 13px;
  background: #ffffff;
  box-shadow: 0 4px 8px rgb(0 0 0 / 12%);
  transform: translateX(-50%) rotate(45deg);
}

/*
 * Empty-map notice
 */
.dimex-map-notice {
  margin-top: 12px;
  padding: 14px 16px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.dimex-store-locator--empty {
  display: block;
}

/*
 * Leaflet interface controls
 */
.dimex-store-locator .leaflet-control-zoom a {
  color: #2b2b2b;
  font-family: "Figtree", sans-serif;
}

.dimex-store-locator .leaflet-control-attribution,
.dimex-store-locator .leaflet-control-attribution a {
  color: #2b2b2b;
  font-family: "Figtree", sans-serif;
}

/* ==========================================================================
 * NEW: search bar
 *
 * Sits inside the existing sticky list header, so it stays visible while the
 * list scrolls. !important appears only on the input's visual properties:
 * Bricks styles bare form controls site-wide with high-specificity selectors,
 * and without it the field inherits the theme's input skin instead of matching
 * the locator.
 * ======================================================================== */

.dimex-store-search {
  position: relative;
  margin-top: 10px;
}

.dimex-store-locator .dimex-store-search-input {
  width: 100% !important;
  min-height: 0 !important;
  height: auto !important;
  margin: 0 !important;
  padding: 9px 32px 9px 34px !important;
  color: #2b2b2b !important;
  font-family: "Figtree", sans-serif !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  line-height: 1.4 !important;
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  appearance: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.dimex-store-locator .dimex-store-search-input::placeholder {
  color: #9ca3af;
  opacity: 1;
}

.dimex-store-locator .dimex-store-search-input:focus,
.dimex-store-locator .dimex-store-search-input:focus-visible {
  border-color: #001a3a !important;
  box-shadow: 0 0 0 3px rgb(0 26 58 / 8%) !important;
  outline: none !important;
}

/* The native search affordances duplicate our own clear button. */
.dimex-store-search-input::-webkit-search-cancel-button,
.dimex-store-search-input::-webkit-search-decoration {
  appearance: none;
  display: none;
}

.dimex-store-search-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  display: flex;
  color: #9ca3af;
  pointer-events: none;
  transform: translateY(-50%);
}

.dimex-store-locator .dimex-store-search-clear {
  position: absolute;
  top: 50%;
  right: 5px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  color: #6b7280;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transform: translateY(-50%);
}

.dimex-store-search.has-value .dimex-store-search-clear {
  display: flex;
}

.dimex-store-locator .dimex-store-search-clear:hover {
  color: #001a3a;
  background: #f1f5f9;
}

.dimex-store-locator .dimex-store-search-clear:focus-visible {
  outline: 2px solid #001a3a;
  outline-offset: 1px;
}

/*
 * Filtered-out cards. The [hidden] rule is explicit because Bricks sets a
 * display value on plain divs, which would otherwise beat the UA default.
 */
.dimex-store-locator [hidden] {
  display: none !important;
}

/*
 * :last-child cannot see that later cards are filtered out, so the JS tags the
 * last VISIBLE card and the divider is removed from that one instead.
 */
.dimex-store-item.dimex-last-visible {
  border-bottom: 0;
}

.dimex-store-empty {
  margin: 0;
  padding: 18px 22px 22px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
}

/* Result count: announced by screen readers, invisible on screen. */
.dimex-store-count {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  white-space: nowrap;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

/* WordPress' own utility class is not guaranteed to exist in a Bricks theme. */
.dimex-store-locator .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  white-space: nowrap;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

/*
 * Mobile
 */
@media (max-width: 767px) {
  .dimex-store-locator {
    flex-direction: column;
  }

  .dimex-store-list {
    width: 100%;
    height: var(--dimex-list-height-mobile, 280px);
  }

  .dimex-store-map {
    /*
     * `flex: 1` on the desktop rule means `flex-basis: 0%`. Once the container
     * becomes a COLUMN, flex-basis governs the vertical (main) axis and wins
     * over `height` - and because the wrapper has no definite height there is
     * no free space to grow into, so the map collapses to nothing but its
     * border. Resetting flex here is what makes the height below take effect.
     */
    flex: 0 0 auto;
    width: 100%;
    height: var(--dimex-map-height-mobile, 420px);
  }
}
