/* الخريطة العقارية — تصميم فاخر هادئ */
:root {
  --map-ivory: #faf8f5;
  --map-navy: #1e2a38;
  --map-gold: #c5a46d;
  --map-gold-soft: rgba(197, 164, 109, 0.15);
  --map-border: rgba(30, 42, 56, 0.08);
  --map-shadow: 0 12px 40px rgba(30, 42, 56, 0.08);
}

.map-page {
  min-height: 100vh;
  background: var(--map-ivory);
  color: var(--map-navy);
  font-family: 'Cairo', sans-serif;
}

.nav__link--active {
  color: var(--map-gold, #c5a46d);
}

.map-page .header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 72px;
  min-height: 72px;
  max-height: 72px;
  overflow: hidden;
  background: rgba(250, 248, 245, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--map-border);
}

.map-page .header__inner {
  height: 100%;
  align-items: center;
}

.map-page .logo--header {
  max-height: 100%;
  display: flex;
  align-items: center;
}

.map-page .logo--header .logo__img,
.map-page .logo--header img {
  display: block;
  height: 42px;
  max-height: 42px;
  width: auto;
  max-width: min(150px, 38vw);
  object-fit: contain;
  object-position: right center;
}

.map-page main {
  padding-top: 0;
}

@media (max-width: 768px) {
  .map-page .header {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
  }

  .map-page .logo--header .logo__img,
  .map-page .logo--header img {
    height: 36px;
    max-height: 36px;
    max-width: min(120px, 42vw);
  }
}

.map-hero {
  padding: 2.5rem 0 1.5rem;
  text-align: center;
}

.map-hero__badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--map-gold);
  background: var(--map-gold-soft);
  padding: 0.35rem 1rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.map-hero__title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  color: var(--map-navy);
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.map-hero__desc {
  max-width: 36rem;
  margin: 0 auto;
  font-size: 0.95rem;
  color: rgba(30, 42, 56, 0.65);
  line-height: 1.7;
}

.map-filters {
  padding: 0 0 1rem;
}

.map-filters__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  background: #fff;
  border: 1px solid var(--map-border);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  box-shadow: var(--map-shadow);
}

.map-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(30, 42, 56, 0.55);
  flex: 1 1 120px;
  min-width: 100px;
}

.map-filters select,
.map-filters input {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--map-border);
  border-radius: 10px;
  background: var(--map-ivory);
  color: var(--map-navy);
}

.map-filters__actions {
  display: flex;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.map-filters__btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.map-filters__btn--gold {
  background: var(--map-gold);
  color: #fff;
}

.map-filters__btn--ghost {
  background: transparent;
  color: var(--map-navy);
  border: 1px solid var(--map-border);
}

.map-stage {
  position: relative;
  padding-bottom: 2rem;
}

.map-wrap {
  position: relative;
  height: min(72vh, 720px);
  min-height: 420px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--map-border);
  box-shadow: var(--map-shadow);
  background: #e8e4df;
}

.map-wrap:fullscreen,
.map-wrap:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: none !important;
  min-height: 0 !important;
  border-radius: 0;
  border: none;
}

.map-wrap--fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-height: none !important;
  min-height: 0 !important;
  border-radius: 0;
  border: none;
}

body.map-fs-active {
  overflow: hidden;
}

body.map-fs-active .header,
body.map-fs-active .map-hero,
body.map-fs-active .map-filters,
body.map-fs-active .footer {
  display: none;
}

body.map-fs-active .map-stage.container {
  max-width: none;
  padding: 0;
  margin: 0;
}

body.map-fs-active .map-stage {
  padding-bottom: 0;
}

#property-map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-mobile-tools {
  display: contents;
}

.map-toolbar {
  display: contents;
}

.map-fs-btn {
  position: absolute;
  inset-inline-end: 1rem;
  top: 3.25rem;
  z-index: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--map-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  color: var(--map-navy);
  cursor: pointer;
  box-shadow: var(--map-shadow);
  transition: background 0.2s, color 0.2s;
}

.map-fs-btn:hover,
.map-fs-btn[aria-pressed="true"] {
  background: var(--map-navy);
  color: #fff;
}

.map-fs-btn__icon {
  font-size: 1rem;
  line-height: 1;
}

.map-layer-toggle,
.map-layer-toggle.map-layer-toggle--stack {
  position: absolute;
  inset-inline-end: 1rem;
  top: 1rem;
  z-index: 500;
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--map-shadow);
}

.map-layer-toggle__btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.55rem 0.85rem;
  border: none;
  background: transparent;
  color: rgba(30, 42, 56, 0.65);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.map-layer-toggle__btn + .map-layer-toggle__btn {
  border-inline-start: 1px solid var(--map-border);
}

.map-layer-toggle__btn.active {
  background: var(--map-navy);
  color: #fff;
}

.map-layer-toggle__btn:hover:not(.active) {
  background: var(--map-gold-soft);
  color: var(--map-navy);
}

.map-legend {
  position: absolute;
  inset-inline-start: 1rem;
  top: 1rem;
  z-index: 500;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  min-width: 140px;
  box-shadow: var(--map-shadow);
}

/* كمبيوتر فقط: إنزال خريطة/قمر 10% وملء الشاشة 13% ورفع زر + بنسبة 5% */
@media (min-width: 769px) {
  .map-layer-toggle.map-layer-toggle--stack {
    top: calc(1rem + 10%);
  }

  .map-fs-btn.map-fs-btn--stack {
    top: calc(3.25rem + 13%);
  }
}

.map-legend__title {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--map-navy);
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.map-legend__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(30, 42, 56, 0.8);
  margin-bottom: 0.35rem;
}

.map-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.map-count {
  position: absolute;
  inset-inline-end: 1rem;
  bottom: 1rem;
  z-index: 500;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--map-navy);
  color: #fff;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  opacity: 0.9;
}

.map-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.map-pin-wrap {
  background: transparent !important;
  border: none !important;
}

.map-marker-pulse {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
}

.map-marker-pulse::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--pin-color, #1e2a38);
  opacity: 0.35;
  animation: map-pin-pulse 2.2s ease-out infinite;
}

.map-marker-core {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--pin-color, #1e2a38);
  border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.28);
}

.map-marker-pulse--pick::before {
  animation-duration: 1.4s;
}

@keyframes map-pin-pulse {
  0% { transform: scale(0.6); opacity: 0.5; }
  70% { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}

.map-card__details {
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
}

.map-card__detail {
  margin: 0.15rem 0;
  color: rgba(30, 42, 56, 0.75);
}

.map-card__detail span {
  font-weight: 700;
  color: var(--map-navy);
}

.map-card__btn--call {
  background: var(--map-navy);
  color: #fff;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(250, 248, 245, 0.7);
  font-weight: 700;
  color: var(--map-navy);
  transition: opacity 0.3s;
}

.map-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* بطاقة العقار — سطح المكتب */
.map-popup.leaflet-popup-content-wrapper {
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--map-shadow);
  border: 1px solid var(--map-border);
}

.map-popup .leaflet-popup-content {
  margin: 0;
  width: min(320px, 85vw) !important;
}

.map-card__gallery {
  position: relative;
  height: 160px;
  background: #eee;
  overflow: hidden;
}

.map-card__gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.map-card__body {
  padding: 1rem;
}

.map-card__type {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--map-gold);
  margin-bottom: 0.25rem;
}

.map-card__title {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
  line-height: 1.35;
}

.map-card__loc {
  font-size: 0.8rem;
  color: rgba(30, 42, 56, 0.6);
  margin-bottom: 0.5rem;
}

.map-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.map-card__price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--map-navy);
  margin-bottom: 0.35rem;
}

.map-card__price span {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(30, 42, 56, 0.5);
}

.map-card__ref {
  font-size: 0.72rem;
  color: rgba(30, 42, 56, 0.5);
  margin-bottom: 0.5rem;
}

.map-card__desc {
  font-size: 0.78rem;
  line-height: 1.55;
  color: rgba(30, 42, 56, 0.65);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.map-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.map-card__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.5rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.map-card__btn--primary {
  background: var(--map-navy);
  color: #fff;
  grid-column: 1 / -1;
}

.map-card__btn--wa {
  background: #25d366;
  color: #fff;
}

.map-card__btn--share {
  background: var(--map-gold-soft);
  color: var(--map-navy);
  border: 1px solid var(--map-gold);
}

/* Bottom Sheet — جوال */
.map-sheet {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  visibility: hidden;
}

.map-sheet.open {
  pointer-events: auto;
  visibility: visible;
}

.map-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 42, 56, 0.4);
  opacity: 0;
  transition: opacity 0.3s;
}

.map-sheet.open .map-sheet__backdrop {
  opacity: 1;
}

.map-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  background: #fff;
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: auto;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
}

.map-sheet.open .map-sheet__panel {
  transform: translateY(0);
}

.map-sheet__handle {
  width: 40px;
  height: 4px;
  background: rgba(30, 42, 56, 0.15);
  border-radius: 2px;
  margin: 0.65rem auto;
}

