:root{
  --bg: #0b1220;
  --panel: rgba(255,255,255,.90);
  --panel2: rgba(255,255,255,.82);
  --border: rgba(15,23,42,.10);
  --border2: rgba(255,255,255,.26);
  --text:#0f172a;
  --muted: rgba(15,23,42,.70);
  --shadow: 0 18px 55px rgba(0,0,0,.22);
  --shadow2: 0 10px 24px rgba(0,0,0,.14);
  --radius: 22px;
  --accent:#7c3aed;
  --accent2:#2563eb;
  --warn:#f59e0b;
  --chip: rgba(15,23,42,.06);
  --chipOn: rgba(124,58,237,.14);
  --ok:#16a34a;
}

html, body { height: 100%; margin: 0; font-family: "Cairo", system-ui, -apple-system, Segoe UI, Roboto, Arial; color: var(--text); }
#map { height: 100vh; width: 100vw; background: #0b1220; }
a { color: var(--accent2); text-decoration: none; }

.material-symbols-rounded{
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}


.leaflet-container { outline: none; }
.leaflet-control-zoom a { border-radius: 12px !important; overflow:hidden; }
.leaflet-popup-content-wrapper { border-radius: 18px; box-shadow: var(--shadow2); }
.leaflet-popup-content { margin: 10px 12px; }

.mapVignette{
  position: fixed; inset: 0; pointer-events:none; z-index: 10;
  background:
    radial-gradient(1200px 800px at 85% 18%, rgba(124,58,237,.14), transparent 55%),
    radial-gradient(900px 700px at 12% 88%, rgba(37,99,235,.10), transparent 55%),
    radial-gradient(1200px 1200px at 50% 50%, rgba(0,0,0,.08), transparent 60%);
}

/* =========================
   Map-first floating tools
========================= */
.mapTools{
  position: fixed;
  right: 16px;
  bottom: 18px;
  z-index: 1300;
  display:flex;
  gap: 10px;
  align-items:center;
}
.toolBtn{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 28px rgba(0,0,0,.18);
  cursor:pointer;
  font-weight: 900;
}
.toolBtn:active{ transform: scale(.98); }
.toolIco{ font-size: 18px; line-height: 1; display:grid; place-items:center; }
.toolLbl{ font-size: 13px; opacity:.85; }

/* Tooltip-like label: show text on hover (desktop) only */
@media (hover:hover){
  .toolLbl{ max-width: 0; overflow:hidden; opacity:0; transition: max-width .18s ease, opacity .18s ease; }
  .toolBtn:hover .toolLbl{ max-width: 120px; opacity:.90; }
}

/* Active tool button */
body[data-panel="filters"] #toolFilters,
body[data-panel="list"] #toolList,
body[data-panel="layers"] #toolLayers{
  border-color: rgba(124,58,237,.38);
  box-shadow: 0 18px 34px rgba(124,58,237,.18);
}

@media (max-width: 820px){
  .mapTools{
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 14px;
  }
  .toolBtn{ padding: 12px 12px; }
  .toolLbl{ display:none; }
}

.panel{
  position: fixed; top: 14px; right: 14px;
  width: clamp(360px, 34vw, 460px);
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(255,255,255,.86));
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1200;
  overflow: hidden;
  display:flex; flex-direction:column;
  min-height: 0;
  max-height: calc(100vh - 28px);
  transform: translateZ(0);
}

/* Panel visibility control (map-first) */
body.panelClosed .panel{ display:none; }
body.panelClosed .layersPanel{ display:none; }

/* Show only the relevant section depending on the selected tool */
body[data-panel="filters"] .panel{ display:flex; }
body[data-panel="filters"] .listWrap{ display:none; }

body[data-panel="list"] .panel{ display:flex; }
body[data-panel="layers"] .panel{ display:none; }

body[data-panel="list"] .filtersArea,
body[data-panel="list"] .sectionTitle{ display:none; }

/* =========================
   Layers popover
========================= */
.layersPanel{
  position: fixed;
  right: 16px;
  bottom: 76px;
  z-index: 1400;
  width: 260px;
  max-width: calc(100vw - 32px);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.22);
  padding: 10px;
  display:none;
}
body[data-panel="layers"] .layersPanel{ display:block; }
.layersHdr{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 4px 6px 10px 6px;
}
.layersFoot{ padding: 8px 6px 2px 6px; display:flex; justify-content:flex-end; }

@media (max-width: 820px){
  .layersPanel{
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 70px;
    width: min(320px, calc(100vw - 32px));
  }
}

