/* ─────────────────────────────────────────────
   RESET & CSS VARIABLES
───────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #1a73e8;
  --blue-l:  #e8f0fe;
  --blue-d:  #1557b0;
  --blue-m:  rgba(26,115,232,.12);
  --red:     #ea4335;
  --red-l:   #fce8e6;
  --green:   #34a853;
  --green-l: #e6f4ea;
  --yellow:  #f9ab00;
  --yellow-l:#fef7e0;
  --purple:  #a142f4;
  --orange:  #fa7b17;
  --t1: #202124;
  --t2: #5f6368;
  --t3: #80868b;
  --t4: #bdc1c6;
  --border:  #dadce0;
  --surf:    #f8f9fa;
  --white:   #fff;
  --sh0: 0 1px 2px rgba(0,0,0,.10);
  --sh1: 0 1px 4px rgba(0,0,0,.14), 0 1px 2px rgba(0,0,0,.08);
  --sh2: 0 4px 14px rgba(0,0,0,.14), 0 2px 4px rgba(0,0,0,.08);
  --r4:  4px;
  --r8:  8px;
  --r12: 12px;
  --r16: 16px;
  --r24: 24px;
  --cat1: #1a73e8;
  --cat2: #ea4335;
  --cat3: #34a853;
  --cat4: #fa7b17;
  --cat5: #a142f4;
}

body {
  font-family: 'Roboto', sans-serif;
  background: #f1f3f4;
  color: var(--t1);
  height: 100vh;     /* fallback */
  height: 100dvh;    /* mobile: excludes browser chrome */
  display: flex;
  overflow: hidden;
}

/* ─────────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────────── */
#sidebar {
  width: 400px;
  min-width: 400px;
  background: var(--white);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--sh2);
  z-index: 10;
}

/* ── Header ── */
#hdr {
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}

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

.logo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.lg-dot { width: 6.5px; height: 6.5px; border-radius: 50%; }

.logo-name { font-size: 18px; font-weight: 400; color: var(--t1); letter-spacing: -.3px; }
.logo-name span { color: var(--blue); font-weight: 500; }

.api-access-btn {
  display: flex;
  align-items: center;
  padding: 5px 12px;
  background: var(--blue-l);
  color: var(--blue);
  border: 1.5px solid rgba(26,115,232,.3);
  border-radius: var(--r8);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-decoration: none;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.api-access-btn:hover {
  background: #d2e3fc;
  border-color: var(--blue);
  text-decoration: none;
}
  display: flex;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}
.lang-btn {
  padding: 3px 11px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: var(--t2);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.6;
}
.lang-btn.on {
  background: var(--white);
  color: var(--blue);
  box-shadow: var(--sh0);
}

/* ── Scrollable body ── */
#sb-body { flex: 1; overflow-y: auto; }
#sb-body::-webkit-scrollbar { width: 4px; }
#sb-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Panel (section wrapper) ── */
.panel { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.panel:last-child { border-bottom: none; }

.panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .9px;
}
.panel-title svg { opacity: .7; }
.panel-hint { font-size: 11px; color: var(--t3); }

/* ─────────────────────────────────────────────
   LOCATION SECTION
───────────────────────────────────────────── */
.loc-btn-row { display: flex; gap: 8px; margin-bottom: 10px; }

.lac-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r12);
  background: var(--white);
  cursor: pointer;
  transition: all .18s;
  font-family: 'Roboto', sans-serif;
  text-align: left;
}
.lac-btn:hover { border-color: #bbb; box-shadow: var(--sh0); }
.lac-btn.on.locate  { border-color: var(--blue);   background: var(--blue-l); }
.lac-btn.on.pin-b   { border-color: var(--yellow);  background: var(--yellow-l); animation: ppulse 1.2s ease infinite; }

@keyframes ppulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(249,171,0,.25); }
  50%       { box-shadow: 0 0 0 8px rgba(249,171,0,.0);  }
}

