/* ===========================
   SanatMap – Factory Map CSS
   =========================== */

.sm-factory-map-wrap{
  --sm-brand: #002b66;
  --sm-brand-rgb: 0,43,102;
  --sm-accent: #ff7900;

  display:flex;
  gap:0;
  /* سایدبار سمت راست بدون تغییر HTML */
  flex-direction: row-reverse;
  height:100vh;               /* ارتفاع تمام‌صفحه برای خود بخش نقشه */
  overflow:hidden;
  background:#fff;
  font-family:"Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", Tahoma, sans-serif;
  overscroll-behavior: none;
}

/* از دست‌کاری بدنهٔ قالب خودداری شود (برای تداخل نداشتن با هدر/فوتر سایت) */
/* body{ ... }  ← عمداً وجود ندارد */

/* اطمینان از فونت داخل نقشه و پاپ‌آپ‌ها */
.sm-factory-map-wrap .leaflet-container,
.sm-factory-map-wrap .leaflet-popup-content, 
.sm-factory-map-wrap .leaflet-tooltip {
  font-family:"Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", Tahoma, sans-serif;
}

.sm-popup,
.leaflet-popup-content{
  direction:rtl;
  text-align:right;
}

/* ===========================
   نقشه و سایدبار
   =========================== */
#sm-map{
  flex:1 1 auto;
  height:100%;
  min-width:0;
  contain: layout paint size; /* بهبود رندر */
}
.sm-sidebar{
  width:clamp(260px, 28vw, 380px);
  max-width:40%;
  border-inline-start:1px solid #eee; /* چون row-reverse است، این خط در سمت راست می‌افتد */
  background:#fff;
  display:flex;
  flex-direction:column;
  overflow:auto;              /* فقط سایدبار اسکرول */
  contain: content;           /* ایزوله‌سازی برای سرعت */
  -webkit-overflow-scrolling: touch; /* iOS smooth scrolling */
}
html[dir="rtl"] .sm-sidebar{
  /* در RTL نیازی به تغییر نیست؛ row-reverse سایدبار را راست می‌آورد */
}

.sm-map-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  padding: 12px;
  border-bottom: 1px solid #eee;
}

/* جستجو */
.sm-search{ padding:12px; border-bottom:1px solid #eee; }
#sm-factory-search{
  width:100%;
  padding:10px 12px;
  border:1px solid #ddd;
  border-radius:10px;
}

