/* چت‌بات فروشگاه: همه قاعده‌ها زیر #dgf-chat تا پوسته‌های دیگر دست نزنند. رنگ و قلم و گردی از «طراحی و متن‌ها»
   (--dgf-*) که پیش از این فایل روی همین شناسه چاپ می‌شود؛ پیش‌فرض‌ها با :where تا تنظیم مدیر برنده بماند. */
:where(#dgf-chat) {
	--dgf-accent: #1f6feb;
	--dgf-font: inherit;
	--dgf-r-box: 16px;
	--dgf-r-btn: 999px;
}
#dgf-chat {
	--c-bg: #fff;
	--c-fg: #1d2330;
	--c-mut: #6b7280;
	--c-soft: rgba(128, 128, 128, .12);
	--c-line: rgba(128, 128, 128, .28);
	position: fixed;
	bottom: 20px;
	z-index: 99990;
	font-family: var(--dgf-font);
	font-size: 15px;
	line-height: 1.7;
	color: var(--c-fg);
	direction: rtl;
	text-align: right;
}
#dgf-chat.dgf-chat--left { left: 20px; }
#dgf-chat.dgf-chat--right { right: 20px; }
#dgf-chat *, #dgf-chat *::before, #dgf-chat *::after { box-sizing: border-box; }
#dgf-chat[hidden], #dgf-chat [hidden] { display: none !important; }
/* تیره فقط وقتی خود سایت تیره است (حالت شب DIGIFORGE)، نه به پیروی از سیستم: پنجره تیره روی سایت روشن ناجور است. */
body.dgf-dark #dgf-chat { --c-bg: #171b22; --c-fg: #e8eaee; --c-mut: #9aa3b2; }

#dgf-chat .dgf-chat__fab {
	position: relative;
	display: grid;
	place-items: center;
	width: 58px;
	height: 58px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--dgf-accent);
	color: #fff;
	box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
	cursor: pointer;
	transition: transform .18s ease;
}
#dgf-chat .dgf-chat__fab:hover { transform: translateY(-2px); }
#dgf-chat .dgf-chat__fab:focus-visible, #dgf-chat button:focus-visible, #dgf-chat a:focus-visible, #dgf-chat textarea:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--dgf-accent) 55%, transparent);
	outline-offset: 2px;
}
#dgf-chat .dgf-chat__fab svg { width: 26px; height: 26px; fill: currentColor; }
#dgf-chat.is-open .dgf-chat__fab { display: none; }
#dgf-chat .dgf-chat__badge {
	position: absolute;
	top: -4px;
	inset-inline-end: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: #e5484d;
	color: #fff;
	font-size: 12px;
	line-height: 22px;
	text-align: center;
}

#dgf-chat .dgf-chat__panel {
	display: flex;
	flex-direction: column;
	width: min(380px, calc(100vw - 32px));
	height: min(600px, calc(100vh - 40px));
	background: var(--c-bg);
	border: 1px solid var(--c-line);
	border-radius: var(--dgf-r-box);
	box-shadow: 0 18px 48px rgba(0, 0, 0, .24);
	overflow: hidden;
}
#dgf-chat .dgf-chat__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 12px 16px;
	background: var(--dgf-accent);
	color: #fff;
}
#dgf-chat .dgf-chat__title { display: flex; flex-direction: column; line-height: 1.4; }
#dgf-chat .dgf-chat__title small { opacity: .85; font-size: 12px; }
#dgf-chat .dgf-chat__close {
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .16);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
#dgf-chat .dgf-chat__list {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px;
	overflow-y: auto;
	overscroll-behavior: contain;
}
#dgf-chat .dgf-chat__msg { display: flex; flex-direction: column; gap: 6px; max-width: 86%; align-self: flex-start; }
#dgf-chat .dgf-chat__msg--visitor { align-self: flex-end; align-items: flex-end; }
#dgf-chat .dgf-chat__bubble {
	margin: 0;
	padding: 8px 12px;
	border-radius: 14px;
	background: var(--c-soft);
	white-space: pre-line;
	overflow-wrap: anywhere;
}
#dgf-chat .dgf-chat__msg--visitor .dgf-chat__bubble { background: var(--dgf-accent); color: #fff; }
#dgf-chat .dgf-chat__msg--staff .dgf-chat__bubble { background: color-mix(in srgb, var(--dgf-accent) 16%, var(--c-bg)); border: 1px solid color-mix(in srgb, var(--dgf-accent) 35%, transparent); }
#dgf-chat .dgf-chat__acts { display: flex; flex-wrap: wrap; gap: 6px; }
#dgf-chat .dgf-chat__act {
	display: inline-flex;
	align-items: center;
	min-height: 36px;
	margin: 0;
	padding: 4px 14px;
	border: 1px solid color-mix(in srgb, var(--dgf-accent) 45%, transparent);
	border-radius: var(--dgf-r-btn);
	background: transparent;
	color: var(--dgf-accent);
	font: inherit;
	font-size: 14px;
	text-decoration: none;
	cursor: pointer;
}
#dgf-chat .dgf-chat__act:hover { background: color-mix(in srgb, var(--dgf-accent) 10%, transparent); }
#dgf-chat .dgf-chat__cards { display: flex; flex-direction: column; gap: 6px; width: 100%; }
#dgf-chat .dgf-chat__card {
	display: flex;
	gap: 10px;
	align-items: center;
	padding: 6px;
	border: 1px solid var(--c-line);
	border-radius: 12px;
	color: inherit;
	text-decoration: none;
}
#dgf-chat .dgf-chat__card:hover { border-color: var(--dgf-accent); }
#dgf-chat .dgf-chat__card img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; }
#dgf-chat .dgf-chat__cardtext { display: flex; flex-direction: column; line-height: 1.5; min-width: 0; }
#dgf-chat .dgf-chat__cardtext b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dgf-chat .dgf-chat__cardtext span { color: var(--c-mut); font-size: 13px; }
#dgf-chat .dgf-chat__form { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--c-line); }
#dgf-chat .dgf-chat__input {
	flex: 1;
	min-height: 42px;
	max-height: 120px;
	margin: 0;
	padding: 9px 12px;
	border: 1px solid var(--c-line);
	border-radius: 12px;
	background: var(--c-bg);
	color: inherit;
	font: inherit;
	font-size: 16px; /* زیر ۱۶ پیکسل آیفون صفحه را بزرگ می‌کند */
	resize: none;
}
#dgf-chat .dgf-chat__send {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--dgf-accent);
	color: #fff;
	cursor: pointer;
}
#dgf-chat .dgf-chat__send svg { width: 20px; height: 20px; fill: currentColor; transform: scaleX(-1); }
#dgf-chat .dgf-chat__send:disabled { opacity: .55; cursor: wait; }

@media (max-width: 520px) {
	#dgf-chat.is-open { inset: 0; bottom: 0; }
	#dgf-chat.is-open .dgf-chat__panel { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
	#dgf-chat:not(.is-open) { bottom: 16px; }
	#dgf-chat.dgf-chat--left:not(.is-open) { left: 16px; }
	#dgf-chat.dgf-chat--right:not(.is-open) { right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
	#dgf-chat .dgf-chat__fab { transition: none; }
}