.lac-ico { font-size: 18px; line-height: 1; flex-shrink: 0; width: 22px; text-align: center; }
.lac-txt strong { font-size: 13px; font-weight: 500; color: var(--t1); display: block; line-height: 1.35; }
.lac-txt small  { font-size: 11px; color: var(--t3); }

.loc-field {
  display: flex;
  align-items: center;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r12);
  padding: 10px 12px;
  gap: 8px;
  transition: all .18s;
  margin-top: 0;
}
.loc-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,.18);
}

.loc-field-ico { color: var(--t3); font-size: 16px; line-height: 1; flex-shrink: 0; }

.loc-go {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.loc-go:hover { opacity: .75; }

/* PlaceAutocompleteElement — strip its default chrome so it sits flush */
#autocomplete-container gmp-place-autocomplete,
#autocomplete-container input {
  width: 100% !important;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  font-family: 'Roboto', sans-serif !important;
  font-size: 14px !important;
  color: var(--t1) !important;
  box-shadow: none !important;
  padding: 4px 0 !important;
}
gmp-place-autocomplete {
  --gmp-input-border-radius: 0;
  --gmp-input-border: none;
  --gmp-input-box-shadow: none;
  --gmp-input-background: transparent;
  --gmp-input-padding: 0;
  width: 100%;
}

.loc-note { font-size: 11px; color: var(--t3); margin-top: 8px; line-height: 1.5; }

/* ─────────────────────────────────────────────
   SEARCH TARGETS
───────────────────────────────────────────── */
.targets-list { display: flex; flex-direction: column; gap: 8px; }

.tgt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r12);
  background: var(--surf);
  transition: border-color .15s, background .15s;
}
.tgt-row:hover { border-color: #c0c0c0; background: var(--white); }

.tgt-color { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(0,0,0,.08); }

.tgt-type-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  flex-shrink: 0;
  white-space: nowrap;
}
.badge-cat   { background: var(--blue-l);   color: var(--blue); }
.badge-brand { background: var(--yellow-l); color: #b06000; }

.tgt-sel {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  color: var(--t1);
  outline: none;
  cursor: pointer;
  min-width: 0;
}
.tgt-sel option { background: white; }

.tgt-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  color: var(--t1);
  outline: none;
  min-width: 0;
}
.tgt-input::placeholder { color: var(--t3); font-style: italic; }

.tgt-rm {
  background: none;
  border: none;
  color: var(--t4);
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
  transition: all .15s;
}
.tgt-rm:hover { background: var(--red-l); color: var(--red); }

.add-row { display: flex; gap: 8px; margin-top: 10px; }

.add-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: var(--r8);
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.add-cat-btn   { border: 1.5px solid rgba(26,115,232,.35);  background: var(--blue-l);   color: var(--blue);  border-radius: var(--r12); }
.add-cat-btn:hover   { background: #d2e3fc; border-color: var(--blue); }
.add-brand-btn { border: 1.5px solid rgba(52,168,83,.35);   background: #e6f4ea;         color: #1e7e34;      border-radius: var(--r12); }
.add-brand-btn:hover { background: #ceead6; border-color: #34a853; }

/* ─────────────────────────────────────────────
   RADIUS
───────────────────────────────────────────── */
.radius-controls { display: flex; align-items: center; gap: 10px; }

.r-inputs { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.r-num {
  width: 68px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r4);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--blue);
  text-align: center;
  outline: none;
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.r-num:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-m); }

.r-unit {
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r4);
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  color: var(--t2);
  background: var(--surf);
  outline: none;
  cursor: pointer;
}

input[type=range].r-sl {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type=range].r-sl::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  box-shadow: 0 0 0 4px var(--blue-m), 0 1px 3px rgba(0,0,0,.2);
}

.r-marks { display: flex; justify-content: space-between; font-size: 10px; color: var(--t3); margin-top: 5px; }

/* ─────────────────────────────────────────────
   SEARCH BUTTON
───────────────────────────────────────────── */
.search-wrap { padding: 14px 20px; }

