/* بایو مپ – frontend styles (RTL) */

/* در حالت باز بودن نقشه، خود صفحه اسکرول ندارد؛ فقط لیست گیاهان هم‌زیست اسکرول داخلی دارد */
body.phab-open { overflow: hidden; }

/* ویجت چت گفتینو (و هر عنصری با شناسه گفتینو) هنگام باز بودن نقشه پنهان می‌شود؛
   لایه پشتیبان در کنار API رسمی گفتینو که در جاوااسکریپت صدا زده می‌شود */
body.phab-open [id*="goftino"],
body.phab-open [class*="goftino"] {
	display: none !important;
}

/* دکمه زیر نام گیاه: کادر کمرنگ و حالت کاملاً گرد (pill) */
.phab-open-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 8px 0 14px;
	padding: 10px 20px;
	background: #fff;
	color: #2e7d32;
	border: 1px solid rgba(46, 125, 50, 0.3);
	border-radius: 999px;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.phab-open-btn::before { content: "◉"; font-size: 12px; }
.phab-open-btn:hover { background: #2e7d32; border-color: #2e7d32; color: #fff; }

/* ---------- افکت شیشه‌ای مشترک ---------- */
.phab-glass {
	background: rgba(255, 255, 255, 0.55);
	-webkit-backdrop-filter: blur(14px) saturate(160%);
	backdrop-filter: blur(14px) saturate(160%);
	border: 1px solid rgba(255, 255, 255, 0.65);
	box-shadow: 0 8px 28px rgba(15, 40, 20, 0.14);
	border-radius: 14px;
	color: #1d3a24;
}

/* ---------- صفحه نقشه (به جای محتوای محصول در همان صفحه) ---------- */
/* کل صفحه نقشه ارتفاع ثابت دارد (با جاوااسکریپت = باقی‌مانده ارتفاع صفحه زیر هدر)؛
   نقشه ثابت است و فقط لیست پایین اسکرول می‌خورد. */
/* جلوگیری از سرریز عرضی: عرض همه عناصر داخل صفحه نقشه شامل padding و border محاسبه می‌شود */
.phab-page,
.phab-page * {
	box-sizing: border-box;
}

.phab-page {
	direction: rtl;
	width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
	height: 80vh; /* مقدار دقیق با جاوااسکریپت تنظیم می‌شود */
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.phab-page[hidden] { display: none; }

/* نقشه: تمام‌عرض و بخش اصلی ارتفاع */
.phab-map-hero {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	width: 100%;
	overflow: hidden;
}

/* کنترل‌های پایین نقشه (زوم و اعتبار) هماهنگ با کادر پایینی بالا و پایین می‌روند */
.phab-page .leaflet-bottom {
	transition: bottom .35s cubic-bezier(.4, 0, .2, 1);
}
#phab-map { position: absolute; inset: 0; z-index: 1; }

/* نوار بالای نقشه: فلش بازگشت + عنوان + جستجو */
.phab-topbar {
	position: absolute;
	top: 14px;
	right: 14px;
	left: 14px;
	z-index: 900;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	pointer-events: none;
}
.phab-topbar > * { pointer-events: auto; }

/* فلش بازگشت (RTL: رو به راست) */
.phab-back {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	transition: background .15s ease;
}
.phab-back:hover { background: rgba(255, 255, 255, 0.8); }
.phab-back[hidden] { display: none; }
.phab-back svg { display: block; }

.phab-title {
	margin: 0;
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 700;
	max-width: 46%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* جستجو داخل نقشه، شیشه‌ای */
.phab-search-wrap { position: relative; flex: 1 1 220px; max-width: 340px; margin-right: auto; }
.phab-search {
	width: 100%;
	padding: 11px 16px;
	font-size: 14px;
	color: #1d3a24;
	outline: none;
}
.phab-search::placeholder { color: rgba(29, 58, 36, 0.55); }
.phab-search:focus { border-color: rgba(76, 187, 23, 0.8); box-shadow: 0 8px 28px rgba(46, 125, 50, 0.22); }
.phab-search-results {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	left: 0;
	z-index: 950;
	max-height: 280px;
	overflow-y: auto;
	background: rgba(255, 255, 255, 0.7);
	padding: 4px;
}
.phab-sr-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	cursor: pointer;
	font-size: 13px;
	color: #1d3a24;
	border-radius: 10px;
}
.phab-sr-item:hover { background: rgba(255, 255, 255, 0.85); }
.phab-sr-item img { width: 34px; height: 34px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.phab-sr-empty { padding: 10px 12px; font-size: 13px; color: #566; }

/* ---------- مپ مارکر (پین) نقاط زیستگاه ---------- */
.phab-pin-wrap { background: none; border: none; }
.phab-pin {
	display: block;
	filter: drop-shadow(0 3px 5px rgba(15, 40, 20, 0.35));
	cursor: pointer;
	transition: transform .15s ease;
	transform-origin: 50% 100%;
}
.phab-pin-wrap:hover .phab-pin { transform: scale(1.12); }
.phab-pin-body { transition: fill .2s ease; }

/* پین انتخاب‌شده: سبز تیره‌تر از بقیه */
.phab-pin-wrap.is-active .phab-pin-body { fill: #14571f; }

/* پین بازدیدشده (visited): طوسی خنثی */
.phab-pin-wrap.is-visited .phab-pin-body { fill: #9aa39c; }

/* ---------- پاپ‌آپ دما و رطوبت (Leaflet popup روی همان نقطه) ---------- */
.phab-popup .leaflet-popup-content-wrapper {
	background: rgba(255, 255, 255, 0.55);
	-webkit-backdrop-filter: blur(16px) saturate(160%);
	backdrop-filter: blur(16px) saturate(160%);
	border: 1px solid rgba(255, 255, 255, 0.65);
	box-shadow: 0 8px 28px rgba(15, 40, 20, 0.18);
	border-radius: 14px;
	color: #1d3a24;
}
.phab-popup .leaflet-popup-content { margin: 12px 16px; font-size: 13px; line-height: 1.7; }
.phab-popup .leaflet-popup-tip {
	background: rgba(255, 255, 255, 0.55);
	-webkit-backdrop-filter: blur(16px) saturate(160%);
	backdrop-filter: blur(16px) saturate(160%);
	box-shadow: 0 8px 28px rgba(15, 40, 20, 0.18);
}
.phab-popup .leaflet-popup-close-button { color: #1d3a24; }
.phab-popup-body { direction: rtl; text-align: right; }

/* نام کشور - شهر بالای کادر، با رنگ سبز */
.phab-popup-place {
	color: #2e7d32;
	font-weight: 700;
	font-size: 13.5px;
	margin-bottom: 6px;
	padding-bottom: 6px;
	border-bottom: 1px solid rgba(46, 125, 50, 0.2);
}
.phab-popup-place:empty { display: none; }

.phab-climate-row { margin: 2px 0; }
.phab-climate-row span { color: rgba(29, 58, 36, 0.65); }

/* اعتبار نقشه (biogol | ...) با ظاهر پیش‌فرض Leaflet، چسبیده به گوشه پایین راست کادر نقشه */
.phab-page .leaflet-control-attribution { direction: ltr; }

/* کنترل زوم مدرن و شیشه‌ای */
.phab-page .leaflet-control-zoom {
	border: none !important;
	box-shadow: none !important;
	margin: 0 0 14px 14px;
	border-radius: 14px;
	overflow: hidden;
	background: rgba(255, 255, 255, 0.55);
	-webkit-backdrop-filter: blur(14px) saturate(160%);
	backdrop-filter: blur(14px) saturate(160%);
	border: 1px solid rgba(255, 255, 255, 0.65) !important;
	box-shadow: 0 8px 28px rgba(15, 40, 20, 0.14) !important;
	/* کمی فاصله از لبه نقشه، هماهنگ با جستجو و کادر دما و رطوبت */
	margin: 0 14px 14px 0 !important;
}
.phab-page .leaflet-control-zoom a {
	width: 40px;
	height: 40px;
	line-height: 40px;
	font-size: 19px;
	font-weight: 400;
	color: #1d3a24;
	background: transparent;
	border: none;
	border-bottom: 1px solid rgba(255, 255, 255, 0.5);
	transition: background .15s ease;
}
.phab-page .leaflet-control-zoom a:last-child { border-bottom: none; }
.phab-page .leaflet-control-zoom a:hover { background: rgba(255, 255, 255, 0.75); color: #1f6b34; }
.phab-page .leaflet-control-zoom a.leaflet-disabled { color: rgba(29, 58, 36, 0.3); background: transparent; }

/* ---------- کادر پایینی (bottom sheet) گیاهان هم‌زیست ---------- */
/* روی نقشه شناور است؛ سه حالت دارد: جمع (peek)، باز (expanded) و بسته (closed).
   ارتفاع حالت‌ها با جاوااسکریپت تنظیم و جابه‌جایی بین آن‌ها نرم انیمیت می‌شود. */
.phab-below {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 930;
	display: flex;
	flex-direction: column;
	min-height: 0;
	padding: 0 16px 14px;
	background: #fff;
	border-top: 1px solid #e3e8e4;
	border-radius: 18px 18px 0 0;
	box-shadow: 0 -10px 30px rgba(15, 40, 20, 0.16);
	overflow: hidden;
	transition: height .35s cubic-bezier(.4, 0, .2, 1), transform .35s cubic-bezier(.4, 0, .2, 1);
	will-change: height, transform;
}
.phab-below.is-dragging { transition: none; }
.phab-below.is-closed { transform: translateY(105%); box-shadow: none; }

/* سربرگ کادر: دستگیره کشیدن + فلش + ضربدر */
.phab-sheet-head {
	position: relative;
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 8px 0 4px;
	cursor: grab;
	touch-action: none; /* کشیدن کادر به جای اسکرول صفحه */
	user-select: none;
	-webkit-user-select: none;
}
.phab-below.is-dragging .phab-sheet-head { cursor: grabbing; }
.phab-sheet-grip {
	position: absolute;
	top: 4px;
	left: 50%;
	transform: translateX(-50%);
	width: 40px;
	height: 4px;
	border-radius: 999px;
	background: #d5ded7;
}
.phab-sheet-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 26px;
	margin-top: 6px;
	padding: 0;
	background: transparent;
	border: none;
	color: #2e7d32;
	cursor: pointer;
}
.phab-sheet-toggle svg { transition: transform .35s cubic-bezier(.4, 0, .2, 1); }
.phab-below.is-expanded .phab-sheet-toggle svg { transform: rotate(180deg); }

.phab-hint {
	flex: 0 0 auto;
	font-size: 13.5px;
	color: #35503b;
	background: #f2f8f3;
	border: 1px solid #dceadf;
	border-radius: 10px;
	padding: 9px 14px;
	margin-bottom: 10px;
}
.phab-side-title {
	flex: 0 0 auto;
	font-size: 15px;
	font-weight: 700;
	color: #1d3a24;
	margin: 2px 0 10px;
}
.phab-side-title:empty { display: none; }

/* لیست گیاهان هم‌زیست: در حالت جمع بدون اسکرول (نیم‌آیتم دیده می‌شود)،
   در حالت باز با اسکرول عمودی داخلی */
.phab-list {
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	padding-left: 4px;
	max-width: 100%;
}
.phab-below.is-expanded .phab-list {
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
}
.phab-item {
	display: flex;
	align-items: center;
	width: 100%;
	gap: 12px;
	padding: 10px 12px;
	margin-bottom: 8px;
	background: #fff;
	border: 1px solid #e2e8e3;
	border-radius: 12px;
}
.phab-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; }
.phab-item-body { min-width: 0; flex: 1; }
.phab-item-name { font-size: 13.5px; font-weight: 600; color: #222; margin-bottom: 6px; }
.phab-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.phab-item-link,
.phab-item-habitats {
	font-size: 12px;
	padding: 5px 12px;
	border-radius: 999px;
	border: 1px solid rgba(46, 125, 50, 0.45);
	background: #fff;
	color: #2e7d32;
	cursor: pointer;
	text-decoration: none;
	line-height: 1.5;
	transition: background .15s ease, color .15s ease;
}
.phab-item-link:hover,
.phab-item-habitats:hover { background: #2e7d32; color: #fff; }
.phab-empty, .phab-loading { padding: 14px; font-size: 13px; color: #777; }

/* موبایل */
@media (max-width: 782px) {
	.phab-topbar { top: 10px; right: 10px; left: 10px; gap: 8px; }
	.phab-title { order: 3; max-width: 100%; flex: 1 1 100%; font-size: 13px; padding: 8px 12px; }
	.phab-search-wrap { max-width: none; }
	.phab-below { padding: 0 12px 12px; }
	.phab-page .leaflet-control-zoom { margin: 0 10px 10px 0 !important; }
	.phab-page .leaflet-control-zoom a { width: 36px; height: 36px; line-height: 36px; }
	.phab-item img { width: 52px; height: 52px; }
}