/* فیلترها */
.sm-filters{
  padding:10px 12px;
  border-bottom:1px solid #eee;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.sm-filter-row{ display:flex; gap:8px; }
.sm-filter-row select{
  width:100%;
  padding:8px 10px;
  border:1px solid #ddd;
  border-radius:10px;
  background:#fff;
}
.sm-inbounds{
  font-size:13px;
  display:flex;
  align-items:center;
  gap:8px;
  user-select:none;
}

/* ===========================
   لیست کارخانه‌ها
   =========================== */
.sm-list{ list-style:none; margin:0; padding:10px; }

.sm-item{
  padding:12px;
  border:1px solid #eee;
  border-radius:12px;
  margin-bottom:8px;
  display:grid;
  grid-template-columns: 1fr 64px; /* عنوان/دکمه چپ، لوگو راست کارت */
  gap:12px;
  align-items:center;
  background:#fff;
}
.sm-item.is-active{ border-color:#c7d2fe; background:#f8fafc; }

.sm-card-body{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.sm-title{
  cursor:pointer;
  font-weight:700;
  font-size:14px;
  line-height:1.7;
  margin:0;
}
.sm-title:focus{
  outline:none;
  box-shadow:0 0 0 2px rgba(0,0,0,.08);
  border-radius:8px;
}

/* رسانه (ستون 64px) */
.sm-card-media{
  display:flex;
  justify-content:flex-end; /* لوگو به کنارهٔ راست کارت بچسبد */
  align-items:center;
  width:64px;               /* محکم‌کاری برای 100% شدن img در حالت has-logo */
  height:64px;
}
.sm-card-media img{
  width:56px; height:56px; object-fit:cover;
  border-radius:12px; border:1px solid #eee;
}
.sm-avatar{
  width:56px; height:56px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  background:#eef2ff; color:#002b66; font-weight:800; font-size:18px;
  border:1px solid #e5e7eb;
}

/* دکمۀ نارنجی کوچک (CTA کارت) */
.sm-card-btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding:6px 10px;
  border-radius:10px;
  background:var(--sm-accent);
  color:#fff !important;
  text-decoration:none !important;
  font-size:12px; font-weight:700;
  box-shadow:0 1px 4px rgba(0,0,0,.06);
  transition:filter .2s ease, transform .02s ease;
}
.sm-card-btn:hover{ filter:brightness(1.06); }
.sm-card-btn:active{ transform:translateY(1px); }

/* ===========================
   دکمه‌های سایدبار
   =========================== */

/* گروه دکمه‌های کناری */
.sm-actions{
  display:grid;
  grid-template-columns: 1fr 1fr; /* هرکدام ۵۰٪ */
  gap:8px;
}

/* استایل مشترک دکمه‌ها (کپی لینک + محدوده پیش‌فرض) */
.sm-btn,
.sm-copy-btn{
  appearance:none;
  -webkit-appearance:none;
  background:var(--sm-brand);
  color:#fff;
  border:1px solid var(--sm-brand);
  border-radius:12px;
  padding:10px 14px;
  width:100%;
  display:block;
  text-align:center;
  font:inherit;
  font-weight:600;
  cursor:pointer;
  transition:background .2s ease, box-shadow .2s ease, transform .02s ease, filter .2s ease;
  box-shadow:0 2px 8px rgba(0,0,0,.06);
  -webkit-tap-highlight-color:transparent;
}

.sm-btn:hover,
.sm-copy-btn:hover{ filter:brightness(1.06); }
.sm-btn:focus,
.sm-copy-btn:focus{ outline:none; box-shadow:0 0 0 3px rgba(var(--sm-brand-rgb), .28); }
.sm-btn:active,
.sm-copy-btn:active{ transform:translateY(1px); }
.sm-copy-btn.is-copied{ background:#00255a; border-color:#00255a; }

/* دکمه مکان‌یابی */
.sm-locate-btn{
  display:flex; align-items:center; justify-content:center;
  background:var(--sm-brand);
  color:#fff;
  border:none;
  border-radius:10px;
  width:40px; height:40px;
  cursor:pointer;
  box-shadow:0 2px 8px rgba(0,0,0,.15);
}
.sm-locate-btn:hover{ filter:brightness(1.06); }
.sm-locate-btn:active{ transform:translateY(1px); }
.leaflet-top.leaflet-left .sm-locate-btn{ margin-top:8px; }

/* ===========================
   پاپ‌آپ
   =========================== */
.sm-popup{ min-width:220px; max-width:280px; }
.sm-pop-title{ font-weight:700; font-size:15px; margin-bottom:6px; }
.sm-pop-addr{ color:#6b7280; font-size:13px; line-height:1.8; margin-bottom:8px; }

.sm-pop-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}
.sm-pop-btn{
  display:flex; align-items:center; justify-content:center; gap:6px;
  background:var(--sm-brand);
  color:#fff !important;
  text-decoration:none;
  border-radius:10px;
  padding:8px 10px;
  font-size:13px;
}
.sm-pop-btn:hover{ filter:brightness(1.06); }

/* CTA: جزئیات */
.sm-pop-more{
  display:block;
  width:100%;
  margin-top:10px;
  background:var(--sm-accent);
  color:#fff !important;
  text-align:center;
  border-radius:10px;
  padding:9px 12px;
  font-weight:700;
  text-decoration:none !important;
  box-shadow:0 2px 6px rgba(0,0,0,.08);
  transition:filter .2s ease, transform .02s ease;
}
.sm-pop-more:hover{ filter:brightness(1.05); }
.sm-pop-more:active{ transform:translateY(1px); }

/* padding فقط وقتی تصویر داریم (طبق تغییر اخیر شما) */
.sm-card-media.has-logo img { padding: 3px; width:100%; height:100%; object-fit: contain; box-sizing: border-box; }
.sm-card-media:not(.has-logo) { padding: 0; }

/* کاهش حرکت برای کاربران حساس به انیمیشن */
@media (prefers-reduced-motion: reduce){
  .sm-card-btn,
  .sm-pop-more{ transition:none; }
}

/* استایل دکمه نمایش بیشتر */
.sm-load-more.sm-btn {
  width: calc(100% - 30px); /* عرض کامل با احتساب فاصله از طرفین */
  margin: 10px 15px 20px;   /* فاصله از بالا، طرفین و پایین */
}

.marker-cluster div {
    margin-right: 5px;align-content
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 992px){
  /* نقشه بالا، سایدبار پایین */
  .sm-factory-map-wrap{ flex-direction: column; }

  #sm-map{ height: 100%; }
  
  .sm-sidebar{
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 80%; /* حداکثر ارتفاع سایدبار */
    border-inline-start: none;
    border-top: 1px solid #ddd;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,.1);
    z-index: 1000;
    transform: translateY(calc(100% - 55px)); /* حالت بسته: فقط بخش کوچکی معلوم است */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    contain: content;
  }
  
  /* وقتی سایدبار باز است */
  .sm-sidebar.is-open {
    transform: translateY(0);
  }

  .sm-map-title {
    cursor: pointer; /* کاربر می‌تواند با کلیک روی عنوان هم پنل را باز و بسته کند */
    text-align: center;
    padding: 18px 12px;
  }
  .sm-map-title::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 0 auto 12px;
  }

  .sm-item{ grid-template-columns: 1fr 64px; }
  .sm-card-media{ width:64px; height:64px; }
  .sm-card-media img, .sm-avatar{ width:64px; height:64px; border-radius:10px; }
}
