/* =====================================================================
   ویجت چت‌بات هوشمند سایت — سه مدل نمایش (شناور/تب‌کناری/نوار پایین)
   و سه تم (مدرن/مینیمال/تیره). با تمرکز ویژه بر ریسپانسیو‌بودن واقعی
   (رفع اشکال کلاسیک flexbox + واحدهای ویوپورت پویا برای موبایل).
   ===================================================================== */

:root {
	--noya-vh: 1vh; /* توسط جاوااسکریپت برای مرورگرهای بدون پشتیبانی dvh به‌روزرسانی می‌شود */
}

@media (max-width: 640px) {
	body.noya-chat-locked { overflow: hidden; }
}

.noya-chat-widget {
	--noya-chat-color: #4f46e5;
	--noya-chat-color-dark: #4338ca;
	--noya-bg: #ffffff;
	--noya-bg-soft: #f8fafc;
	--noya-text: #1f2937;
	--noya-text-soft: #64748b;
	--noya-border: #e5e7eb;
	--noya-bubble-bot-bg: #ffffff;
	--noya-bubble-bot-text: #1f2937;
	--noya-header-text: #ffffff;
	--noya-radius: 18px;
	--noya-shadow: 0 16px 48px rgba(17, 24, 39, .18);
	font-family: 'Vazirmatn', Tahoma, sans-serif;
	direction: rtl;
	box-sizing: border-box;
}
.noya-chat-widget *, .noya-chat-widget *::before, .noya-chat-widget *::after {
	box-sizing: border-box;
}

/* ---------- تم: مینیمال (تخت، تضاد بالا، بدون گرادیان) ---------- */
.noya-chat-widget.noya-theme-minimal {
	--noya-radius: 12px;
	--noya-shadow: 0 10px 30px rgba(17, 24, 39, .14);
}

/* ---------- تم: تیره ---------- */
.noya-chat-widget.noya-theme-dark {
	--noya-bg: #1e1e2e;
	--noya-bg-soft: #171723;
	--noya-text: #e5e7eb;
	--noya-text-soft: #9ca3af;
	--noya-border: #33334a;
	--noya-bubble-bot-bg: #2a2a3d;
	--noya-bubble-bot-text: #e5e7eb;
}

/* =====================================================================
   عناصر مشترک: حباب‌های پیام، پیشنهادها، محصولات، فرم رضایت، نوار ورودی
   ===================================================================== */

.noya-chat-messages {
	flex: 1 1 auto;
	min-height: 0; /* رفع اشکال معروف flexbox: بدون این خط، این ناحیه از اسکرول‌شدن سر باز می‌زند و نوار ارسال پیام را از صفحه بیرون می‌راند */
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 16px;
	background: var(--noya-bg-soft);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.noya-chat-bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 13.5px;
	line-height: 1.85;
	word-wrap: break-word;
	flex-shrink: 0;
}
.noya-chat-bubble-assistant {
	align-self: flex-start;
	background: var(--noya-bubble-bot-bg);
	border: 1px solid var(--noya-border);
	color: var(--noya-bubble-bot-text);
	border-start-start-radius: 4px;
}
.noya-chat-bubble-user {
	align-self: flex-end;
	background: var(--noya-chat-color);
	color: #fff;
	border-start-end-radius: 4px;
}

.noya-chat-typing { display: flex; gap: 4px; padding: 12px 16px; align-items: center; flex-shrink: 0; }
.noya-chat-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--noya-text-soft);
	animation: noya-chat-blink 1.2s infinite ease-in-out;
}
.noya-chat-typing span:nth-child(2) { animation-delay: .2s; }
.noya-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes noya-chat-blink {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-3px); }
}