.layersPanel{
  position: fixed;
  right: 16px;
  bottom: 78px;
  width: 280px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.22);
  backdrop-filter: blur(10px);
  padding: 10px;
  z-index: 1400;
  display:none;
}
body[data-panel="layers"] .layersPanel{ display:block; }
.layersHdr{ display:flex; justify-content:space-between; align-items:center; padding: 4px 6px 8px 6px; }
.layersFoot{ display:flex; justify-content:flex-end; padding-top: 10px; }

@media (max-width: 820px){
  .layersPanel{
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 72px;
    width: min(92vw, 340px);
  }
}

.header{
  padding: 12px 14px;
  display:flex; align-items:center; justify-content:space-between; gap: 10px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  background:
    radial-gradient(900px 220px at 100% 0%, rgba(124,58,237,.16), transparent 65%),
    radial-gradient(900px 220px at 0% 0%, rgba(37,99,235,.12), transparent 65%);
}

.brand{ direction: rtl; text-align:right; line-height: 1.05; }
.brand b{ font-size: 15px; font-weight: 900; letter-spacing: .2px; }
.brand span{ font-size: 12px; color: var(--muted); }

.hBtns{ display:flex; gap:8px; align-items:center; }
.pill{
  font-size: 12px; border: 1px solid rgba(0,0,0,.10);
  padding: 6px 10px; border-radius: 999px;
  background: rgba(255,255,255,.85);
}
.iconBtn{
  width: 40px; height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  cursor:pointer;
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(0,0,0,.10);
}
.iconBtn:active{ transform: scale(.98); }

.sectionTitle{
  display:flex; justify-content:space-between; align-items:center;
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,.35);
  border-bottom: 1px solid rgba(0,0,0,.06);
  background: rgba(255,255,255,.65);
}
.sectionTitle b{ font-size: 13px; font-weight: 900; }
.sectionTitle button{
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  border-radius: 12px;
  padding: 6px 10px;
  cursor:pointer;
  font-weight: 900;
}

.filtersArea .body{ padding: 12px 14px; direction: rtl; text-align:right; }