.search-btn {
  width: 100%;
  padding: 12px;
  background: var(--blue);
  border: none;
  border-radius: var(--r24);
  color: white;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  box-shadow: 0 1px 3px rgba(26,115,232,.35), 0 1px 2px rgba(26,115,232,.2);
  letter-spacing: .2px;
}
.search-btn:hover   { background: var(--blue-d); box-shadow: 0 2px 8px rgba(26,115,232,.45); }
.search-btn:active  { transform: scale(.98); }
.search-btn:disabled { background: #9aa0a6; box-shadow: none; cursor: not-allowed; transform: none !important; }

/* ─────────────────────────────────────────────
   RESULTS
───────────────────────────────────────────── */
#rp { display: none; flex-direction: column; }

.rp-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surf);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.rp-title { font-size: 13px; font-weight: 500; color: var(--t1); }

.ns-btn {
  padding: 5px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--red);
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.ns-btn:hover { background: var(--red-l); border-color: var(--red); }

.rs-section { padding: 12px 16px; border-bottom: 1px solid var(--border); }

.rs-hdr {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .8px;
}
.rs-bdg { font-size: 9px; padding: 2px 7px; border-radius: 10px; font-weight: 600; letter-spacing: .4px; }
.bdg-b  { background: var(--blue-l);  color: var(--blue);  }
.bdg-g  { background: var(--green-l); color: var(--green); }

/* Combo card */
.cc {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--r12);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .18s;
  box-shadow: var(--sh0);
}
.cc:last-child { margin-bottom: 0; }
.cc:hover      { box-shadow: var(--sh1); border-color: #bbb; }
.cc.act-b { border-color: var(--blue)   !important; box-shadow: 0 0 0 2px rgba(26,115,232,.2)  !important; }
.cc.act-g { border-color: var(--green)  !important; box-shadow: 0 0 0 2px rgba(52,168,83,.2)   !important; }
.cc.act-y { border-color: var(--yellow) !important; box-shadow: 0 0 0 2px rgba(249,171,0,.2)   !important; }

.cc-places { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }

.cc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  transition: background .12s;
  cursor: pointer;
}
.cc-row:hover { background: var(--surf); }

.cc-dot      { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cc-name     { font-size: 13px; color: var(--t1); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-type-tag { font-size: 9px; padding: 1px 5px; border-radius: 8px; flex-shrink: 0; font-weight: 500; text-transform: uppercase; letter-spacing: .3px; }
.tag-cat     { background: var(--blue-l);   color: var(--blue);  }
.tag-brand   { background: var(--yellow-l); color: #b06000; }
.cc-open     { font-size: 10px; flex-shrink: 0; }
.cc-rat      { font-size: 11px; color: #f5a623; flex-shrink: 0; }
.cc-dist     { font-size: 11px; color: var(--t3); flex-shrink: 0; }
.cc-view     {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  transition: background .12s;
}
.cc-view:hover { background: var(--blue-l); }

.cc-stats { display: flex; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }
.st { flex: 1; text-align: center; }
.st:not(:last-child) { border-right: 1px solid var(--border); }
.sv { font-size: 13px; font-weight: 500; color: var(--t1); }
.sl { font-size: 10px; color: var(--t3); margin-top: 1px; }

.oth-tog {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r8);
  color: var(--t2);
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .15s;
}
.oth-tog:hover { background: var(--surf); }
#oth-list { display: none; margin-top: 8px; }

/* ─────────────────────────────────────────────
   MAP
───────────────────────────────────────────── */
#mw { flex: 1; position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; display: none; }

#mph {
  width: 100%; height: 100%;
  background: #e8eaed;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
}
.ph-ico { font-size: 52px; opacity: .18; }
.ph-t   { font-size: 15px; color: var(--t2); }
.ph-s   { font-size: 13px; color: var(--t3); }

/* Info-window toggle — switch style */
#iw-toggle-btn {
  display: none;   /* shown by JS when results render */
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--t2);
  font-family: 'Roboto', sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
}
.iw-toggle-track {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--blue);
  flex-shrink: 0;
  transition: background .2s;
}
.iw-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 16px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .2s;
}
#iw-toggle-btn.off .iw-toggle-track { background: var(--border); }
#iw-toggle-btn.off .iw-toggle-thumb { left: 2px; }
.iw-toggle-label { user-select: none; }