.noya-chat-quickreplies { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 100%; flex-shrink: 0; }
.noya-chat-quickreply {
	background: var(--noya-bg);
	border: 1.5px solid var(--noya-chat-color);
	color: var(--noya-chat-color);
	border-radius: 20px;
	padding: 6px 14px;
	font-size: 12.5px;
	font-family: inherit;
	cursor: pointer;
	transition: background .15s, color .15s;
}
.noya-chat-quickreply:hover { background: var(--noya-chat-color); color: #fff; }

.noya-chat-products { display: flex; flex-direction: column; gap: 8px; align-self: flex-start; width: 100%; flex-shrink: 0; }
.noya-chat-product {
	display: flex;
	gap: 10px;
	background: var(--noya-bg);
	border: 1px solid var(--noya-border);
	border-radius: 12px;
	padding: 8px;
	text-decoration: none;
	color: inherit;
	transition: box-shadow .15s;
}
.noya-chat-product:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .1); }
.noya-chat-product img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--noya-bg-soft); }
.noya-chat-product-info { flex: 1; min-width: 0; }
.noya-chat-product-title { font-size: 12.5px; font-weight: 700; color: var(--noya-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noya-chat-product-price { font-size: 12.5px; color: var(--noya-chat-color); font-weight: 700; margin-top: 2px; }
.noya-chat-product-stock { font-size: 10.5px; margin-top: 2px; }
.noya-chat-product-stock.ok { color: #16a34a; }
.noya-chat-product-stock.no { color: #dc2626; }

.noya-chat-consent {
	align-self: stretch;
	background: var(--noya-bg);
	border: 1.5px dashed var(--noya-chat-color);
	border-radius: 12px;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 7px;
	flex-shrink: 0;
}
.noya-chat-consent-text { font-size: 12.5px; color: var(--noya-text-soft); margin: 0 0 2px; line-height: 1.7; }
.noya-chat-consent-input {
	border: 1px solid var(--noya-border);
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 13px;
	font-family: inherit;
	direction: rtl;
	background: var(--noya-bg);
	color: var(--noya-text);
}
.noya-chat-consent-actions { display: flex; gap: 8px; margin-top: 4px; }
.noya-chat-consent-submit, .noya-chat-consent-skip {
	flex: 1;
	border: 0;
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 12.5px;
	font-family: inherit;
	cursor: pointer;
}
.noya-chat-consent-submit { background: var(--noya-chat-color); color: #fff; font-weight: 700; }
.noya-chat-consent-skip { background: var(--noya-bg-soft); color: var(--noya-text-soft); }

.noya-chat-inputbar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	padding-bottom: max(10px, env(safe-area-inset-bottom));
	border-top: 1px solid var(--noya-border);
	background: var(--noya-bg);
	flex-shrink: 0; /* هرگز فشرده نشود؛ همیشه در پایین کادر باقی می‌ماند */
}
.noya-chat-input {
	flex: 1;
	min-width: 0;
	border: 1px solid var(--noya-border);
	border-radius: 22px;
	padding: 10px 16px;
	font-size: 13.5px;
	font-family: inherit;
	direction: rtl;
	outline: none;
	background: var(--noya-bg);
	color: var(--noya-text);
}
.noya-chat-input:focus { border-color: var(--noya-chat-color); }
.noya-chat-send {
	width: 40px;
	height: 40px;
	min-width: 40px;
	border-radius: 50%;
	background: var(--noya-chat-color);
	color: #fff;
	border: 0;
	cursor: pointer;
	flex-shrink: 0;
	font-size: 15px;
	transform: scaleX(-1);
}
.noya-chat-send:hover { filter: brightness(1.08); }
.noya-chat-send:disabled { opacity: .5; cursor: default; }

.noya-chat-header {
	background: linear-gradient(135deg, var(--noya-chat-color), var(--noya-chat-color-dark));
	color: var(--noya-header-text);
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}
.noya-theme-minimal .noya-chat-header { background: var(--noya-chat-color); }
.noya-chat-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	object-fit: cover;
	background: rgba(255, 255, 255, .25);
	flex-shrink: 0;
}
.noya-chat-avatar-fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 800;
	font-size: 16px;
}
.noya-chat-header-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.noya-chat-header-info strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noya-chat-status { font-size: 11.5px; opacity: .85; }
.noya-chat-status::before {
	content: '';
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	margin-inline-end: 5px;
}
.noya-chat-close {
	background: rgba(255, 255, 255, .18);
	border: 0;
	color: #fff;
	width: 30px;
	height: 30px;
	min-width: 30px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 13px;
	flex-shrink: 0;
}
.noya-chat-close:hover { background: rgba(255, 255, 255, .3); }

/* ساختار داخلی مشترک هر سه مدل: هدر + پیام‌ها (کشسان) + نوار ورودی (ثابت) */
.noya-chat-body {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 0;
	overflow: hidden;
}

/* =====================================================================
   مدل ۱: شناور (Bubble) — دکمه‌ی گرد در گوشه، پنجره‌ی شناور کنار آن
   ===================================================================== */

.noya-chat-widget.noya-model-bubble {
	position: fixed;
	bottom: max(20px, env(safe-area-inset-bottom));
	z-index: 999999;
}
.noya-chat-widget.noya-model-bubble.noya-chat-right { right: 20px; }
.noya-chat-widget.noya-model-bubble.noya-chat-left { left: 20px; }

.noya-bubble-launcher {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--noya-chat-color), var(--noya-chat-color-dark));
	border: 0;
	box-shadow: 0 8px 26px rgba(17, 24, 39, .28);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	transition: transform .18s ease;
}
.noya-theme-minimal .noya-bubble-launcher { background: var(--noya-chat-color); }
.noya-bubble-launcher:hover { transform: scale(1.06); }
.noya-bubble-launcher-icon { font-size: 27px; line-height: 1; }
.noya-model-bubble.is-open .noya-bubble-launcher { transform: scale(.92); }

