:root {
  --brand-green: #e3f98a; /* Search button — change to your brand color */
  --pin-teal: #a9eadf;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  /* 1% of the real device viewport height (a px value), set by JS — from the
     parent page when embedded, or from our own viewport otherwise. The fixed
     px fallback (≈700px tall) avoids any iframe-relative vh feedback loop. */
  --dvh: 7px;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
}

/* ---- Layout: panel + map ------------------------------------------------ */

#app {
  display: flex;
  flex-direction: row; /* desktop: panel left, map right */
  gap: 22px; /* space between panel and map (desktop) */
  height: 600px; /* desktop section height */
  width: 100%;
}

#panel {
  flex: 0 0 360px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 0; /* allow inner scroll */
}

/* Rounded, shadowed card wrapping the search + results (footer stays outside). */
.panel-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin: 16px;
  padding: 16px 20px; /* controls inset of search, count and list */
  background: #fff;
  border-radius: 40px;
  box-shadow: 0 6px 28px rgba(17, 24, 39, 0.1);
}

#map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 56px; /* desktop */
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: #e8eef2;
}

/* Mobile: map on top, panel underneath */
@media (max-width: 720px) {
  #app {
    flex-direction: column;
    gap: 0; /* no vertical gap on mobile (map stacks above panel) */
    height: auto;
  }
  #map-wrap {
    order: 0;
    flex: 0 0 auto;
    height: calc(var(--dvh) * 80);
    min-height: 400px;
    border-radius: 34px; /* mobile */
  }
  #panel {
    order: 1;
    flex: 0 0 auto;
    height: auto; /* size to content so the iframe fits (no empty space) */
    min-height: 0;
    max-width: none;
    border-right: none;
  }
  /* Fixed-height scrollable list on mobile (when showing results). */
  .store-list {
    flex: 0 0 auto;
    height: 640px;
    overflow-y: auto;
  }
  /* Before searching it only shows a prompt — collapse so there's no tall
     empty area. */
  .store-list.is-prompt {
    height: auto;
    overflow: visible;
  }
  /* Card sizes to content on mobile so the iframe fits snugly. */
  .panel-card {
    flex: 0 0 auto;
  }
}

/* ---- Search ------------------------------------------------------------- */

.panel-search {
  padding: 0 0 8px; /* horizontal inset comes from .panel-card */
}

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.near-label {
  font-size: 18px;
  font-weight: 600;
}

.search-input {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px;
  background: #fff;
}

.search-input input {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 16px;
  padding: 10px 6px;
  background: transparent;
  min-width: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.icon-btn:hover {
  color: var(--ink);
}

.search-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border: 0;
  border-radius: 999px;
  background: var(--brand-green);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.search-btn:hover {
  filter: brightness(0.96);
}

/* ---- Results ------------------------------------------------------------ */

.result-count {
  padding: 8px 2px;
  font-size: 15px;
  color: var(--muted);
}

.store-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
}

.store-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 6px;
  align-items: start;
  padding: 14px 8px;
  border: 1px solid #eef0f2;
  border-radius: 16px;
  margin: 10px 0;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.05);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.store-item:hover,
.store-item.active {
  border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

/* Numbered teardrop pin */
.pin {
  width: 26px;
  height: 26px;
  margin-top: 4px;
  background: var(--pin-teal);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pin span {
  transform: rotate(45deg);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.store-name {
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.15;
  margin: 0 0 4px;
}
.store-addr,
.store-phone {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.35;
}
.store-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
  font-size: 14px;
}
.store-products {
  color: var(--ink);
  font-weight: 600;
}
.store-distance {
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
}

.panel-footer {
  text-align: center;
  padding: 16px 12px;
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.list-empty {
  padding: 18px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

/* ---- Map overlays ------------------------------------------------------- */

.status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  text-align: center;
  color: #46555f;
  font-family: var(--font);
  background: rgba(238, 238, 238, 0.9);
}
.status[hidden] {
  display: none;
}

/* Hide the bottom-right attribution control */
.leaflet-bottom.leaflet-right {
  display: none;
}

.locate-control a {
  font-size: 18px;
  line-height: 26px;
  text-align: center;
  color: #1a73e8;
  cursor: pointer;
}
.locate-control a:hover {
  background: #f4f4f4;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 1200;
  max-width: 90%;
  padding: 8px 14px;
  border-radius: 6px;
  background: rgba(33, 33, 33, 0.9);
  color: #fff;
  font: 13px var(--font);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.toast[hidden] {
  display: none;
}

/* ---- Popups ------------------------------------------------------------- */

.store-popup {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  max-width: 240px;
}
.store-popup h3 {
  margin: 0 0 2px;
  font-size: 14px;
}
.store-popup .franchise {
  color: #888;
  font-size: 12px;
  margin-bottom: 4px;
}
.store-popup .addr {
  color: #555;
}
.store-popup a {
  color: #1a73e8;
  text-decoration: none;
}
.store-popup a:hover {
  text-decoration: underline;
}
.store-popup .directions {
  display: inline-block;
  margin-top: 8px;
  font-weight: 600;
}