/* ── Pulsing user location dot (replaces deprecated google.maps.Marker) ── */
.user-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4285F4;
  border: 3px solid white;
  box-shadow: 0 0 0 0 rgba(66,133,244,.5);
  animation: udot-pulse 2s ease-out infinite;
}
@keyframes udot-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(66,133,244,.5); }
  70%  { box-shadow: 0 0 0 14px rgba(66,133,244,0);  }
  100% { box-shadow: 0 0 0 0   rgba(66,133,244,0);   }
}
  bottom: 130px; right: 10px;
  z-index: 10;
  width: 40px; height: 40px;
  background: white;
  border: none; border-radius: 4px;
  display: none;
  align-items: center; justify-content: center;
  box-shadow: 0 1px 5px rgba(0,0,0,.3);
  cursor: pointer;
  transition: background .12s;
}
#loc-map-btn:hover { background: var(--surf); }


/* ─────────────────────────────────────────────
   TOAST  (Google Snackbar style)
───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 14px;
  z-index: 9999;
  animation: tIn .2s ease;
  box-shadow: var(--sh2);
  max-width: 360px;
  text-align: center;
  pointer-events: none;
  font-family: 'Roboto', sans-serif;
}
.toast.err { background: #b71c1c; }

@keyframes tIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0);   }
}

/* ─────────────────────────────────────────────
   MOBILE TOGGLE BUTTONS (hidden on desktop)
───────────────────────────────────────────── */
#mob-map-btn, #mob-panel-btn { display: none; }

/* ─────────────────────────────────────────────
   MOBILE LAYOUT  (≤ 767px)
───────────────────────────────────────────── */
@media (max-width: 767px) {

  /* Stack vertically; each view takes full screen */
  body {
    flex-direction: column;
  }

  /* ── Sidebar: full width, full height by default ── */
  #sidebar {
    width: 100%;
    min-width: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
  }

  /* ── Map: hidden by default; shown when data-mv="map" ── */
  #mw {
    display: none;
    flex: 1;
  }

  /* ── View switching via data attribute on body ── */
  body[data-mv="map"] #sidebar { display: none; }
  body[data-mv="map"] #mw     { display: flex; flex: 1; min-height: 0; }

  /* ── Mobile header tweaks ── */
  #hdr { height: 56px; padding: 0 16px; }

  /* ── Show mobile map/panel buttons ── */
  #mob-map-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    background: var(--surf);
    color: var(--blue);
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
  }
  #mob-map-btn:hover { background: var(--blue-l); }

  #mob-panel-btn {
    display: flex;
    position: absolute;
    top: 12px;
    left: 10px;
    z-index: 10;
    width: 40px;
    height: 40px;
    background: white;
    border: none;
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 5px rgba(0,0,0,.3);
    cursor: pointer;
    color: var(--t1);
    transition: background .12s;
  }
  #mob-panel-btn:hover { background: var(--surf); }

  /* ── Touch-friendly sizing ── */
  .lac-btn       { padding: 12px 10px; }
  .lac-txt strong { font-size: 13px; }
  .tgt-rm        { width: 36px; height: 36px; }
  .search-btn    { padding: 14px; font-size: 15px; }
  .cc-view       { width: 32px; height: 32px; font-size: 15px; }

  /* ── Panel padding reduction on small screens ── */
  .panel    { padding: 14px 16px; }
  .rs-section { padding: 10px 14px; }
  .search-wrap { padding: 12px 16px; }

  /* ── Slider thumb bigger for touch ── */
  input[type=range].r-sl::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  /* ── Toast: stay above mobile bottom bar ── */
  .toast { bottom: env(safe-area-inset-bottom, 16px); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }

  /* ── Map buttons: reposition clear of safe-area ── */
  #loc-map-btn   { bottom: calc(env(safe-area-inset-bottom, 0px) + 130px); }
}

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: sp .7s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }
