/* ===== راست‌چین‌کردن کادر جستجوی هدر موبایل =====
   هدر موبایل direction:ltr دارد و کادر جستجو آن را به ارث می‌برد؛ در نتیجه متن فارسی از چپ شروع می‌شد
   و علامت پاک‌کردن (×) پشت کلمات می‌افتاد. اینجا کادر راست‌چین می‌شود: متن از راست، × و میکروفون سمت چپ. */
@media (max-width: 767px) {
  html body.jh-divar .jhe-header[data-mode="mobile"] .jhe-search-form,
  html body.jh-divar .jhe-header[data-mode="mobile"] .jhe-search-form input[type="search"] {
    direction: rtl !important;
  }
  html body.jh-divar .jhe-header[data-mode="mobile"] .jhe-search-form input[type="search"] {
    text-align: right !important;
    unicode-bidi: isolate !important;
    padding-left: 48px !important;
    padding-right: 14px !important;
  }
  html body.jh-divar .jhe-header[data-mode="mobile"] .jhe-search-form input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 18px;
    margin: 0 0 0 4px;
    cursor: pointer;
    background: no-repeat center / 14px 14px url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 6l12 12M18 6L6 18' fill='none' stroke='%23888' stroke-width='3' stroke-linecap='round'/></svg>");
  }
}

/* ===== پنجرهٔ کشویی زیردسته‌ها (فقط موبایل) ===== */
.jh-sheet { display: none; }
@media (max-width: 767px) {
  html.jh-sheet-lock, html.jh-sheet-lock body { overflow: hidden !important; }
  .jh-sheet { display: block; position: fixed; inset: 0; z-index: 100010; direction: rtl; font-family: inherit; }
  .jh-sheet[hidden] { display: none !important; }
  .jh-sheet__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .18s ease; }
  .jh-sheet__panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; max-height: 88dvh; min-height: 40vh;
    display: flex; flex-direction: column; background: #fff; color: #29292d;
    border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.18);
    transform: translateY(100%); transition: transform .18s ease; padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .jh-sheet.is-open .jh-sheet__backdrop { opacity: 1; }
  .jh-sheet.is-open .jh-sheet__panel { transform: translateY(0); }
  .jh-sheet__handle { display: block; width: 58px; height: 5px; border-radius: 3px; background: #d4d4d8; margin: 10px auto 4px; flex: none; }
  .jh-sheet__head { display: flex; align-items: center; gap: 8px; padding: 8px 14px 12px; border-bottom: 1px solid #ececef; margin: 0 12px; flex: none; }
  .jh-sheet__titles { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: right; }
  .jh-sheet__crumb { font-size: 15px; color: #737379; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .jh-sheet__title { font-size: 19px; font-weight: 800; color: #29292d; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .jh-sheet__btn { flex: none; width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 0; margin: 0; border: 0 !important; border-radius: 50%; background: transparent !important; color: #4a4a50 !important; box-shadow: none !important; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .jh-sheet__btn:active { background: #f0f0f2 !important; }
  .jh-sheet__search { padding: 12px 12px 6px; flex: none; }
  .jh-sheet .jh-sheet__input {
    display: block; width: 100%; height: 50px; margin: 0; padding: 0 16px; box-sizing: border-box;
    border: 1.5px solid #c9c9ce !important; border-radius: 14px !important; background: #fff !important; box-shadow: none !important; outline: 0 !important;
    direction: rtl; text-align: right; unicode-bidi: isolate; font: inherit; font-size: 17px; font-weight: 600; color: #29292d;
  }
  .jh-sheet .jh-sheet__input::placeholder { color: #8d8d93; opacity: 1; font-weight: 600; }
  .jh-sheet .jh-sheet__input:focus { border-color: #a62626 !important; }
  .jh-sheet__list { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 6px 12px 16px; }
  .jh-sheet .jh-sheet__row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; box-sizing: border-box;
    min-height: 56px; margin: 0 0 9px; padding: 10px 16px; border: 0 !important; border-radius: 14px; background: #f5f5f6 !important;
    color: #29292d !important; font: inherit; font-size: 17px; font-weight: 700; text-align: right; text-decoration: none !important;
    cursor: pointer; -webkit-tap-highlight-color: transparent; box-shadow: none !important;
  }
  .jh-sheet .jh-sheet__row:active { background: #eaeaed !important; }
  .jh-sheet__rowtext { flex: 1 1 auto; min-width: 0; text-align: right; line-height: 1.6; }
  .jh-sheet__rowsub { flex: none; max-width: 48%; font-size: 13px; font-weight: 600; color: #8d8d93; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .jh-sheet__chev { flex: none; display: inline-flex; color: #8d8d93; }
  .jh-sheet__empty { padding: 28px 8px; text-align: center; color: #8d8d93; font-size: 16px; }

  /* انیمیشن خروج هنگام رفتن به صفحهٔ دسته: پنجره پایین می‌رود، پس‌زمینه تاریک و سپس صفحه عوض می‌شود */
  .jh-sheet.is-leaving { pointer-events: none; }
  .jh-sheet.is-leaving .jh-sheet__backdrop { background: rgba(0,0,0,.72); transition: background .14s ease; }
  .jh-sheet.is-leaving .jh-sheet__panel { transform: translateY(100%); opacity: .4; transition: transform .14s ease, opacity .14s ease; }
}

/* موبایل: نوار چیپ‌های فیلتر (دسته/شهر/جستجو) بالای آگهی‌ها نمایش داده نشود */
@media (max-width: 767px) {
  .ad-list-block .jh-active, .jh-main .jh-active { display: none !important; }
}

/* ===== نام سایت در هدر (عنوان سایت از تنظیمات عمومی): همیشه قرمز ===== */
.jhe-header .jhe-item-front.jhe-site-name,
.jhe-header .jhe-item-front.jhe-site-name:hover,
.jhe-header .jhe-item-front.jhe-site-name:focus,
body.jh-divar .jhe-header .jhe-item-front.jhe-site-name,
body.jh-divar .jhe-header .jhe-item-front.jhe-site-name:hover { color: var(--jhe-site-name, #d32f2f) !important; }

/* ===== فاصلهٔ نام سایت تا باکس انتخاب شهر دو برابر (فاصلهٔ قبلی ۶ تا ۱۲ پیکسل بود؛ همان‌قدر اضافه شد) ===== */
.jhe-header .jhe-site-name + .jhe-city-wrap,
.jhe-header .jhe-city-wrap + .jhe-site-name { margin-inline-start: 6px; }
@media (min-width: 1024px) {
  .jhe-header .jhe-site-name + .jhe-city-wrap,
  .jhe-header .jhe-city-wrap + .jhe-site-name { margin-inline-start: 12px; }
}

/* ===== منوی فوتر + شبکه‌های اجتماعی + نمادها زیر نوار دسته‌ها (دسکتاپ، مثل دیوار) ===== */
.jh-side__foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid #ececef; direction: rtl; text-align: right; }
/* منوی دسترسی سریع (بدون عنوان) فقط در دسکتاپ */
@media (max-width: 1024px) { .jh-side__fmenu { display: none !important; } }
.jh-side__fmenu ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 18px; }
.jh-side__fmenu li { margin: 0; }
.jh-side__fmenu a { display: inline-block; padding: 6px 0; font-size: 14px; color: #6b6b72 !important; text-decoration: none !important; }
.jh-side__fmenu a:hover { color: #a62626 !important; }
.jh-side__social { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; }
.jh-side__social li { margin: 0; }
.jh-side__social a { display: inline-flex; color: #5f5f66 !important; font-size: 20px; text-decoration: none !important; }
.jh-side__social a:hover { color: #a62626 !important; }
.jh-side__namad { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.jh-side__namad img { max-width: 84px; height: auto; }
/* در دسکتاپ همان موارد از ستون‌های پایین فوتر برداشته می‌شود تا تکراری نباشد */
@media (min-width: 1025px) {
  body:has(.jh-side__foot) footer.footer .namad,
  body:has(.jh-side__foot) footer.footer .row > .col-md-3 { display: none !important; }
}

/* ===== انتخاب چندتایی شهر (موبایل، تبلت و دسکتاپ): استان ← شهرها (مثل دیوار) ===== */
@media (max-width: 767px) {
  /* پنجره انتخاب شهر باید بالاتر از فوتر و تمام لایه‌های سایت باشد */
  .jhe-city-menu.jh-multi-menu {
    position: fixed !important; inset: 0 !important; z-index: 2147483647 !important;
    width: 100vw !important; height: 100vh !important; height: 100dvh !important;
    max-height: none !important; margin: 0 !important; padding: 0 !important;
    align-items: stretch !important; justify-content: stretch !important;
    overflow: hidden !important; background: #fff !important;
  }
  .jhe-city-menu.jh-multi-menu.open { display: flex !important; }
  .jhe-city-menu.jh-multi-menu { display: none; }
  .jhe-city-menu.jh-multi-menu .jhe-modal-box { position: relative; z-index: 1; }
  .jhe-city-menu.jh-multi-menu { isolation: isolate; }

  .jhe-city-menu.jh-multi-menu .jhe-modal-box {
    display: flex !important; flex-direction: column !important; align-items: stretch !important;
    width: 100%; max-width: none; height: 100%; min-height: 0; max-height: 100%; flex: 1 1 auto;
    padding: 0 !important; margin: 0 !important; overflow: hidden !important; border-radius: 0; box-shadow: none; background: #fff !important;
  }
  .jhe-city-menu.jh-multi-menu .jhe-modal-head,
  .jhe-city-menu.jh-multi-menu .jhe-modal-body { display: none !important; }
}

/* ===== ساختار مشترک انتخاب شهر (همهٔ اندازه‌ها) ===== */
/* علت اصلی: هدر موبایل (position:fixed + z-index:99998) یک stacking context می‌سازد و پنجرهٔ شهر داخل آن است؛
   در نتیجه z-index بسیار بالای پنجره فقط داخل هدر معتبر بود و نوار فوتر (z-index:99999) روی آن می‌افتاد.
   تا وقتی پنجرهٔ شهر باز است، هدر (میزبان پنجره) بالاتر از همه و فوتر زیر آن قرار می‌گیرد. */
html.jh-city-open .jhe-header,
body:has(.jhe-city-menu.jh-multi-menu.open) .jhe-header { z-index: 2147483647 !important; }
html.jh-city-open .jmfm-bar,
body:has(.jhe-city-menu.jh-multi-menu.open) .jmfm-bar { z-index: 1 !important; pointer-events: none !important; }

.jhc { display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; height: 100%; min-height: 0; box-sizing: border-box; direction: rtl; background: #fff; overflow: hidden; }
.jhc-head {
  flex: none; display: flex; align-items: center; gap: 14px; padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: #f5f5f6; color: #29292d;
}
.jhc-back { flex: none; display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; margin: 0; padding: 0; border: 0 !important; background: transparent !important; color: #6b6b72 !important; box-shadow: none !important; }
.jhc-title { flex: 1 1 auto; font-size: 19px; font-weight: 800; text-align: right; }

.jhc-search { flex: none; padding: 12px 10px 8px; }
.jhc-q {
  display: block; width: 100%; height: 48px; box-sizing: border-box; padding: 0 16px; direction: rtl; text-align: right;
  border: 1.5px solid #c9c9ce; border-radius: 12px; background: #fff; color: #29292d; font: inherit; font-size: 16px; outline: 0; box-shadow: none;
  -webkit-appearance: none; appearance: none;
}
.jhc-q:focus { border-color: #a62626; }
.jhc-q::placeholder { color: #9a9aa1; }

.jhc-chips { flex: none; display: flex; gap: 10px; overflow-x: auto; padding: 6px 10px 10px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.jhc-chips::-webkit-scrollbar { display: none; }
.jhc-chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; margin: 0;
  border: 1.5px solid #c25a5a !important; border-radius: 10px; background: #fdf7f7 !important; color: #a62626 !important;
  font: inherit; font-size: 16px; font-weight: 700; white-space: nowrap; cursor: pointer; box-shadow: none !important;
}

.jhc-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 12px; }
.jhc-row {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 6px 4px; box-sizing: border-box;
  border-bottom: 1px solid #e4e4e8; color: #29292d; font-size: 18px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.jhc-row.is-bold { font-weight: 800; }
.jhc-row:active { background: #f3f3f5; }
.jhc-txt { flex: 1 1 auto; min-width: 0; text-align: right; line-height: 1.5; }
.jhc-txt small { display: block; font-size: 13px; font-weight: 500; color: #8d8d93; }
.jhc-chev { flex: none; display: inline-flex; color: #8d8d93; }
.jhc-empty { padding: 32px 8px; text-align: center; color: #8d8d93; font-size: 16px; }

.jh-check {
  flex: none; position: relative; width: 26px; height: 26px; box-sizing: border-box;
  border: 2px solid #8d8d93; border-radius: 5px; background: #fff;
}
.jh-check.is-checked, .jh-check.is-partial { background: #d32121; border-color: #d32121; }
.jh-check.is-checked:after {
  content: ""; position: absolute; left: 8px; top: 3px; width: 6px; height: 12px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.jh-check.is-partial:after { content: ""; position: absolute; left: 5px; right: 5px; top: 10px; height: 3px; border-radius: 2px; background: #fff; }

.jh-city-foot { position: relative !important; z-index: 2147483647 !important; display: flex !important; flex: 0 0 auto !important; align-items: center; justify-content: flex-start; width: 100%; min-height: 82px; box-sizing: border-box; padding: 12px 4.2% calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 0; background: #f5f5f6 !important; direction: ltr; }
.jh-city-apply {
  display: block !important; visibility: visible !important; opacity: 1 !important; width: 46%; max-width: 420px; min-width: 150px; height: 54px; margin: 0; border: 0 !important; border-radius: 12px; background: #c62c2c !important;
  color: #fff !important; font: inherit; font-size: 19px; font-weight: 800; cursor: pointer; box-shadow: none !important;
}
.jh-city-apply:active { filter: brightness(.92); }

/* ===== تبلت و دسکتاپ: همان ساختار انتخاب شهر به‌صورت پنجرهٔ وسط صفحه ===== */
@media (min-width: 768px) {
  .jhe-city-menu.jh-multi-menu .jhe-modal-head,
  .jhe-city-menu.jh-multi-menu .jhe-modal-body { display: none !important; }
  .jhe-city-menu.jh-multi-menu .jhe-modal-box {
    display: flex !important; flex-direction: column !important; align-items: stretch !important;
    width: 520px; max-width: 100%; height: min(680px, calc(100vh - 40px)); max-height: calc(100vh - 40px);
    padding: 0 !important; margin: 0 !important; overflow: hidden !important; border-radius: 16px; background: #fff !important;
  }
  .jhe-city-menu.jh-multi-menu .jhc-head { padding: 16px 18px 12px; }
  .jhe-city-menu.jh-multi-menu .jhc-row { min-height: 56px; font-size: 17px; }
  .jhe-city-menu.jh-multi-menu .jhc-row:hover { background: #f3f3f5; }
  .jhe-city-menu.jh-multi-menu .jh-city-foot { display: flex !important; min-height: 78px; padding: 12px 18px; }
  .jhe-city-menu.jh-multi-menu .jh-city-apply { width: 100%; max-width: none; }
}

/* ===== موبایل: منوی سریع، آیکن‌های شبکه‌های اجتماعی و کد نمادها حذف می‌شوند (فقط در دسکتاپ نمایش داده می‌شوند) ===== */
@media (max-width: 767px) {
  .jh-side__foot,
  footer.footer .namad,
  footer.footer .social,
  footer.footer .row > .col-md-3 { display: none !important; }
}