.noya-chat-badge {
	position: absolute;
	top: -3px;
	inset-inline-end: -3px;
	background: #ef4444;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 20px;
	height: 20px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
	border: 2px solid var(--noya-bg);
}

.noya-bubble-panel {
	position: fixed;
	bottom: calc(20px + 62px + 14px);
	width: 372px;
	max-width: calc(100vw - 28px);
	height: min(600px, calc(100 * var(--noya-vh) - 140px));
	background: var(--noya-bg);
	border-radius: var(--noya-radius);
	box-shadow: var(--noya-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 999999;
	/* نمایش/پنهانی بر پایه‌ی کلاس (نه ویژگی hidden) تا هیچ‌گاه با قوانین display این کلاس تداخل نکند */
	opacity: 0;
	transform: translateY(12px) scale(.98);
	pointer-events: none;
	visibility: hidden;
	transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}
.noya-model-bubble.is-open .noya-bubble-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
	visibility: visible;
	transition: opacity .18s ease, transform .18s ease;
}
@supports (height: 100dvh) {
	.noya-bubble-panel { height: min(600px, calc(100dvh - 140px)); }
}
.noya-chat-widget.noya-chat-right .noya-bubble-panel { right: 20px; }
.noya-chat-widget.noya-chat-left .noya-bubble-panel { left: 20px; }

/* =====================================================================
   مدل ۲: تب کناری (Side Tab) — زبانه‌ی عمودی چسبیده به لبه، پنل کشویی
   ===================================================================== */

.noya-chat-widget.noya-model-side_tab {
	position: fixed;
	inset: 0;
	z-index: 999999;
	pointer-events: none; /* فقط عناصر تعاملی داخل آن کلیک‌پذیرند؛ خود این پوسته اندازه‌ای ندارد */
}

.noya-tab-launcher {
	position: fixed;
	top: 50%;
	transform: translateY(-50%);
	pointer-events: auto;
	writing-mode: vertical-rl;
	background: linear-gradient(180deg, var(--noya-chat-color), var(--noya-chat-color-dark));
	color: #fff;
	border: 0;
	border-radius: 14px 0 0 14px;
	padding: 18px 10px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 8px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 700;
	box-shadow: -4px 4px 20px rgba(17, 24, 39, .2);
}
.noya-theme-minimal .noya-tab-launcher { background: var(--noya-chat-color); }
.noya-chat-widget.noya-model-side_tab.noya-chat-right .noya-tab-launcher { right: 0; }
.noya-chat-widget.noya-model-side_tab.noya-chat-left .noya-tab-launcher { left: 0; border-radius: 0 14px 14px 0; box-shadow: 4px 4px 20px rgba(17, 24, 39, .2); }
.noya-tab-launcher-icon { font-size: 18px; writing-mode: horizontal-tb; }
.noya-tab-launcher .noya-chat-badge { top: -6px; inset-inline-end: 50%; transform: translateX(50%); writing-mode: horizontal-tb; }

