/* جیم‌اینفو — نقشهٔ باشگاه‌ها و انتخابگر موقعیت */

/* ---------- نقشهٔ عمومی ---------- */
.map-section {
  padding: 6px 0 30px;
  scroll-margin-top: calc(var(--header-h) + 14px);
}
.map-shell {
  position: relative;
  z-index: 0;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  padding: 14px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px 12px;
}
.map-toolbar__text { display: flex; flex-direction: column; gap: 3px; }
.map-toolbar strong { font-size: .96rem; font-weight: 800; }
.map-hint { font-size: .78rem; color: var(--ink-2); line-height: 1.8; }
.map-count { color: var(--ink); font-weight: 600; }
.map-close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink-2);
  font-size: .8rem;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.map-close:hover { color: var(--ink); border-color: var(--ink-2); background: var(--surface-2); }

.gym-map,
.gym-map-picker__canvas {
  direction: ltr;
  width: 100%;
  height: 440px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #e9e9ee;
  position: relative;
}
.gym-map--detail { height: 230px; margin-bottom: 12px; }
.map-route { width: 100%; justify-content: center; }

.map-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: .86rem;
  color: var(--ink-2);
  z-index: 500;
}
.map-empty {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 600;
  max-width: 86%;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-soft);
  font-size: .78rem;
  color: var(--ink-2);
  text-align: center;
}
.map-empty--error { color: #ffb4b4; border-color: rgba(248, 113, 113, .4); }

/* نشانگر باشگاه */
.gym-pin { background: none; border: 0; }
.gym-pin svg { display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); transition: transform .16s ease; }
.gym-pin:hover svg { transform: translateY(-2px) scale(1.05); }

/* موقعیت کاربر */
.user-pin { background: none; border: 0; }
.user-dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2f81f7;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(47, 129, 247, .28);
}

/* پاپ‌آپ */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
}
.leaflet-popup-content { margin: 12px 14px; font: inherit; }
.leaflet-popup-tip { background: var(--surface); border: 1px solid var(--glass-border); }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-2); }
.leaflet-container { font-family: inherit; }

