/* ===== فونت داخلی Vazirmatn (بدون CDN) ===== */
@font-face {
	font-family: 'Vazirmatn';
	src: url('../fonts/Vazirmatn-FD-Regular.woff2') format('woff2');
	font-weight: 400;
	font-display: swap;
}
@font-face {
	font-family: 'Vazirmatn';
	src: url('../fonts/Vazirmatn-FD-Medium.woff2') format('woff2');
	font-weight: 500;
	font-display: swap;
}
@font-face {
	font-family: 'Vazirmatn';
	src: url('../fonts/Vazirmatn-FD-SemiBold.woff2') format('woff2');
	font-weight: 600;
	font-display: swap;
}

/* اصلاح مهم: ویژگی hidden باید بر نمایش غلبه کند (تا ویجت در حالت عادی بسته باشد). */
#aisb-widget [hidden] {
	display: none !important;
}

.aisb-widget {
	position: fixed;
	bottom: 24px;
	z-index: 99999;
	font-family: 'Vazirmatn', Tahoma, sans-serif;
	direction: rtl;
	text-align: right;
	--aisb-primary: #4f46e5;
}
.aisb-widget.aisb-pos-bottom-right { right: 24px; left: auto; }
.aisb-widget.aisb-pos-bottom-left { left: 24px; right: auto; }
.aisb-widget *,
.aisb-widget *::before,
.aisb-widget *::after { box-sizing: border-box; }

/* ---- دکمه بازکننده ---- */
.aisb-chat-launcher {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--aisb-primary);
	background: linear-gradient(135deg, var(--aisb-primary), #312e81);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
	position: relative;
	transition: transform 0.15s ease;
}
.aisb-chat-launcher:hover { transform: scale(1.05); }
.aisb-chat-launcher svg { width: 28px; height: 28px; }
.aisb-launcher__close { display: none; }
.aisb-widget.is-open .aisb-launcher__icon { display: none; }
.aisb-widget.is-open .aisb-launcher__close { display: flex; }
.aisb-widget.is-open .aisb-chat-launcher { background: #0f172a; box-shadow: none; }

.aisb-launcher__label {
	position: absolute;
	bottom: 68px;
	right: 0;
	background: #fff;
	border: 1px solid #e2e8f0;
	color: #0f172a;
	padding: 8px 14px;
	border-radius: 12px;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

/* ---- جعبه چت ---- */
.aisb-chatbox {
	position: absolute;
	bottom: 78px;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 500px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
	display: flex;
	flex-direction: column;
	border: 1px solid #e2e8f0;
}
.aisb-widget.aisb-pos-bottom-right .aisb-chatbox { right: 0; }
.aisb-widget.aisb-pos-bottom-left .aisb-chatbox { left: 0; }

.aisb-chatbox__header {
	background: var(--aisb-primary);
	background: linear-gradient(135deg, var(--aisb-primary), #312e81);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 12px;
}
.aisb-chatbox__avatar {
	width: 40px;
	height: 40px;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;
}
.aisb-chatbox__avatar svg { width: 22px; height: 22px; }
.aisb-chatbox__meta { flex: 1; }
.aisb-chatbox__meta strong { font-size: 15px; display: block; }
.aisb-online { font-size: 12px; color: #d9f99d; display: flex; align-items: center; gap: 6px; }
.aisb-online__dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
.aisb-chatbox__close {
	background: transparent;
	border: none;
	color: #fff;
	cursor: pointer;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
}
.aisb-chatbox__close:hover { background: rgba(255, 255, 255, 0.15); }
.aisb-chatbox__close svg { width: 20px; height: 20px; }

.aisb-chatbox__body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f8fafc;
}
.aisb-chatbox__body::-webkit-scrollbar { width: 6px; }
.aisb-chatbox__body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }

.aisb-msg { display: flex; }
.aisb-msg--bot { justify-content: flex-start; }
.aisb-msg--user { justify-content: flex-end; }
.aisb-msg__bubble {
	max-width: 82%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.7;
	word-break: break-word;
	white-space: pre-wrap;
}
.aisb-msg--bot .aisb-msg__bubble {
	background: #fff;
	border: 1px solid #e2e8f0;
	color: #1e293b;
	border-bottom-right-radius: 4px;
}
.aisb-msg--user .aisb-msg__bubble {
	background: var(--aisb-primary);
	color: #fff;
	border-bottom-left-radius: 4px;
}
.aisb-msg--error .aisb-msg__bubble {
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
}

.aisb-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.aisb-typing span {
	width: 7px;
	height: 7px;
	background: #94a3b8;
	border-radius: 50%;
	animation: aisb-blink 1.2s infinite both;
}
.aisb-typing span:nth-child(2) { animation-delay: 0.2s; }
.aisb-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aisb-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* ---- فرم قبل از چت ---- */
.aisb-prechat {
	flex: 1;
	overflow-y: auto;
	padding: 20px 18px;
	background: #f8fafc;
	display: flex;
	align-items: flex-start;
	justify-content: center;
}
.aisb-prechat__card {
	width: 100%;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 16px;
	padding: 22px 20px;
	box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}
.aisb-prechat__head { text-align: center; margin-bottom: 20px; }
.aisb-prechat__icon {
	width: 52px;
	height: 52px;
	margin: 0 auto 10px;
	border-radius: 14px;
	background: linear-gradient(135deg, var(--aisb-primary), #312e81);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
}
.aisb-prechat__icon svg { width: 26px; height: 26px; }
.aisb-prechat__head strong { display: block; font-size: 16px; font-weight: 700; color: #0f172a; }
.aisb-prechat__head p { margin: 6px 0 0; font-size: 12.5px; color: #64748b; line-height: 1.7; }
.aisb-prechat__field { display: block; margin-bottom: 14px; }
.aisb-prechat__label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: #334155;
	margin-bottom: 6px;
}
.aisb-req { color: #dc2626; font-weight: 700; }
.aisb-prechat__input-wrap {
	position: relative;
	display: flex;
	align-items: center;
}
.aisb-prechat__input-icon {
	position: absolute;
	right: 12px;
	color: #94a3b8;
	display: flex;
	align-items: center;
	pointer-events: none;
}
.aisb-prechat__input-icon svg { width: 17px; height: 17px; }
.aisb-prechat__input-wrap input {
	width: 100%;
	font-family: 'Vazirmatn', Tahoma, sans-serif;
	font-size: 14px;
	padding: 11px 12px 11px 38px;
	border: 1px solid #cbd5e1;
	border-radius: 10px;
	background: #fff;
	color: #0f172a;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.aisb-prechat__input-wrap input::placeholder { color: #94a3b8; }
.aisb-prechat__input-wrap input:focus {
	outline: none;
	border-color: var(--aisb-primary);
	box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.aisb-prechat__submit {
	width: 100%;
	font-family: 'Vazirmatn', Tahoma, sans-serif;
	font-size: 14px;
	font-weight: 700;
	padding: 12px;
	margin-top: 4px;
	border: none;
	border-radius: 10px;
	background: var(--aisb-primary);
	color: #fff;
	cursor: pointer;
	transition: filter 0.15s ease, transform 0.1s ease;
}
.aisb-prechat__submit:hover { filter: brightness(1.08); }
.aisb-prechat__submit:active { transform: scale(0.99); }
.aisb-prechat__foot { margin: 12px 0 0; text-align: center; font-size: 11.5px; color: #94a3b8; }

.aisb-chatbox__footer {
	display: flex;
	gap: 8px;
	padding: 12px;
	background: #fff;
	border-top: 1px solid #e2e8f0;
	align-items: flex-end;
}
.aisb-chatbox__footer textarea {
	flex: 1;
	font-family: 'Vazirmatn', Tahoma, sans-serif;
	font-size: 14px;
	border: 1px solid #cbd5e1;
	border-radius: 10px;
	padding: 10px 12px;
	resize: none;
	max-height: 100px;
	min-height: 42px;
	color: #0f172a;
}
.aisb-chatbox__footer textarea:focus { outline: none; border-color: var(--aisb-primary); }
.aisb-send {
	width: 44px;
	height: 44px;
	flex: none;
	border: none;
	border-radius: 10px;
	background: var(--aisb-primary);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: filter 0.15s ease;
}
.aisb-send:hover { filter: brightness(1.1); }
.aisb-send[disabled] { opacity: 0.6; cursor: not-allowed; }
.aisb-send svg { width: 20px; height: 20px; }

@media (max-width: 420px) {
	.aisb-widget.aisb-pos-bottom-right { right: 12px; }
	.aisb-widget.aisb-pos-bottom-left { left: 12px; }
}
