/* ========== Layout ========== */
.ffwf {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: var(--ffwf-height, 70vh); /* set by the shortcode "height" attribute */
  gap: 0;
  position: relative;
}

.ffwf__panel {
  background: #111;
  color: #eee;
  padding: 14px;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-flow: column;
}

.ffwf__map {
  background: #222;
}

/* ========== Inputs & Controls ========== */
.ffwf__label {
  font-size: 0.85rem;
  color: #ccc;
  margin-bottom: 4px;
  display: block;
}

.ffwf__row {
  display: flex;
  flex-flow: row wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

/* Pinned above the product options while they scroll, so it needs an opaque background and its own layer. */
.ffwf__row-search {
  position: sticky;
  top: 0;
  z-index: 1;
  margin-bottom: 0;
  padding-bottom: 6px;
  background: #111;
}

.ffwf__row-search input {
  height: 26px !important;
}

.ffwf__input,
.ffwf__select {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #1b1b1b;
  color: #fff;
}

.ffwf__input {
  flex: 1;
}

/* Google's suggestion list background follows the page color scheme. In light
   mode that background is white, while the text inherits the white color above. */
#ffwf-address-pac {
  color-scheme: dark;
}

.ffwf__btn {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #444;
  background: #222;
  color: #eee;
  cursor: pointer;
}

.ffwf__btn:hover {
  background: #2a2a2a;
}

.ffwf__btn--primary {
  background: #345;
  border-color: #456;
}

.ffwf__btn--small {
  padding: 6px 8px;
  font-size: 0.85rem;
}

/* ========== Filters ========== */
.ffwf__filters summary {
  cursor: pointer;
  margin: 6px 0;
  padding: 0.5rem 0;
  font-weight: 600;
  list-style: none;
}

.ffwf__filters[open] summary {
  border-bottom: 1px solid #eee;
  margin-bottom: 0.5rem;
}

.ffwf__brands {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow: auto;
  padding-right: 6px;
}

.ffwf__brand {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid #2a2a2a;
  padding: 8px;
  border-radius: 8px;
}

.ffwf__brand-title {
  flex-basis: 100%;
  font-weight: 600;
  margin-bottom: 2px;
  color: #ddd;
}

.ffwf__chk {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
  font-size: 0.93rem;
  cursor: pointer;
}

.ffwf__filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 8px;
}

/* ========== Results ========== */
.ffwf__results {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 auto;
  overflow-y: auto;

  @media only all and (max-width: 59.938rem) {
    max-height: 60vh;
  }
}

.ffwf__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto; /* scroll the cards, not the pager, when a page runs slightly over */
}

/* ========== Results & product filter scrollbars ========== */
/* Colors are set in Settings → Map Appearance (printed as CSS variables on .ffwf). */
/* Transparent borders + padding-box clipping leave a 4px gap from the cards and inset the thumb in the rail. */
.ffwf__results::-webkit-scrollbar,
.ffwf__list::-webkit-scrollbar,
.ffwf__brands::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.ffwf__results::-webkit-scrollbar-track,
.ffwf__list::-webkit-scrollbar-track,
.ffwf__brands::-webkit-scrollbar-track {
  background: var(--ffwf-scrollbar-track, #1a1a1a);
  background-clip: padding-box;
  border-left: 4px solid transparent;
}

.ffwf__results::-webkit-scrollbar-thumb,
.ffwf__list::-webkit-scrollbar-thumb,
.ffwf__brands::-webkit-scrollbar-thumb {
  background: var(--ffwf-scrollbar-thumb, #a48254);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-left-width: 6px;
}

.ffwf__results::-webkit-scrollbar-thumb:hover,
.ffwf__results::-webkit-scrollbar-thumb:active,
.ffwf__list::-webkit-scrollbar-thumb:hover,
.ffwf__list::-webkit-scrollbar-thumb:active,
.ffwf__brands::-webkit-scrollbar-thumb:hover,
.ffwf__brands::-webkit-scrollbar-thumb:active {
  background-color: var(--ffwf-scrollbar-thumb-hover, #cb9e61);
}

.ffwf__results::-webkit-scrollbar-corner,
.ffwf__list::-webkit-scrollbar-corner,
.ffwf__brands::-webkit-scrollbar-corner {
  background: transparent;
}

/* Chromium ignores ::-webkit-scrollbar once these are set, so only Firefox gets them. */
@supports not selector(::-webkit-scrollbar) {
  .ffwf__results,
  .ffwf__list,
  .ffwf__brands {
    scrollbar-width: thin;
    scrollbar-color: var(--ffwf-scrollbar-thumb, #a48254) var(--ffwf-scrollbar-track, #1a1a1a);
  }
}

.ffwf__card {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  padding: 10px;
}

.ffwf__card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.ffwf__card-title {
  font-weight: 700;
  color: #fff;
}

.ffwf__dist {
  font-size: 0.9rem;
  color: #9ad;
  white-space: nowrap;
}

.ffwf__addr {
  color: #bbb;
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.ffwf__actions {
  display: flex;
  gap: 8px;
}

.ffwf__prods {
  margin-top: 8px;
  border-top: 1px dashed #333;
  padding-top: 8px;
}

.ffwf__brand-group {
  margin: 6px 0;
}

.ffwf__prod-list {
  margin: 6px 0 0 0;
  padding-left: 18px;
}

.ffwf__size {
  color: #888;
}

.ffwf__empty {
  color: #aaa;
  font-style: italic;
}

/* ========== Option buttons (radio groups) ========== */
/* The radios stay in the DOM for keyboard and screen-reader use; their labels are the visible buttons. */
/* Selected colors are set in Settings → Map Appearance (printed as CSS variables on .ffwf). */

/* Distance / Type: <input id> + <label for> */
.ffwf__radios {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-basis: 100%;
}

.ffwf__radios > label {
  flex: 1 1 auto;
}

/* Product filters: <label class="ffwf__radio"><input><span> */
.ffwf__radio {
  position: relative;
  display: inline-flex;
}

.ffwf__radios > input[type="radio"],
.ffwf__radio > input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.ffwf__radios > label,
.ffwf__radio > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1px solid #333;
  border-radius: 999px;
  background: #1b1b1b;
  color: #ddd;
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ffwf__radios > label:hover,
.ffwf__radio:hover > span {
  background: #262626;
  border-color: #555;
  color: #fff;
}

.ffwf__radios > input:checked + label,
.ffwf__radio > input:checked + span {
  background: var(--ffwf-option-selected-bg, #cb9e61);
  border-color: var(--ffwf-option-selected-bg, #cb9e61);
  color: var(--ffwf-option-selected-text, #111111);
  font-weight: 600;
}

.ffwf__radios > input:focus-visible + label,
.ffwf__radio > input:focus-visible + span {
  outline: 2px solid var(--ffwf-option-selected-bg, #cb9e61);
  outline-offset: 2px;
}

/* ========== Responsive ========== */
@media only all and (max-width: 59.938rem) {
  .ffwf {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    height: auto;
  }

  .ffwf__panel {
    order: 2;
    max-height: none;
  }

  .ffwf__map {
    order: 1;
    height: 50vh;
  }

  /* Mobile layout & toggle */
  .ffwf__row {
    display: block;
  }

  .ffwf__row--toggle {
    margin: 0.25rem 0 0.5rem;
  }

  .ffwf__tabs {
    display: inline-flex;
    gap: 0.5rem;
  }

  .ffwf__tab {
    padding: 0.4rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
  }

  .ffwf__tab--active {
    background: #000;
    color: #fff;
    border-color: #fff;
  }

  /* LIST mode: hide map; panel shows all rows in order */
  .ffwf.ffwf--mobile-list .ffwf__map {
    display: none;
  }

  .ffwf.ffwf--mobile-list .ffwf__panel {
    display: block;
  }

  .ffwf.ffwf--mobile-list .ffwf__results {
    margin-top: 10px;
  }

  /* MAP mode: show panel + map, with map sized nicely */
  .ffwf.ffwf--mobile-map .ffwf__panel {
    display: block;
  }

  .ffwf.ffwf--mobile-map .ffwf__results {
    display: none;
  }

  .ffwf.ffwf--mobile-map .ffwf__map--mobile {
    display: block;
    width: 100%;
    height: 56vh;
    margin: 0 0 0.5rem;
  }
}

.ffwf__loader {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.6); z-index: 99999;
}
.ffwf.ffwf--loading .ffwf__loader { display: flex; }

.ffwf__spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.2); border-top-color: #111;
  animation: ffwf-spin 0.8s linear infinite; margin-right: 8px;
}
.ffwf__loading-text { font-size: 14px; color: #111; }

@keyframes ffwf-spin { to { transform: rotate(360deg); } }

.ffwf__pager { flex: none; }
.ffwf__pager .ffwf__btn--text { background: transparent; border: none; padding: .25rem .5rem; }
.ffwf__pager .ffwf__btn--text[disabled] { opacity: .5; pointer-events: none; }
.ffwf__pageinfo { font-size: 0.9rem; opacity: .8; }