/* ==========================================================================
   ویجت چت زنده - طراحی مدرن + ریسپانسیو کامل + حالت تاریک
   متغیرهای رنگی از تنظیمات ادمین (پالت رنگی) تزریق می‌شوند.
   این بلاک با اولویت بالا نوشته شده تا با استایل‌های قالب سایت تداخل نکند.
   ========================================================================== */

#wcs-chat-widget, #wcs-chat-widget * {
	box-sizing: border-box !important;
	margin: 0;
	padding: 0;
	line-height: 1.6;
}
#wcs-chat-widget button,
#wcs-chat-widget input,
#wcs-chat-widget textarea,
#wcs-chat-widget select {
	float: none !important;
	position: static !important;
	-webkit-appearance: none;
	appearance: none;
	font-family: inherit;
}

#wcs-chat-widget {
	position: fixed !important;
	z-index: 2147483000 !important;
	bottom: 22px !important;
	font-family: var(--wcs-font-family, -apple-system, BlinkMacSystemFont, "Vazirmatn", Tahoma, sans-serif) !important;
	direction: rtl;
	font-size: 14px;
}
#wcs-chat-widget.wcs-position-bottom-right { right: 22px !important; left: auto !important; }
#wcs-chat-widget.wcs-position-bottom-left { left: 22px !important; right: auto !important; }

/* --- دکمه شناور --- */
#wcs-toggle-btn {
	width: 60px; height: 60px; border-radius: 50%; border: none;
	position: relative !important;
	background: linear-gradient(135deg, var(--wcs-primary, #6366f1), var(--wcs-secondary, #8b5cf6));
	color: #fff !important; cursor: pointer;
	box-shadow: 0 8px 24px -6px rgba(99,102,241,.55);
	position: relative;
	display: flex; align-items: center; justify-content: center;
	transition: transform .2s ease;
	animation: wcs-pulse 2.6s infinite;
}
#wcs-toggle-btn:hover { transform: scale(1.06); }
@keyframes wcs-pulse {
	0% { box-shadow: 0 8px 24px -6px rgba(99,102,241,.55), 0 0 0 0 rgba(99,102,241,.4); }
	70% { box-shadow: 0 8px 24px -6px rgba(99,102,241,.55), 0 0 0 13px rgba(99,102,241,0); }
	100% { box-shadow: 0 8px 24px -6px rgba(99,102,241,.55), 0 0 0 0 rgba(99,102,241,0); }
}

#wcs-toggle-btn .wcs-toggle-icon-open,
#wcs-toggle-btn .wcs-toggle-icon-close {
	position: absolute; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
	transition: opacity .15s, transform .15s;
}
#wcs-toggle-btn .wcs-toggle-icon-open svg,
#wcs-toggle-btn .wcs-toggle-icon-close svg { width: 100%; height: 100%; color: #fff; }
#wcs-toggle-btn .wcs-toggle-icon-img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
#wcs-toggle-btn .wcs-toggle-icon-close { opacity: 0; transform: scale(.6) rotate(-45deg); }
#wcs-chat-widget.wcs-is-open #wcs-toggle-btn .wcs-toggle-icon-open { opacity: 0; transform: scale(.6) rotate(45deg); }
#wcs-chat-widget.wcs-is-open #wcs-toggle-btn .wcs-toggle-icon-close { opacity: 1; transform: scale(1) rotate(0); }

.wcs-badge {
	position: absolute; top: -3px; left: -3px; background: #ef4444; color: #fff !important;
	border-radius: 50%; font-size: 10px; min-width: 18px; height: 18px; line-height: 18px;
	text-align: center; border: 2px solid #fff; font-weight: 700;
}

/* --- پنجره چت (ارتفاع ثابت و جمع‌وجور) --- */
#wcs-chat-window {
	width: 366px; max-width: calc(100vw - 44px);
	height: 500px; max-height: 80vh;
	background: var(--wcs-bg, #fff);
	border-radius: 20px;
	box-shadow: 0 20px 54px -14px rgba(20,20,43,.4), 0 2px 8px rgba(20,20,43,.06);
	position: absolute; bottom: 74px; right: 0;
	display: flex; flex-direction: column;
	overflow: hidden;
	animation: wcs-window-in .2s ease;
	border: 1px solid rgba(0,0,0,.05);
}
@keyframes wcs-window-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
#wcs-chat-widget.wcs-position-bottom-left #wcs-chat-window { right: auto; left: 0; }
.wcs-hidden { display: none !important; }