.map-popup {
  display: grid;
  gap: 3px;
  min-width: 168px;
  direction: rtl;
  text-align: right;
  line-height: 1.7;
}
.map-popup__name { font-size: .92rem; font-weight: 800; color: var(--ink); }
.map-popup__meta { font-size: .76rem; color: var(--ink-2); }
.map-popup__distance { font-size: .76rem; font-weight: 700; color: var(--accent-deep); }
.map-popup__price { font-size: .82rem; font-weight: 800; color: var(--ink); }
.map-popup__link { font-size: .8rem; font-weight: 700; color: #0071e3; margin-top: 2px; }
[data-theme="dark"] .map-popup__link { color: #6cb8ff; }

/* کاشی‌ها و کنترل‌ها در حالت تاریک */
[data-theme="dark"] .leaflet-tile-pane,
html.dark .leaflet-tile-pane {
  filter: brightness(.66) invert(1) contrast(1.05) hue-rotate(180deg) saturate(.55);
}
[data-theme="dark"] .leaflet-container,
html.dark .leaflet-container { background: #101014; }
[data-theme="dark"] .leaflet-control-zoom a,
html.dark .leaflet-control-zoom a {
  background: #1b1b21;
  color: #f5f5f7;
  border-color: rgba(255, 255, 255, .14);
}
[data-theme="dark"] .leaflet-control-zoom a:hover,
html.dark .leaflet-control-zoom a:hover { background: #26262e; }
[data-theme="dark"] .leaflet-control-attribution,
html.dark .leaflet-control-attribution {
  background: rgba(10, 10, 12, .72);
  color: #9d9da4;
}
[data-theme="dark"] .leaflet-control-attribution a { color: #b9c7d8; }
[data-theme="dark"] .leaflet-popup-tip,
[data-theme="dark"] .leaflet-popup-content-wrapper { border-color: rgba(255, 255, 255, .12); }

/* برچسب فاصله روی کارت باشگاه */
.chip--distance {
  background: rgba(255, 204, 0, .18);
  border-color: rgba(255, 204, 0, .5);
  color: var(--ink);
  font-weight: 700;
}
[data-theme="dark"] .chip--distance {
  background: rgba(255, 204, 0, .16);
  border-color: rgba(255, 204, 0, .45);
  color: #ffe27a;
}

/* دکمه‌های موقعیت در صفحه فهرست */
.directory-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 20px;
}
.directory-tools .directory-search { margin-top: 0; flex: 1 1 420px; }
.directory-geo { white-space: nowrap; }
.directory-geo svg { margin-left: 4px; }
.directory-geo.is-busy,
.filter-geo.is-busy { opacity: .6; pointer-events: none; }
.filter-geo { margin-top: 10px; width: 100%; justify-content: center; }
.results-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.results-actions .btn.is-active {
  background: rgba(255, 204, 0, .2);
  border-color: rgba(255, 204, 0, .55);
  color: var(--ink);
}
[data-theme="dark"] .results-actions .btn.is-active { color: #ffe27a; }

/* ---------- انتخابگر موقعیت در پنل ---------- */
.gym-map-picker {
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.gym-map-picker__canvas { height: 340px; border-radius: 0; }
.gym-map-picker__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  font-size: .78rem;
  color: #52525b;
  border-top: 1px solid rgba(0, 0, 0, .08);
}
.gym-map-picker__hint { line-height: 1.8; }
.gym-map-picker__coords {
  display: inline-block;
  margin-inline-start: 4px;
  font-weight: 700;
  color: #b45309;
  direction: ltr;
}
.dark .gym-map-picker__coords { color: #fbbf24; }
.gym-map-picker__btn {
  flex: 0 0 auto;
  border-radius: 9px;
  padding: 6px 12px;
  border: 1px solid rgba(0, 0, 0, .16);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: .78rem;
  transition: background .16s ease, border-color .16s ease;
}
.gym-map-picker__btn:hover { background: rgba(255, 204, 0, .18); border-color: rgba(255, 204, 0, .55); }
.dark .gym-map-picker { background: #18181b; border-color: rgba(255, 255, 255, .14); }
.dark .gym-map-picker__bar { color: #a1a1aa; border-top-color: rgba(255, 255, 255, .1); }
.dark .gym-map-picker__btn { border-color: rgba(255, 255, 255, .18); }

/* ---------- دیالوگ انتخاب موقعیت (باشگاه‌های اطراف من) ---------- */
html.nearby-open,
html.nearby-open body { overflow: hidden; }

.nearby-dialog {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 18px;
}
.nearby-dialog[hidden] { display: none; }
.nearby-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 14, .55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.nearby-dialog__sheet {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .38);
  padding: 20px 20px 22px;
}
.nearby-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.nearby-dialog__title { font-size: 1.12rem; font-weight: 800; }
.nearby-dialog__sub { margin-top: 4px; font-size: .82rem; line-height: 1.8; color: var(--ink-2); }
.nearby-dialog__close {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink-2);
  font-size: .8rem;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.nearby-dialog__close:hover { color: var(--ink); border-color: var(--ink-2); background: var(--surface-2); }

.nearby-status {
  margin: 0 0 14px;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.8;
  background: rgba(47, 129, 247, .12);
  border: 1px solid rgba(47, 129, 247, .3);
  color: var(--ink);
}
.nearby-status[data-type="error"] {
  background: rgba(248, 113, 113, .14);
  border-color: rgba(248, 113, 113, .38);
}
.nearby-status[data-type="ok"] {
  background: rgba(255, 204, 0, .16);
  border-color: rgba(255, 204, 0, .45);
}

.nearby-pane[hidden] { display: none; }

.nearby-options { display: grid; gap: 10px; }
.nearby-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: right;
  padding: 13px 14px;
  border-radius: 15px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.nearby-option:hover {
  border-color: rgba(255, 204, 0, .65);
  background: rgba(255, 204, 0, .12);
  transform: translateY(-1px);
}
.nearby-option[disabled] { opacity: .6; cursor: wait; transform: none; }
.nearby-option--primary {
  background: rgba(255, 204, 0, .18);
  border-color: rgba(255, 204, 0, .5);
}
.nearby-option__icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--accent-deep);
}
.nearby-option__text { display: grid; gap: 3px; }
.nearby-option__text strong { font-size: .9rem; font-weight: 800; }
.nearby-option__text small { font-size: .76rem; line-height: 1.75; color: var(--ink-2); }

.nearby-helpbox {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .32);
  line-height: 1.85;
}
.nearby-helpbox[hidden] { display: none; }
.nearby-helpbox__title { display: block; font-size: .86rem; font-weight: 800; margin-bottom: 4px; }
.nearby-helpbox__text { font-size: .78rem; color: var(--ink-2); }
.nearby-helpbox__list {
  margin: 6px 0 0;
  padding-inline-start: 18px;
  list-style: disc;
  font-size: .78rem;
  color: var(--ink-2);
}
.nearby-helpbox__list li { margin-top: 4px; }
.nearby-helpbox__list b { color: var(--ink); }
.nearby-helpbox__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.nearby-helpbox__actions .btn { flex: 1 1 140px; justify-content: center; }

.nearby-picker {
  direction: ltr;
  width: 100%;
  height: 320px;
  border-radius: 14px;
  overflow: hidden;
  background: #e9e9ee;
}
.nearby-help { margin-top: 10px; font-size: .78rem; line-height: 1.8; color: var(--ink-2); }
.nearby-help a { color: var(--accent-deep); font-weight: 700; }
.nearby-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.nearby-actions .btn { flex: 1 1 180px; justify-content: center; }
.nearby-actions .btn[disabled] { opacity: .55; pointer-events: none; }
.nearby-option:focus-visible,
.nearby-dialog__close:focus-visible,
.nearby-field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nearby-field { display: grid; gap: 6px; }
.nearby-field span { font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.nearby-field input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
}
.nearby-field input:focus {
  outline: none;
  border-color: rgba(255, 204, 0, .8);
  box-shadow: 0 0 0 3px rgba(255, 204, 0, .2);
}

@media (max-width: 560px) {
  .nearby-dialog { padding: 0; place-items: end stretch; }
  .nearby-dialog__sheet {
    width: 100%;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }
  .nearby-picker { height: 260px; }
  .nearby-actions .btn { flex-basis: 100%; }
}

@media (max-width: 900px) {
  .gym-map { height: 360px; }
  .gym-map--detail { height: 220px; }
  .map-toolbar { align-items: flex-start; }
}
@media (max-width: 640px) {
  .gym-map { height: 300px; }
  .directory-tools .directory-search { flex-basis: 100%; }
  .directory-geo { width: 100%; justify-content: center; }
  .results-actions { width: 100%; justify-content: space-between; }
}
