/* ============================================================================
   RetailRadar — store finder page styles.
   Sidebar (search, radius, group filter, results) beside a full-height map.

   One stylesheet drives both finders. The FMCG Üzletkereső and the builder-merchant
   Építőanyag-kereső differ only in accent colour, which the landing page already uses
   to tell the two verticals apart (cyan = FMCG, green = Építőanyag). Rather than fork
   the file, every accent is a token below and `.finder--bm` swaps the pair over — the
   primary and secondary colours simply trade places between the two pages.
   ============================================================================ */

.finder {
  padding: clamp(28px, 4vw, 48px) 0 60px;

  --finder-accent: var(--accent-blue);
  --finder-accent-rgb: 56, 189, 248;
  --finder-ink: #04121d;          /* text on a filled accent pill */
  --finder-badge: var(--accent-green);
  --finder-badge-rgb: 16, 185, 129;
}

.finder--bm {
  --finder-accent: var(--accent-green);
  --finder-accent-rgb: 16, 185, 129;
  --finder-ink: #03150f;
  --finder-badge: var(--accent-blue);
  --finder-badge-rgb: 56, 189, 248;
}
.finder__head { margin-bottom: 26px; }
.finder__head .display { margin-bottom: 10px; }

.finder__layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) 1fr;
  gap: 20px;
  align-items: start;
}

.finder__panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  /* The panel scrolls with a sticky top so the map stays in view on desktop
     while the operator works down a long result list. */
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
}

.finder__map {
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
}
#store-map {
  width: 100%;
  height: calc(100vh - var(--header-h) - 40px);
  min-height: 480px;
  background: var(--bg-elevated);
}

/* Site-wide components default to the FMCG cyan. On the builder-merchant page they
   would be the only cyan things on a green page, so pull them onto the accent too. */
.finder--bm .eyebrow { color: var(--finder-accent); }
.finder--bm .btn--primary {
  background: var(--finder-accent);
  color: var(--finder-ink);
  box-shadow: 0 6px 26px rgba(var(--finder-accent-rgb), 0.28);
}
.finder--bm .btn--primary:hover { box-shadow: 0 10px 32px rgba(var(--finder-accent-rgb), 0.42); }
.finder--bm .btn--ghost:hover { border-color: var(--finder-accent); color: var(--finder-accent); }

/* --- vertical switch -------------------------------------------------------- */

/* The two finders are separate pages with separate URLs (they target different
   searches), so this is a pair of links rather than a JS tab — but it should read
   as one control with two states. Each side keeps its vertical's colour even when
   inactive, which is the whole point: the colour tells you which market you are in. */
.finder-switch {
  display: inline-flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}
.finder-switch__opt {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 17px;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  transition: background 0.16s ease, color 0.16s ease;
}
.finder-switch__opt .tri { color: var(--accent-blue); }
.finder-switch__opt--bm .tri { color: var(--accent-green); }
.finder-switch__opt:hover { color: var(--text-main); }
.finder-switch__opt.is-active { background: var(--accent-blue); color: #04121d; }
.finder-switch__opt--bm.is-active { background: var(--accent-green); color: #03150f; }
.finder-switch__opt.is-active .tri { color: currentColor; }

@media (max-width: 560px) {
  .finder-switch { display: flex; width: 100%; }
  .finder-switch__opt { flex: 1; justify-content: center; padding: 9px 10px; font-size: 10.5px; letter-spacing: 0.05em; }
}

/* --- form controls --------------------------------------------------------- */

.field-label {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-family: var(--font-display);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 9px;
}

.search-form { display: flex; gap: 8px; margin-bottom: 12px; }
.search-input {
  flex: 1; min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  border-radius: 40px;
  padding: 11px 18px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
}
.search-input:focus {
  outline: none;
  border-color: var(--finder-accent);
  box-shadow: 0 0 0 3px rgba(var(--finder-accent-rgb), 0.15);
}
.search-input::placeholder { color: var(--text-dim); }

.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.presets__label { font-size: 11.5px; color: var(--text-dim); margin-right: 2px; }
.preset {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset:hover { border-color: var(--finder-accent); color: var(--finder-accent); }

.search-status {
  font-size: 12px; color: var(--text-dim);
  margin-top: 10px; line-height: 1.5;
  min-height: 18px;
}

.radius-badge {
  font-family: var(--font-display);
  background: rgba(var(--finder-accent-rgb), 0.12);
  border: 1px solid rgba(var(--finder-accent-rgb), 0.35);
  color: var(--finder-accent);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.range {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--finder-accent);
  border: 3px solid #0b1120;
  box-shadow: 0 0 10px rgba(var(--finder-accent-rgb), 0.7);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--finder-accent);
  border: 3px solid #0b1120;
  cursor: pointer;
}
.range-marks {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--text-dim);
  margin-top: 6px;
}

/* --- results --------------------------------------------------------------- */

.finder__results-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 24px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.count-badge {
  font-family: var(--font-display);
  font-size: 11.5px; font-weight: 700;
  color: var(--finder-badge);
  background: rgba(var(--finder-badge-rgb), 0.12);
  border: 1px solid rgba(var(--finder-badge-rgb), 0.3);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}

.chain-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--border-strong); color: var(--text-main); }
.chip.is-active { border-color: var(--finder-accent); color: var(--finder-accent); background: rgba(var(--finder-accent-rgb), 0.1); }
.chip__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip__count { opacity: 0.7; font-variant-numeric: tabular-nums; }

.store-list { display: flex; flex-direction: column; gap: 8px; }

.store-item {
  display: flex; gap: 0;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: border-color 0.15s ease, transform 0.15s ease;
  width: 100%;
}
.store-item:hover { border-color: var(--finder-accent); transform: translateX(2px); }
.store-item__bar { width: 3px; flex: none; }
.store-item__body { display: block; padding: 10px 13px; flex: 1; min-width: 0; }
.store-item__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.store-item__chain {
  font-family: var(--font-display);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.11em;
  color: var(--text-muted);
}
.store-item__dist { font-size: 11px; font-weight: 700; color: var(--finder-accent); font-variant-numeric: tabular-nums; }
.store-item__name { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-main); }
.store-item__addr { display: block; font-size: 11.5px; color: var(--text-dim); }
.store-item__area { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* The result card carries a website link on the builder-merchant page, and an <a>
   cannot legally nest inside a <button> — so the card is a div with an explicit
   role and key handler on both pages rather than two divergent markups. */
.store-item:focus-visible {
  outline: 2px solid var(--finder-accent);
  outline-offset: 2px;
}
.store-item__meta { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.store-item__link {
  display: inline-block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--finder-accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(var(--finder-accent-rgb), 0.35);
}
.store-item__link:hover { border-bottom-color: var(--finder-accent); }

.empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 22px 10px; line-height: 1.6; }

/* --- country-wide view ------------------------------------------------------ */

/* Builder merchants are an order of magnitude sparser than grocery stores — 905
   nationwide against 7,151 — so a radius search around a small town can return
   three results. This escape hatch drops the radius filter entirely. */
.radius-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.country-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.country-btn:hover { border-color: var(--finder-accent); color: var(--finder-accent); }
.country-btn.is-active {
  border-color: var(--finder-accent);
  color: var(--finder-accent);
  background: rgba(var(--finder-accent-rgb), 0.1);
}
/* In country mode the radius slider is inert; dim it rather than remove it so the
   control does not jump around when the mode is toggled. */
.finder__layout.is-country .range,
.finder__layout.is-country .range-marks,
.finder__layout.is-country .radius-badge { opacity: 0.35; pointer-events: none; }

.area-note {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim); line-height: 1.55;
}

/* --- leaflet overrides ----------------------------------------------------- */

.leaflet-container { background: var(--bg-elevated); font-family: var(--font-body); }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-control-layers, .leaflet-bar {
  border: 1px solid rgba(0, 0, 0, 0.2) !important;
  border-radius: 10px !important;
}

/* --- list pagination -------------------------------------------------------- */

.list-status {
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}
.load-more-wrap { display: flex; justify-content: center; margin-top: 10px; }
.load-more-wrap[hidden] { display: none; }

/* --- mobile map/list tabs --------------------------------------------------- */

/* Desktop keeps both panes side by side, so the toggle is mobile-only. */
.view-toggle { display: none; }

.view-toggle__btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 14px;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.view-toggle__btn.is-active { background: var(--finder-accent); color: var(--finder-ink); }
.view-toggle__count {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.view-toggle__btn:not(.is-active) .view-toggle__count { background: rgba(255, 255, 255, 0.08); }

@media (max-width: 900px) {
  .finder__layout { grid-template-columns: 1fr; }
  .finder__panel { position: static; max-height: none; padding: 16px; }
  #store-map { height: calc(100vh - 200px); min-height: 340px; }

  /* The page chrome above the map measured 664px on a 375px-wide screen — the
     map only began below the fold. These trim it back without removing anything. */
  .finder { padding-top: 18px; }
  .finder__head { margin-bottom: 14px; }
  .finder__head .display { margin-bottom: 6px; }
  .finder__head .eyebrow { margin-bottom: 10px; }
  .finder__head .lede { font-size: 13px; }
  .search-form { margin-bottom: 10px; }
  .search-status { margin-top: 8px; }
  .presets { gap: 5px; }
  .preset { padding: 4px 10px; font-size: 11.5px; }

  .view-toggle {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 14px;
  }

  /* One pane at a time. The search controls live in the panel, so in map mode
     the panel stays visible but its results collapse away — the user can still
     search and set the radius while looking at the map. */
  .finder__layout.show-map .store-list,
  .finder__layout.show-map .chain-chips,
  .finder__layout.show-map .list-status,
  .finder__layout.show-map .load-more-wrap,
  .finder__layout.show-map .finder__results-head,
  .finder__layout.show-map .area-note { display: none; }

  .finder__layout.show-list .finder__map { display: none; }
}