.map-share-menu {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(30, 42, 56, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.map-share-menu.open {
  opacity: 1;
  pointer-events: auto;
}

.map-share-menu__box {
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 1.25rem;
  width: 100%;
  max-width: 400px;
}

.map-share-menu__box button {
  display: block;
  width: 100%;
  font-family: inherit;
  font-weight: 700;
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--map-border);
  border-radius: 10px;
  background: var(--map-ivory);
  cursor: pointer;
}

@media (max-width: 768px) {
  .map-mobile-tools {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    position: absolute;
    top: 0.65rem;
    right: 0.75rem;
    left: auto;
    bottom: auto;
    z-index: 520;
    width: 106px;
    max-width: 32vw;
    pointer-events: none;
  }

  .map-mobile-tools > * {
    pointer-events: auto;
  }

  .map-mobile-tools .map-legend {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    inset: auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 0.45rem 0.53rem;
    border-radius: 8px;
    box-sizing: border-box;
  }

  .map-mobile-tools .map-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
  }

  .map-mobile-tools .map-layer-toggle.map-layer-toggle--stack {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    inset: auto;
    width: 100%;
    flex-direction: row;
  }

  .map-mobile-tools .map-layer-toggle--stack .map-layer-toggle__btn {
    flex: 1;
    font-size: 0.68rem;
    padding: 0.45rem 0.3rem;
    text-align: center;
  }

  .map-mobile-tools .map-fs-btn.map-fs-btn--stack {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    inset: auto;
    width: 100%;
    justify-content: center;
    padding: 0.42rem 0.5rem;
    font-size: 0.55rem;
    box-sizing: border-box;
  }

  .map-fs-btn--stack .map-fs-btn__label {
    display: none;
  }

  .map-fs-btn--stack .map-fs-btn__icon {
    font-size: 0.85rem;
  }

  .map-add-fab {
    bottom: 1rem;
    inset-inline-start: 0.75rem;
    top: auto;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
  }

  .map-legend__title {
    font-size: 0.49rem;
    margin-bottom: 0.42rem;
    letter-spacing: 0.02em;
  }

  .map-legend__item {
    font-size: 0.48rem;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
  }

  .map-legend__dot {
    width: 7px;
    height: 7px;
  }

  body.map-fs-active .map-mobile-tools {
    top: 0.65rem;
    right: 0.75rem;
    bottom: auto;
  }

  body.map-fs-active .map-count {
    bottom: 0.5rem;
  }

  .map-wrap {
    height: min(58vh, 520px);
    min-height: 360px;
    border-radius: 12px;
  }

  .map-filters__inner {
    padding: 0.85rem;
  }

  .leaflet-popup {
    display: none !important;
  }
}

/* إضافة عقار من الخريطة — أدمن */
.map-add-fab {
  position: absolute;
  inset-inline-start: 1rem;
  bottom: 1rem;
  z-index: 520;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--map-gold);
  color: var(--map-navy);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(197, 164, 109, 0.45);
  transition: transform 0.2s, box-shadow 0.2s;
}

@media (min-width: 769px) {
  .map-add-fab {
    bottom: calc(1rem + 10%);
    top: auto;
  }
}

.map-add-fab.active,
.map-add-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(197, 164, 109, 0.55);
}

.map-add-fab--guest {
  opacity: 0.85;
  border: 2px dashed var(--map-navy);
}

.map-add-panel {
  position: fixed;
  inset: 0;
  z-index: 2500;
  pointer-events: none;
  visibility: hidden;
}

.map-add-panel.open {
  pointer-events: auto;
  visibility: visible;
}

.map-add-panel__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 42, 56, 0.45);
  opacity: 0;
  transition: opacity 0.3s;
}

.map-add-panel.open .map-add-panel__backdrop {
  opacity: 1;
}

.map-add-panel__sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(92vh, 720px);
  background: var(--map-ivory);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(30, 42, 56, 0.15);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-add-panel.open .map-add-panel__sheet {
  transform: translateY(0);
}

@media (min-width: 769px) {
  .map-add-panel__sheet {
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
    width: min(420px, calc(100vw - 2rem));
    max-height: calc(100vh - 3rem);
    border-radius: 16px;
    transform: translateX(120%);
    transition: transform 0.35s ease;
  }

  .map-add-panel.open .map-add-panel__sheet {
    transform: translateX(0);
  }

  .map-add-panel__handle {
    display: none;
  }
}

.map-add-panel__handle {
  width: 40px;
  height: 4px;
  background: rgba(30, 42, 56, 0.15);
  border-radius: 999px;
  margin: 0.65rem auto 0;
}

.map-add-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--map-border);
}

.map-add-panel__head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.map-add-panel__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--map-gold-soft);
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--map-navy);
}

.map-add-form {
  padding: 1rem 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.map-add-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--map-navy);
}

.map-add-form input,
.map-add-form select,
.map-add-form textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--map-border);
  border-radius: 10px;
  background: #fff;
}

.map-add-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.map-add-form__coords {
  font-size: 0.75rem;
  color: var(--map-gold);
  font-weight: 700;
  margin: 0 0 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--map-gold-soft);
  border-radius: 8px;
}

.map-add-form__price-type {
  border: 1px solid var(--map-border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.map-add-form__price-type legend {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 0.25rem;
}

.map-add-form__price-type label {
  flex-direction: row;
  align-items: center;
  font-weight: 600;
}

.map-add-form__preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.map-add-form__preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
}

.map-add-form__submit {
  margin-top: 0.5rem;
  padding: 0.85rem;
  border: none;
  border-radius: 12px;
  background: var(--map-navy);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.map-add-form__submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.map-add-form .req {
  color: #c0392b;
}

.map-add-toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 3000;
  background: var(--map-navy);
  color: #fff;
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.map-add-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.map-add-toast--err {
  background: #b91c1c;
}

body.map-add-open {
  overflow: hidden;
}