.grid2{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.control{ display:flex; flex-direction:column; gap: 6px; margin-bottom: 10px; }
label.small{ font-size: 12px; color: var(--muted); }

select, input{
  width: 100%;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  outline: none;
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
input{ direction: rtl; }
select{ direction: ltr; }

select:focus, input:focus{
  border-color: rgba(124,58,237,.35);
  box-shadow: 0 0 0 4px rgba(124,58,237,.12);
}

.chips{
  display:flex; gap: 8px; overflow-x: auto;
  padding-bottom: 6px; margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}
.chip{
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.08);
  background: var(--chip);
  cursor: pointer;
  font-size: 13px;
  user-select: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.chip:hover{ transform: translateY(-1px); box-shadow: 0 10px 18px rgba(0,0,0,.08); }
.chip.on{
  background: rgba(124,58,237,.22);
  border-color: rgba(124,58,237,.45);
  box-shadow: 0 10px 22px rgba(124,58,237,.18);
  font-weight: 900;
  position: relative;
}

/* Make selected tag state unmistakable (mobile + desktop) */
.chip.on::after{
  content: "✓";
  display: inline-block;
  margin-inline-start: 8px;
  font-weight: 900;
  opacity: .9;
}

.modeRow{ display:flex; gap: 10px; margin: 4px 0 10px 0; }
.modeRow button{
  flex:1;
  padding: 12px 10px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  cursor:pointer;
  font-weight: 900;
  transition: transform .12s ease, box-shadow .12s ease;
}
.modeRow button.active{
  border-color: rgba(124,58,237,.35);
  box-shadow: 0 12px 26px rgba(124,58,237,.12);
}
.modeRow button:active{ transform: scale(.99); }

.info{
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,.06);
  background: rgba(255,255,255,.88);
}
.info .micro{ font-weight: 900; }
.info .desc{ margin-top: 6px; color: var(--muted); font-size: 12px; }
.info .count{ margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend{ display:flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.dot{ width:10px; height:10px; border-radius:50%; display:inline-block; margin-left:6px; }

.listWrap{
  padding: 12px 14px 14px 14px;
  direction: rtl;
  background: rgba(255,255,255,.70);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display:flex; flex-direction:column;
}
.listHdr{ display:flex; justify-content:space-between; align-items:center; gap: 10px; margin-bottom: 8px; }
.listHdr b{ font-weight: 900; }

.listHdrRight{ display:flex; align-items:center; gap: 8px; }
.miniBtn{
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  border-radius: 999px;
  padding: 6px 10px;
  cursor:pointer;
  font-weight: 900;
  font-size: 12px;
  line-height: 1;
}
.miniBtn:active{ transform: scale(.98); }
.list{
  flex: 1; overflow:auto;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.92);
  padding: 8px;
}


.list::-webkit-scrollbar{ width: 10px; }
.list::-webkit-scrollbar-thumb{ background: rgba(15,23,42,.12); border-radius: 999px; border: 2px solid rgba(255,255,255,.8); }
.list::-webkit-scrollbar-track{ background: rgba(255,255,255,.55); border-radius: 999px; }

.card{
  padding: 10px 10px;
  border-radius: 16px;
  border: 1px solid transparent;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.card:hover{
  background: rgba(124,58,237,.08);
  border-color: rgba(0,0,0,.06);
  transform: translateY(-1px);
}
.card.active{
  background: rgba(124,58,237,.12);
  border-color: rgba(124,58,237,.25);
  box-shadow: 0 14px 28px rgba(0,0,0,.10);
}
.card .row{ display:flex; justify-content:space-between; gap: 10px; align-items:flex-start; }
.card .name{ font-weight: 900; }

.badges{ margin-top: 6px; display:flex; flex-wrap:wrap; gap: 6px; }
.badge{
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.95);
}
.badge.dark{ background: #111827; border-color: #111827; color: #fff; }
.badge.ok{ background: rgba(22,163,74,.10); border-color: rgba(22,163,74,.25); }

.fab{
  position: absolute; left: 14px; bottom: 14px;
  z-index: 1250;
  display:flex; flex-direction:column; gap: 10px;
}
.fabRow{ display:flex; gap: 10px; }
.fab button{
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 40px rgba(0,0,0,.16);
  cursor:pointer;
  font-weight: 900;
}
.fab button.on{
  background: #111827;
  color:#fff;
  border-color:#111827;
}

.mobileExploreBtn{
  display:none;
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 1400;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(17,24,39,.92);
  color:#fff;
  box-shadow: 0 18px 44px rgba(0,0,0,.22);
  padding: 12px 14px;
  font-weight: 900;
  cursor:pointer;
}

.sheetHandle{
  display:none;
  height: 24px;
  align-items:center;
  justify-content:center;
  gap: 8px;
  background: rgba(255,255,255,.75);
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.sheetPill{
  width: 56px; height: 6px;
  border-radius: 999px;
  background: rgba(15,23,42,.18);
}

/* Mobile-only UI is hidden by default (desktop/tablet gets the classic side panel) */
.mobileNav{ display:none; }
.mobileTabs{ display:none; }

/* Hide the mobile "close sheet" button on desktop so the header doesn't look odd */
.header .iconBtn[title="Close on mobile"]{ display:none; }

body.filtersCollapsed .filtersArea{ display:none; }



/* Ensure mobile Filters tab is scrollable (body is overflow:hidden) */
.filtersArea{
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.filtersArea .body{
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

@media (max-width: 820px) {
  /* Mobile: keep map clear by default */
  .fab{ display:none; }
  .mobileExploreBtn{ display:none; }

  .panel{
    left: 12px; right: 12px; width: auto;
    top: auto;
    bottom: calc(12px + 64px + env(safe-area-inset-bottom));
    border-radius: 26px;
    max-height: calc(100dvh - 24px - 64px - env(safe-area-inset-bottom));
    height: calc(100dvh - 24px - 64px - env(safe-area-inset-bottom));
transition: transform .18s ease;
    transform: translateY(calc(100% + 24px)); /* fully hidden by default */
  }
  .sheetHandle{ display:flex; }

  /* Re-enable the close button inside the mobile sheet header */
  .header .iconBtn[title="Close on mobile"]{ display:inline-grid; place-items:center; }


.mobileNav{
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 1400;
  display:flex;
  gap: 10px;
}
.mobileNav .navBtn{
  flex:1;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 900;
  cursor:pointer;
}
.mobileNav .navBtn.primary{
  background: linear-gradient(180deg, rgba(25,118,210,.14), rgba(255,255,255,.92));
  border-color: rgba(25,118,210,.25);
}

.header{
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.88));
  backdrop-filter: blur(12px);
}

.mobileTabs{
  display:flex;
  gap: 10px;
  padding: 10px 12px 8px;
  align-items:center;
  flex-wrap: wrap;
  position: sticky;
  top: 64px;
  z-index: 4;
  background: linear-gradient(180deg, rgba(255,255,255,.97), rgba(255,255,255,.90));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.mobileTabs .tabBtn{
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(15,23,42,.04);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 900;
  cursor:pointer;
  line-height: 1;
}
body.mobileTabFilters #mTabFilters,
body.mobileTabList #mTabList{
  background: rgba(255,255,255,.96);
  border-color: rgba(124,58,237,.28);
  box-shadow: 0 10px 24px rgba(0,0,0,.10);
}

.modeSeg{
  display:flex;
  gap: 6px;
  width: 100%;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(15,23,42,.04);
}
.modeSeg .segBtn{
  flex: 1;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.90);
  border-radius: 14px;
  padding: 10px 10px;
  font-weight: 900;
  cursor:pointer;
}

.modeSeg .segBtn.on{
  background: linear-gradient(180deg, rgba(124,58,237,.16), rgba(255,255,255,.96));
  border-color: rgba(124,58,237,.30);
  box-shadow: 0 10px 22px rgba(0,0,0,.10);
}

/* Tab visibility (mobile only) */

  body.sheetOpen .panel{ transform: translateY(0); }
}

.pin{
  width: var(--s);
  height: var(--s);
  border-radius: 999px;
  display:grid;
  place-items:center;
  background: var(--pin);
  color: #fff;
  font-weight: 900;
  font-size: 10px;
  border: 2px solid rgba(255,255,255,.75);
  box-shadow: 0 10px 18px rgba(0,0,0,.20);
  position: relative;
  transform: translateZ(0);
  transition: transform .12s ease, box-shadow .12s ease;
}
.pin::after{
  content:"";
  position:absolute;
  inset:-6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pin) 22%, transparent);
  z-index:-1;
}
.pin:hover{ transform: scale(1.10); box-shadow: 0 16px 28px rgba(0,0,0,.22); }

.pin.active{
  outline: 3px solid rgba(245,158,11,.85);
  outline-offset: 2px;
}
.pin.anchor{
  outline: 4px solid rgba(245,158,11,.95);
  outline-offset: 3px;
  transform: scale(1.12);
}
.pulseRing{
  width: 18px; height: 18px;
  border-radius:999px;
  border: 2px solid rgba(245,158,11,.85);
  position:absolute;
  animation: pulse 1.15s ease-out forwards;
}
@keyframes pulse{
  0%{ transform: scale(.8); opacity:.95; }
  100%{ transform: scale(2.2); opacity:0; }
}

/* Similar mode mini UI */
.similarBar{
  display:none;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(245,158,11,.30);
  background: rgba(245,158,11,.10);
  margin: 10px 14px 0 14px;
  direction: rtl;
}
.similarBar.on{ display:block; }
.similarBar .row{ display:flex; justify-content:space-between; align-items:center; gap: 10px; }
.similarBar b{ font-weight: 900; }
.similarBar .sub{ font-size: 12px; color: var(--muted); margin-top: 4px; }
.similarBar button{
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  border-radius: 12px;
  padding: 8px 10px;
  cursor:pointer;
  font-weight: 900;
  white-space:nowrap;
}

/* =========================
   My Location control (Leaflet)
========================= */
.leaflet-control.myLocateCtl{
  box-shadow: var(--shadow2);
  border-radius: 14px;
  overflow: hidden;
}
.leaflet-control.myLocateCtl button{
  width: 42px; height: 42px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  cursor: pointer;
  display:grid;
  place-items:center;
  font-weight: 900;
  font-size: 18px;
}
.leaflet-control.myLocateCtl button:active{ transform: scale(.98); }
.leaflet-control.myLocateCtl button.loading{
  opacity: .75;
  pointer-events: none;
}
.myLocDot{
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #2563eb;
  box-shadow: 0 0 0 6px rgba(37,99,235,.18);
  border: 2px solid rgba(255,255,255,.95);
}


/* ===== Layers panel (vertical options) ===== */
.layersPanel{ padding: 12px; }
.layersHdr b{ font-weight: 900; }
.layersClose{ width: 40px; height: 40px; display:grid; place-items:center; }
.layersList{ display:flex; flex-direction:column; gap: 8px; padding: 6px 2px 2px; }
.layerOpt{
  width: 100%;
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
  cursor:pointer;
  font-weight: 900;
}
.layerOpt .txt{ font-size: 13px; opacity:.92; }
.layerOpt:active{ transform: scale(.99); }
.layerOpt.on{
  border-color: rgba(124,58,237,.32);
  box-shadow: 0 14px 30px rgba(124,58,237,.14);
  background: linear-gradient(180deg, rgba(124,58,237,.12), rgba(255,255,255,.94));
}
.layerOpt.reset{
  border-style: dashed;
  opacity: .95;
}
