/* دستیار هوشمند زرین آهن — ویجت گفتگو */

.zaia-root {
	--zaia-primary: #1f3a4d;
	--zaia-accent: #c07c2c;
	--zaia-surface: #ffffff;
	--zaia-muted: #f2f4f6;
	--zaia-line: #dbe1e6;
	--zaia-text: #1b232a;
	--zaia-text-soft: #5d6a75;
	--zaia-radius: 6px;

	position: fixed;
	bottom: 20px;
	z-index: 99990;
	font-family: inherit;
	line-height: 1.8;
	color: var(--zaia-text);
	direction: rtl;
}

.zaia-root.zaia-pos-left {
	left: 20px;
}

.zaia-root.zaia-pos-right {
	right: 20px;
}

.zaia-root *,
.zaia-root *::before,
.zaia-root *::after {
	box-sizing: border-box;
}

/* دکمه باز کردن */

.zaia-launcher {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 11px 16px 11px 14px;
	border: 0;
	border-radius: var(--zaia-radius);
	background: var(--zaia-primary);
	color: #fff;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(20, 32, 42, 0.28);
	border-bottom: 3px solid var(--zaia-accent);
}

.zaia-launcher:hover {
	filter: brightness(1.08);
}

.zaia-launcher:focus-visible {
	outline: 3px solid var(--zaia-accent);
	outline-offset: 2px;
}

.zaia-launcher svg {
	width: 20px;
	height: 20px;
	flex: none;
}

.zaia-root.is-open .zaia-launcher {
	display: none;
}

/* پنجره گفتگو */

.zaia-panel {
	display: none;
	flex-direction: column;
	width: 370px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 100px);
	background: var(--zaia-surface);
	border: 1px solid var(--zaia-line);
	border-radius: var(--zaia-radius);
	overflow: hidden;
	box-shadow: 0 18px 48px rgba(20, 32, 42, 0.24);
}

.zaia-root.is-open .zaia-panel {
	display: flex;
}

.zaia-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 13px 15px;
	background: var(--zaia-primary);
	color: #fff;
	border-bottom: 3px solid var(--zaia-accent);
}

.zaia-title {
	font-size: 15px;
	font-weight: 700;
	margin: 0;
}

.zaia-status {
	display: block;
	font-size: 12px;
	font-weight: 400;
	opacity: 0.85;
}

.zaia-header-actions {
	display: flex;
	gap: 4px;
}

.zaia-icon-btn {
	width: 30px;
	height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.28);
	border-radius: 4px;
	color: #fff;
	cursor: pointer;
	padding: 0;
}

.zaia-icon-btn:hover {
	background: rgba(255, 255, 255, 0.14);
}

.zaia-icon-btn:focus-visible {
	outline: 2px solid var(--zaia-accent);
	outline-offset: 1px;
}

.zaia-icon-btn svg {
	width: 16px;
	height: 16px;
}

/* پیام‌ها */

.zaia-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px;
	background: var(--zaia-muted);
	display: flex;
	flex-direction: column;
	gap: 10px;
	overscroll-behavior: contain;
}

.zaia-msg {
	max-width: 86%;
	padding: 10px 13px;
	border-radius: var(--zaia-radius);
	font-size: 14px;
	white-space: normal;
	word-wrap: break-word;
}

.zaia-msg a {
	color: inherit;
	text-decoration: underline;
}

.zaia-msg-bot {
	align-self: flex-start;
	background: var(--zaia-surface);
	border: 1px solid var(--zaia-line);
	border-right: 3px solid var(--zaia-accent);
}

.zaia-msg-user {
	align-self: flex-end;
	background: var(--zaia-primary);
	color: #fff;
}

.zaia-msg-error {
	align-self: center;
	background: #fdecec;
	border: 1px solid #f3bcbc;
	color: #8a2020;
	font-size: 13px;
	max-width: 100%;
}

/* نشانگر نوشتن */

.zaia-typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 12px 14px;
	background: var(--zaia-surface);
	border: 1px solid var(--zaia-line);
	border-radius: var(--zaia-radius);
}

.zaia-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--zaia-text-soft);
	animation: zaia-bounce 1.1s infinite ease-in-out;
}

.zaia-typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.zaia-typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes zaia-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
	30% { transform: translateY(-4px); opacity: 1; }
}

/* دکمه‌های پیشنهادی */

.zaia-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 14px 0;
	background: var(--zaia-muted);
}

.zaia-quick button {
	background: var(--zaia-surface);
	border: 1px solid var(--zaia-line);
	border-radius: var(--zaia-radius);
	padding: 6px 11px;
	font: inherit;
	font-size: 13px;
	color: var(--zaia-primary);
	cursor: pointer;
}

.zaia-quick button:hover {
	border-color: var(--zaia-accent);
}

.zaia-quick button:focus-visible {
	outline: 2px solid var(--zaia-accent);
	outline-offset: 1px;
}

/* نوار ورودی */

.zaia-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 11px 13px;
	background: var(--zaia-surface);
	border-top: 1px solid var(--zaia-line);
}

.zaia-input {
	flex: 1;
	resize: none;
	max-height: 110px;
	min-height: 42px;
	padding: 10px 12px;
	border: 1px solid var(--zaia-line);
	border-radius: var(--zaia-radius);
	font: inherit;
	font-size: 14px;
	line-height: 1.7;
	color: var(--zaia-text);
	background: #fff;
}

.zaia-input:focus {
	outline: none;
	border-color: var(--zaia-primary);
}

.zaia-send {
	flex: none;
	height: 42px;
	padding: 0 16px;
	border: 0;
	border-radius: var(--zaia-radius);
	background: var(--zaia-primary);
	color: #fff;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.zaia-send[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

.zaia-send:focus-visible {
	outline: 3px solid var(--zaia-accent);
	outline-offset: 2px;
}

.zaia-foot {
	padding: 0 14px 9px;
	background: var(--zaia-surface);
	font-size: 11px;
	color: var(--zaia-text-soft);
	text-align: center;
}

/* موبایل */

@media (max-width: 480px) {
	.zaia-root {
		bottom: 14px;
	}

	.zaia-root.zaia-pos-left {
		left: 14px;
	}

	.zaia-root.zaia-pos-right {
		right: 14px;
	}

	.zaia-root.is-open {
		inset: 0;
		bottom: 0;
	}

	.zaia-panel {
		width: 100vw;
		max-width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		border: 0;
		border-radius: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.zaia-typing span {
		animation: none;
	}
}