.noya-tab-panel {
	position: fixed;
	pointer-events: auto;
	top: 0;
	bottom: 0;
	width: 380px;
	max-width: 92vw;
	height: 100%;
	background: var(--noya-bg);
	box-shadow: var(--noya-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: transform .22s ease;
}
.noya-chat-widget.noya-model-side_tab.noya-chat-right .noya-tab-panel { right: 0; border-radius: 18px 0 0 18px; transform: translateX(100%); }
.noya-chat-widget.noya-model-side_tab.noya-chat-left .noya-tab-panel { left: 0; border-radius: 0 18px 18px 0; transform: translateX(-100%); }
.noya-model-side_tab.is-open .noya-tab-panel { transform: translateX(0); }

/* =====================================================================
   مدل ۳: نوار پایین (Bottom Dock) — نوار داکِ پایین صفحه، بازشونده به‌بالا
   ===================================================================== */

.noya-chat-widget.noya-model-bottom_dock {
	position: fixed;
	right: 0;
	left: 0;
	bottom: 0;
	z-index: 999999;
	display: flex;
	justify-content: center;
	pointer-events: none;
}
.noya-chat-widget.noya-model-bottom_dock.noya-chat-right { justify-content: flex-end; }
.noya-chat-widget.noya-model-bottom_dock.noya-chat-left { justify-content: flex-start; }

.noya-dock-launcher {
	pointer-events: auto;
	margin: 0 16px max(16px, env(safe-area-inset-bottom));
	background: var(--noya-bg);
	border: 1px solid var(--noya-border);
	border-radius: 999px;
	padding: 8px 18px 8px 8px;
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	box-shadow: 0 8px 26px rgba(17, 24, 39, .18);
	font-family: inherit;
	max-width: calc(100vw - 32px);
	position: relative;
}
.noya-dock-launcher-icon {
	width: 36px;
	height: 36px;
	min-width: 36px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--noya-chat-color), var(--noya-chat-color-dark));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 17px;
}
.noya-dock-launcher-text { font-size: 13px; font-weight: 700; color: var(--noya-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noya-dock-launcher .noya-chat-badge { top: -2px; inset-inline-end: -2px; }

.noya-dock-panel {
	pointer-events: auto;
	position: fixed;
	right: 0;
	left: 0;
	bottom: 0;
	margin: 0 auto;
	width: 100%;
	max-width: 420px;
	height: min(600px, calc(100 * var(--noya-vh) - 40px));
	background: var(--noya-bg);
	border-radius: var(--noya-radius) var(--noya-radius) 0 0;
	box-shadow: var(--noya-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 999999;
	transition: transform .22s ease;
	transform: translateY(100%);
}
@supports (height: 100dvh) {
	.noya-dock-panel { height: min(600px, calc(100dvh - 40px)); }
}
.noya-model-bottom_dock.is-open .noya-dock-panel { transform: translateY(0); }
.noya-model-bottom_dock.noya-chat-right .noya-dock-panel { margin-inline-end: 16px; margin-inline-start: auto; }
.noya-model-bottom_dock.noya-chat-left .noya-dock-panel { margin-inline-start: 16px; margin-inline-end: auto; }

/* =====================================================================
   پس‌زمینه‌ی تیره‌ی پشت پنل هنگام بازبودن (برای تب کناری و داک پایین)
   ===================================================================== */
.noya-chat-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, .35);
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s ease;
	z-index: 999998;
}
.noya-chat-overlay.is-visible { opacity: 1; pointer-events: auto; }

/* =====================================================================
   حالت موبایل: تمام‌صفحه برای هر سه مدل (پایدارترین رفتار ریسپانسیو)
   ===================================================================== */
@media (max-width: 640px) {
	.noya-bubble-panel,
	.noya-tab-panel,
	.noya-dock-panel {
		position: fixed;
		inset: 0;
		top: env(safe-area-inset-top);
		width: 100%;
		max-width: 100%;
		height: calc(100 * var(--noya-vh) - env(safe-area-inset-top));
		border-radius: 0;
		margin: 0;
		right: 0;
		left: 0;
		bottom: 0;
	}
	@supports (height: 100dvh) {
		.noya-bubble-panel, .noya-tab-panel, .noya-dock-panel {
			height: calc(100dvh - env(safe-area-inset-top));
		}
	}
	.noya-tab-panel { transform: translateX(100%); }
	.noya-chat-widget.noya-chat-left .noya-tab-panel { transform: translateX(-100%); }
	.noya-model-side_tab.is-open .noya-tab-panel { transform: translateX(0); }

	.noya-dock-panel { transform: translateY(100%); }
	.noya-model-bottom_dock.is-open .noya-dock-panel { transform: translateY(0); }

	.noya-tab-launcher { padding: 14px 8px; }
	.noya-dock-launcher { margin: 0 10px max(10px, env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
	.noya-chat-bubble { max-width: 88%; }
}