/* --- هدر --- */
/* --- هدر (فاصله‌گذاری واضح، بدون تداخل عناصر) --- */
.wcs-header {
	background: linear-gradient(135deg, var(--wcs-primary, #6366f1), var(--wcs-secondary, #8b5cf6));
	color: #fff !important; padding: 18px !important;
	display: flex; justify-content: space-between; align-items: flex-start; flex-shrink: 0;
	min-height: 64px;
}
.wcs-header-info { display: flex; flex-direction: column; gap: 7px; padding-top: 2px; }
.wcs-header-title { font-weight: 800; font-size: 15px; color: #fff !important; line-height: 1.3; }
.wcs-online-pill { font-size: 10px; padding: 3px 10px; border-radius: 20px; width: fit-content; font-weight: 700; line-height: 1.4; }
.wcs-online-pill.wcs-online { background: rgba(34,197,94,.28); color: #dcfce7 !important; }
.wcs-online-pill.wcs-offline { background: rgba(255,255,255,.2); color: #fee2e2 !important; }
.wcs-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.wcs-header-actions button {
	background: rgba(255,255,255,.16); border: none; color: #fff !important; border-radius: 10px;
	width: 32px; height: 32px; cursor: pointer; display: flex; align-items: center; justify-content: center;
	transition: background .15s; flex-shrink: 0;
}
.wcs-header-actions button svg { width: 15px; height: 15px; }
.wcs-header-actions button:hover { background: rgba(255,255,255,.32); }
#wcs-new-chat-btn { display: none; }

.wcs-panel { flex: 1; display: flex; flex-direction: column; padding: 18px !important; overflow-y: auto; background: var(--wcs-bg, #fff); min-height: 0; }
.wcs-welcome-text { color: var(--wcs-text, #1f2937) !important; font-size: 13.5px; margin-bottom: 14px !important; line-height: 1.7 !important; }

.wcs-prechat-panel { display: flex; flex-direction: column; }
.wcs-prechat-inner { display: flex; flex-direction: column; }
.wcs-prechat-footer {
	flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 6px;
	font-size: 11px; color: #9ca3af !important; padding-top: 14px; margin-top: auto;
	border-top: 1px dashed #eef0f4;
}
.wcs-footer-dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; flex-shrink: 0; }

#wcs-prechat-form input, #wcs-prechat-form textarea, #wcs-message-text {
	border: 1.5px solid #e5e7eb !important; border-radius: 12px !important; padding: 11px 14px !important;
	margin-bottom: 10px !important; font-size: 13px !important; font-family: inherit !important; resize: none;
	background: #f9fafb !important; color: var(--wcs-text, #1f2937) !important;
	width: 100% !important; transition: all .15s; display: block;
}
#wcs-prechat-form input:focus, #wcs-prechat-form textarea:focus, #wcs-message-text:focus {
	outline: none !important; border-color: var(--wcs-primary, #6366f1) !important; background: var(--wcs-bg, #fff) !important;
	box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
#wcs-prechat-form textarea { min-height: 64px; }
#wcs-start-chat-btn { margin-top: 4px; box-shadow: 0 8px 20px -8px rgba(99,102,241,.55); }

.wcs-btn-primary {
	background: linear-gradient(135deg, var(--wcs-primary, #6366f1), var(--wcs-secondary, #8b5cf6)) !important;
	color: #fff !important; border: none !important; border-radius: 11px !important; padding: 10px 16px !important;
	cursor: pointer; font-size: 13px !important; font-weight: 700 !important; transition: opacity .15s;
	width: 100%;
}
.wcs-btn-primary:hover { opacity: .92; }
.wcs-error-text { color: #ef4444 !important; font-size: 12px; min-height: 16px; margin-top: 4px !important; }

/* --- کپچا: جمع‌وجور، همه در یک ردیف --- */
#wcs-captcha-box {
	display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px !important;
	padding: 10px !important; background: #f7f8fc; border-radius: 12px; border: 1px solid #eef0f6;
}
.wcs-captcha-prompt { font-size: 12px !important; color: var(--wcs-text, #374151) !important; margin: 0 !important; font-weight: 600; }
.wcs-captcha-row { display: flex; align-items: center; gap: 8px; }
#wcs-captcha-answer { flex: 1; margin: 0 !important; }
.wcs-captcha-visual { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#wcs-captcha-image { border-radius: 8px; border: 1px solid #e5e7eb; height: 38px; width: auto; max-width: 118px; object-fit: contain; background: #fff; display: block; }
#wcs-captcha-text-fallback { font-size: 13px; font-weight: 800; letter-spacing: .5px; color: var(--wcs-text, #1f2937) !important; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px 10px; }
#wcs-captcha-refresh {
	width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; border: 1px solid #e5e7eb; background: #fff;
	cursor: pointer; display: flex; align-items: center; justify-content: center; color: #6b7280 !important; transition: all .15s;
}
#wcs-captcha-refresh svg { width: 15px; height: 15px; }
#wcs-captcha-refresh:hover { border-color: var(--wcs-primary, #6366f1); color: var(--wcs-primary, #6366f1) !important; transform: rotate(45deg); }
.wcs-captcha-choices { display: flex; gap: 6px; flex-wrap: wrap; }
.wcs-captcha-choices button {
	border: 1px solid #e5e7eb; border-radius: 9px; padding: 7px 11px; background: #fff; cursor: pointer;
	font-size: 12px; transition: all .15s;
}
.wcs-captcha-choices button:hover { border-color: var(--wcs-primary, #6366f1); background: #eef2ff; }

/* --- پیام‌ها --- */
#wcs-messages-list { flex: 1; overflow-y: auto; display: flex !important; flex-direction: column !important; gap: 10px !important; padding-inline-end: 4px; min-height: 0; }
.wcs-msg {
	max-width: 80% !important; padding: 9px 13px !important; border-radius: 15px !important; font-size: 13px !important; line-height: 1.65 !important;
	word-wrap: break-word; word-break: break-word; overflow-wrap: anywhere; animation: wcs-msg-in .18s ease; display: block !important;
}
@keyframes wcs-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.wcs-msg-user { align-self: flex-start !important; background: var(--wcs-user-bubble, #f1f3f9) !important; color: var(--wcs-text, #1f2937) !important; border-bottom-right-radius: 4px !important; }
.wcs-msg-operator { align-self: flex-end !important; background: linear-gradient(135deg, var(--wcs-operator-bubble, #6366f1), var(--wcs-secondary, #8b5cf6)) !important; color: #fff !important; border-bottom-left-radius: 4px !important; }
.wcs-msg img { max-width: 180px; border-radius: 10px; display: block; cursor: pointer; }
.wcs-msg audio { width: 200px; height: 34px; }

#wcs-typing-indicator { font-size: 11px; color: #9ca3af !important; padding: 4px 2px; flex-shrink: 0; }

#wcs-input-area { flex-shrink: 0; position: relative; }
.wcs-input-toolbar { display: flex; gap: 5px; margin-bottom: 8px !important; }
.wcs-tool-btn {
	border: none !important; background: #f1f3f9 !important; border-radius: 9px !important; width: 27px !important; height: 27px !important;
	cursor: pointer; display: flex !important; align-items: center; justify-content: center; color: #6b7280 !important; transition: background .15s;
	padding: 0 !important; flex-shrink: 0;
}
.wcs-tool-btn svg { width: 13px; height: 13px; display: block; }
.wcs-tool-btn:hover { background: #e5e7eb !important; color: var(--wcs-primary, #6366f1) !important; }

.wcs-text-row { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; gap: 8px; align-items: flex-end; width: 100%; }
.wcs-text-row textarea {
	flex: 1 1 auto !important; width: auto !important; min-width: 0; min-height: 40px !important; max-height: 84px;
	margin: 0 !important; padding: 10px 13px !important; order: 1;
}
#wcs-send-btn {
	order: 2; flex: 0 0 40px !important; width: 40px !important; height: 40px !important;
	min-width: 40px !important; max-width: 40px !important; padding: 0 !important; margin: 0 !important;
	border: none !important; border-radius: 12px !important; cursor: pointer;
	background: linear-gradient(135deg, var(--wcs-primary, #6366f1), var(--wcs-secondary, #8b5cf6)) !important;
	display: flex !important; align-items: center !important; justify-content: center !important;
	box-shadow: 0 4px 12px -4px rgba(99,102,241,.6);
	position: static !important; float: none !important;
}
#wcs-send-btn svg { width: 17px !important; height: 17px !important; display: block; color: #fff; }
#wcs-send-btn:hover { opacity: .92; }

/* --- پاپ‌آور ایموجی (کاملاً داخل باکس، شناور روی دکمه‌ها) --- */
#wcs-emoji-panel {
	position: absolute; bottom: calc(100% + 8px); right: 0; left: auto; z-index: 20;
	background: var(--wcs-bg, #fff); border: 1px solid #e5e7eb; border-radius: 13px;
	box-shadow: 0 12px 30px -8px rgba(20,20,43,.25); padding: 8px;
	display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
	width: 176px; max-width: calc(100% - 4px);
}
#wcs-emoji-panel.wcs-hidden { display: none !important; }
#wcs-emoji-panel span { cursor: pointer; font-size: 16px; text-align: center; padding: 5px 3px; border-radius: 7px; line-height: 1.4; }
#wcs-emoji-panel span:hover { background: #f1f3f9; }

/* --- پیش‌نمایش فایل انتخاب‌شده (نشان می‌دهد چیزی برای ارسال انتخاب شده) --- */
.wcs-file-preview {
	display: flex; align-items: center; gap: 8px; background: #eef2ff; border: 1px solid #c7d2fe;
	border-radius: 10px; padding: 7px 10px; margin-bottom: 8px; font-size: 12px; color: #4338ca;
}
.wcs-file-preview .wcs-file-preview-icon { flex-shrink: 0; width: 16px; height: 16px; }
.wcs-file-preview .wcs-file-preview-icon svg { width: 100%; height: 100%; }
.wcs-file-preview .wcs-file-preview-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wcs-file-preview .wcs-file-preview-spinner {
	width: 13px; height: 13px; border: 2px solid #c7d2fe; border-top-color: #4338ca; border-radius: 50%;
	flex-shrink: 0; animation: wcs-spin .7s linear infinite;
}
@keyframes wcs-spin { to { transform: rotate(360deg); } }
.wcs-file-preview.wcs-file-preview-error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

#wcs-voice-recorder { display: flex; align-items: center; gap: 10px; background: #fef2f2; padding: 8px 12px; border-radius: 12px; margin-bottom: 8px; }
#wcs-voice-recorder button { border: none; background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12px; }
#wcs-voice-timer { font-size: 12px; color: #b91c1c; font-weight: 700; }

#wcs-stars { font-size: 28px; color: #e5e7eb; cursor: pointer; direction: ltr; text-align: center; }
#wcs-stars span.active { color: #f59e0b; }

/* --- اسکرول‌بار زیبا --- */
#wcs-chat-widget ::-webkit-scrollbar { width: 5px; height: 5px; }
#wcs-chat-widget ::-webkit-scrollbar-track { background: transparent; }
#wcs-chat-widget ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 10px; }
#wcs-chat-widget * { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.15) transparent; }

/* ==========================================================================
   حالت تاریک
   ========================================================================== */
#wcs-chat-widget[data-theme="dark"] #wcs-chat-window { background: #1a1b26; border-color: rgba(255,255,255,.06); }
#wcs-chat-widget[data-theme="dark"] .wcs-panel { background: #1a1b26; }
#wcs-chat-widget[data-theme="dark"] .wcs-welcome-text { color: #e5e7eb !important; }
#wcs-chat-widget[data-theme="dark"] #wcs-prechat-form input,
#wcs-chat-widget[data-theme="dark"] #wcs-prechat-form textarea,
#wcs-chat-widget[data-theme="dark"] #wcs-message-text { background: #242535 !important; border-color: #34364a !important; color: #e5e7eb !important; }
#wcs-chat-widget[data-theme="dark"] .wcs-msg-user { background: #2d2f42; color: #e5e7eb !important; }
#wcs-chat-widget[data-theme="dark"] .wcs-tool-btn { background: #2d2f42 !important; color: #d1d5db !important; }
#wcs-chat-widget[data-theme="dark"] #wcs-emoji-panel { background: #242535; border-color: #34364a; }
#wcs-chat-widget[data-theme="dark"] #wcs-emoji-panel span:hover { background: #2d2f42; }
#wcs-chat-widget[data-theme="dark"] .wcs-file-preview { background: #242535; border-color: #34364a; color: #c7d2fe; }
#wcs-chat-widget[data-theme="dark"] #wcs-captcha-box { background: #242535; border-color: #34364a; }
#wcs-chat-widget[data-theme="dark"] #wcs-captcha-image { background: #fff; }
#wcs-chat-widget[data-theme="dark"] #wcs-captcha-text-fallback { background: #2d2f42; border-color: #34364a; color: #e5e7eb !important; }
#wcs-chat-widget[data-theme="dark"] .wcs-captcha-prompt { color: #e5e7eb !important; }
#wcs-chat-widget[data-theme="dark"] #wcs-captcha-refresh { background: #2d2f42; border-color: #34364a; color: #d1d5db !important; }
#wcs-chat-widget[data-theme="dark"] .wcs-captcha-choices button { background: #2d2f42; border-color: #34364a; color: #e5e7eb; }
#wcs-chat-widget[data-theme="dark"] #wcs-voice-recorder { background: #2d1f22; }
#wcs-chat-widget[data-theme="dark"] .wcs-prechat-footer { border-top-color: #34364a; }

/* ==========================================================================
   ریسپانسیو کامل (موبایل: تمام‌صفحه)
   ========================================================================== */
@media (max-width: 480px) {
	#wcs-chat-widget.wcs-position-bottom-right,
	#wcs-chat-widget.wcs-position-bottom-left { right: 16px !important; left: 16px !important; bottom: 16px !important; }

	#wcs-chat-window {
		position: fixed !important; inset: 0 !important; width: 100% !important; height: 100% !important;
		max-width: 100% !important; max-height: 100% !important; border-radius: 0 !important;
		bottom: 0 !important; right: 0 !important; left: 0 !important;
	}
	#wcs-toggle-btn { width: 54px; height: 54px; }
	.wcs-msg { max-width: 88%; }
}

@media (min-width: 481px) and (max-width: 768px) {
	#wcs-chat-window { width: min(380px, 90vw); height: min(520px, 78vh); }
}
