/* گفتمان - ویجت چت فرانت‌اند */

#goftaman-widget-root {
	position: fixed;
	z-index: 999999;
	direction: rtl;
}

/* لایه محافظتی: هیچ تصویر/ویدیو/رسانه‌ای هرگز از عرض ظرف خودش بیرون نزند (ریسپانسیو کامل) */
#goftaman-widget-root img,
#goftaman-widget-root video {
	max-width: 100%;
	height: auto;
	box-sizing: border-box;
}

#goftaman-widget-root.goftaman-position-bottom-right {
	bottom: var(--goftaman-offset-y, 20px);
	right: var(--goftaman-offset-x, 20px);
}

#goftaman-widget-root.goftaman-position-bottom-left {
	bottom: var(--goftaman-offset-y, 20px);
	left: var(--goftaman-offset-x, 20px);
}

#goftaman-widget-root.goftaman-position-top-right {
	top: var(--goftaman-offset-y, 20px);
	right: var(--goftaman-offset-x, 20px);
}

#goftaman-widget-root.goftaman-position-top-left {
	top: var(--goftaman-offset-y, 20px);
	left: var(--goftaman-offset-x, 20px);
}

#goftaman-toggle-btn {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--goftaman-accent, #1E88E5);
	border: none;
	box-shadow: 0 4px 14px rgba(var(--goftaman-accent-rgb, 30, 136, 229), 0.45);
	cursor: pointer;
	font-size: 26px;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

/* ---------------- حالت‌های انیمیشن دکمه شناور ---------------- */

/* ضربان: یک حلقه نور که مدام از دکمه بیرون می‌زند و محو می‌شود */
.goftaman-btn-anim-pulse::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: rgba(var(--goftaman-accent-rgb, 30, 136, 229), 0.55);
	animation: goftaman-btn-pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
	z-index: -1;
}

@keyframes goftaman-btn-pulse-ring {
	0% { transform: scale(1); opacity: 0.7; }
	80% { transform: scale(1.9); opacity: 0; }
	100% { transform: scale(1.9); opacity: 0; }
}

/* شناور: حرکت ملایم بالا و پایین، مثل شناور روی آب */
.goftaman-btn-anim-float {
	animation: goftaman-btn-float 2.6s ease-in-out infinite;
}

@keyframes goftaman-btn-float {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-7px); }
}

/* درخشش: یک خط نور که هر چند ثانیه از روی دکمه رد می‌شود */
.goftaman-btn-anim-shine {
	overflow: hidden;
}

.goftaman-btn-anim-shine::after {
	content: '';
	position: absolute;
	top: -50%;
	left: -60%;
	width: 40%;
	height: 200%;
	background: rgba(255, 255, 255, 0.55);
	transform: rotate(25deg);
	animation: goftaman-btn-shine-sweep 3.2s ease-in-out infinite;
}

@keyframes goftaman-btn-shine-sweep {
	0% { left: -60%; }
	35% { left: 130%; }
	100% { left: 130%; }
}

/* لرزش ملایم دوره‌ای: هر چند ثانیه یک بار برای جلب توجه */
.goftaman-btn-anim-wiggle {
	animation: goftaman-btn-wiggle 4.5s ease-in-out infinite;
}

@keyframes goftaman-btn-wiggle {
	0%, 88%, 100% { transform: rotate(0deg) scale(1); }
	90% { transform: rotate(-10deg) scale(1.05); }
	92% { transform: rotate(9deg) scale(1.05); }
	94% { transform: rotate(-7deg) scale(1.03); }
	96% { transform: rotate(5deg) scale(1.02); }
	98% { transform: rotate(0deg) scale(1); }
}

#goftaman-panel {
	position: absolute;
	width: 330px;
	max-width: 90vw;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
	overflow: hidden;
	border: 1px solid #dbe9f7;
}

#goftaman-widget-root.goftaman-position-bottom-right #goftaman-panel {
	right: 0;
	bottom: 75px;
}

#goftaman-widget-root.goftaman-position-bottom-left #goftaman-panel {
	left: 0;
	bottom: 75px;
}

#goftaman-widget-root.goftaman-position-top-right #goftaman-panel {
	right: 0;
	top: 75px;
}

#goftaman-widget-root.goftaman-position-top-left #goftaman-panel {
	left: 0;
	top: 75px;
}

.goftaman-hidden {
	display: none !important;
}

.goftaman-panel-header {
	background: var(--goftaman-accent, #1E88E5);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.goftaman-header-text {
	display: flex;
	flex-direction: column;
	gap: 3px;
	overflow: hidden;
}

#goftaman-panel-title {
	font-weight: bold;
	font-size: 15px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#goftaman-header-status {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 12px;
	font-weight: normal;
	opacity: 0.92;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.goftaman-header-avatar {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	border: 1px solid rgba(255, 255, 255, 0.6);
}

#goftaman-header-status .goftaman-status-dot {
	width: 7px;
	height: 7px;
	flex-shrink: 0;
}

#goftaman-header-status .goftaman-status-online {
	background: #4ade80;
	box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
}

#goftaman-header-status .goftaman-status-offline {
	background: rgba(255, 255, 255, 0.5);
}

#goftaman-header-status .goftaman-status-sep {
	opacity: 0.7;
}

.goftaman-panel-header button {
	background: rgba(255, 255, 255, 0.15);
	border: none;
	color: #fff;
	font-size: 18px;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	cursor: pointer;
	line-height: 1;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: 8px;
}

.goftaman-panel-header button:hover {
	background: rgba(255, 255, 255, 0.28);
}

.goftaman-step {
	padding: 16px;
}

.goftaman-step p:not(.goftaman-error) {
	color: #444;
	margin: 0 0 12px;
}

.goftaman-welcome-text {
	margin-top: 0;
	color: #444;
	font-size: 14px;
}

#goftaman-widget-root input[type="tel"],
#goftaman-widget-root input[type="text"] {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 12px;
	border: 1px solid #d8e6f5;
	border-radius: 8px;
	margin-bottom: 10px;
	font-size: 14px;
	direction: rtl;
}

.goftaman-btn-primary {
	width: 100%;
	padding: 10px;
	background: var(--goftaman-accent, #1E88E5);
	color: #fff;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-size: 14px;
	font-weight: bold;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

.goftaman-btn-primary:disabled {
	opacity: 0.75;
	cursor: default;
}

.goftaman-btn-primary:hover {
	background: var(--goftaman-accent-dark, #1565C0);
}

.goftaman-btn-spinner {
	width: 15px;
	height: 15px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: goftaman-spin 0.7s linear infinite;
	flex-shrink: 0;
}

@keyframes goftaman-spin {
	to { transform: rotate(360deg); }
}

.goftaman-otp-resend {
	text-align: center;
	font-size: 12px;
	color: #999;
	margin: 10px 0 0;
}

.goftaman-otp-retry-link {
	color: var(--goftaman-accent, #1E88E5);
	cursor: pointer;
	font-weight: bold;
	text-decoration: underline;
}

.goftaman-error {
	color: var(--goftaman-accent, #1E88E5);
	font-size: 12px;
	min-height: 16px;
	margin: 6px 0 0;
}

#goftaman-messages-list {
	height: 320px;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 14px 12px;
	background: #f7f8fa;
}

.goftaman-w-msg {
	max-width: 78%;
	width: fit-content;
	box-sizing: border-box;
	margin-bottom: 12px;
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 13.5px;
	line-height: 1.65;
	clear: both;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.goftaman-w-msg-media {
	padding: 6px;
	max-width: 220px;
}

.goftaman-w-msg-pending {
	opacity: 0.55;
}

.goftaman-w-msg-failed {
	opacity: 0.75;
	box-shadow: 0 0 0 1.5px #e53935 inset;
}

.goftaman-w-msg-user {
	background: var(--goftaman-accent, #1E88E5);
	color: #fff;
	float: left;
	border-top-left-radius: 3px;
}

.goftaman-w-msg-agent {
	background: #fff;
	border: 1px solid #e6ebf0;
	color: #2b2b2b;
	float: right;
	border-top-right-radius: 3px;
}

.goftaman-w-time {
	display: block;
	font-size: 10px;
	opacity: 0.75;
	margin-top: 3px;
}

.goftaman-w-msg-footer {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 3px;
}

.goftaman-w-reply-btn {
	cursor: pointer;
	font-size: 12px;
	opacity: 0.7;
}

.goftaman-w-reply-btn:hover {
	opacity: 1;
}

.goftaman-w-reply-quote {
	border-right: 3px solid rgba(0, 0, 0, 0.15);
	padding: 4px 8px;
	margin-bottom: 6px;
	font-size: 11px;
	opacity: 0.8;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.04);
}

.goftaman-w-msg-user .goftaman-w-reply-quote {
	border-right-color: rgba(255, 255, 255, 0.6);
	background: rgba(255, 255, 255, 0.15);
}

.goftaman-w-attachment-img,
.goftaman-w-attachment-video {
	display: block;
	width: 100%;
	max-width: 220px;
	height: auto;
	border-radius: 10px;
	box-sizing: border-box;
}

.goftaman-voice-player {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 230px;
	max-width: 100%;
	padding: 4px 2px;
	background: transparent;
}

.goftaman-voice-play-btn {
	width: 34px !important;
	height: 34px !important;
	min-width: 34px;
	max-width: 34px;
	flex-shrink: 0;
	box-sizing: border-box;
	border-radius: 50% !important;
	border: none !important;
	cursor: pointer;
	display: flex !important;
	align-items: center;
	justify-content: center;
	padding: 0 !important;
	overflow: hidden;
	line-height: 1;
	appearance: none;
	-webkit-appearance: none;
}

.goftaman-voice-play-btn svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	fill: currentColor;
}

.goftaman-voice-icon-pause {
	display: none;
}

.goftaman-voice-playing .goftaman-voice-icon-play {
	display: none;
}

.goftaman-voice-playing .goftaman-voice-icon-pause {
	display: block;
}

.goftaman-voice-wave {
	position: relative;
	flex: 1;
	height: 26px;
	overflow: hidden;
}

.goftaman-voice-wave-bg,
.goftaman-voice-wave-fg {
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	height: 100%;
	display: flex;
	align-items: center;
	gap: 2.5px;
}

.goftaman-voice-wave-fg {
	width: 0%;
	overflow: hidden;
	transition: width 0.1s linear;
}

.goftaman-voice-bar {
	width: 2.5px;
	border-radius: 2px;
	flex-shrink: 0;
}

.goftaman-voice-duration {
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	direction: ltr;
	flex-shrink: 0;
	opacity: 0.85;
}

/* رنگ‌بندی پلیر بسته به این‌که پیام کاربر است یا پشتیبان */
.goftaman-w-msg-user .goftaman-voice-play-btn {
	background: rgba(255, 255, 255, 0.95) !important;
	color: var(--goftaman-accent, #1E88E5) !important;
}

.goftaman-w-msg-user .goftaman-voice-wave-bg .goftaman-voice-bar {
	background: rgba(255, 255, 255, 0.4);
}

.goftaman-w-msg-user .goftaman-voice-wave-fg .goftaman-voice-bar {
	background: #fff;
}

.goftaman-w-msg-agent .goftaman-voice-play-btn {
	background: var(--goftaman-accent, #1E88E5) !important;
	color: #fff !important;
}

.goftaman-w-msg-agent .goftaman-voice-wave-bg .goftaman-voice-bar {
	background: rgba(0, 0, 0, 0.15);
}

.goftaman-w-msg-agent .goftaman-voice-wave-fg .goftaman-voice-bar {
	background: var(--goftaman-accent, #1E88E5);
}

.goftaman-w-msg-media .goftaman-w-msg-footer {
	padding: 0 4px 2px;
}

.goftaman-w-caption {
	margin-top: 6px;
	padding: 0 4px;
}

#goftaman-reply-preview {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	background: #f2f7fd;
	border-top: 1px solid #dbe9f7;
	padding: 6px 12px;
	font-size: 12px;
	color: #444;
}

#goftaman-reply-preview-text {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#goftaman-reply-preview-cancel {
	cursor: pointer;
	font-size: 16px;
	color: #999;
	flex-shrink: 0;
}

#goftaman-upload-progress {
	text-align: center;
	font-size: 11px;
	color: #888;
	padding: 4px;
	background: #fafafa;
}

.goftaman-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}

.goftaman-icon-btn {
	background: transparent !important;
	border: none;
	cursor: pointer;
	font-size: 18px;
	padding: 0 4px !important;
	line-height: 1;
}

.goftaman-icon-btn.goftaman-recording {
	animation: goftaman-pulse 1s infinite;
}

@keyframes goftaman-pulse {
	0% { opacity: 1; }
	50% { opacity: 0.3; }
	100% { opacity: 1; }
}

.goftaman-input-row {
	position: relative;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 10px;
	border-top: 1px solid #eee;
	background: #fff;
}

.goftaman-input-row input {
	flex: 1;
	margin-bottom: 0 !important;
}

.goftaman-input-row button:not(.goftaman-icon-btn) {
	background: var(--goftaman-accent, #1E88E5);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 10px;
	cursor: pointer;
	font-weight: bold;
}

#goftaman-voice-recording-bar {
	display: none;
	align-items: center;
	gap: 8px;
	position: absolute;
	inset: 0;
	background: #fff;
	padding: 0 10px;
}

.goftaman-input-row.goftaman-recording #goftaman-attach-btn,
.goftaman-input-row.goftaman-recording #goftaman-voice-btn,
.goftaman-input-row.goftaman-recording #goftaman-message-input,
.goftaman-input-row.goftaman-recording #goftaman-send-message-btn {
	visibility: hidden;
}

.goftaman-input-row.goftaman-recording #goftaman-voice-recording-bar {
	display: flex;
}

.goftaman-recording-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #e53935;
	flex-shrink: 0;
	animation: goftaman-rec-pulse 1.1s infinite;
}

@keyframes goftaman-rec-pulse {
	0% { opacity: 1; transform: scale(1); }
	50% { opacity: 0.35; transform: scale(0.85); }
	100% { opacity: 1; transform: scale(1); }
}

#goftaman-voice-timer {
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	color: #333;
	direction: ltr;
	flex-shrink: 0;
}

.goftaman-voice-recording-label {
	font-size: 13px;
	color: #888;
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#goftaman-voice-cancel-btn {
	color: #e53935 !important;
	flex-shrink: 0;
}

.goftaman-voice-send-btn {
	background: var(--goftaman-accent, #1E88E5) !important;
	color: #fff !important;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	flex-shrink: 0;
	font-size: 15px !important;
	display: flex;
	align-items: center;
	justify-content: center;
}

.goftaman-icon-chat {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
}

.goftaman-icon-chat svg {
	width: 100%;
	height: 100%;
	color: #fff;
}

.goftaman-icon-chat img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.goftaman-agent-name {
	font-weight: 600;
}

.goftaman-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	display: inline-block;
}

#goftaman-unread-badge {
	position: absolute;
	top: -4px;
	left: -4px;
	background: #e53935;
	color: #fff;
	border-radius: 999px;
	min-width: 20px;
	height: 20px;
	padding: 0 4px;
	font-size: 11px;
	font-weight: bold;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #fff;
	line-height: 1;
}

#goftaman-teaser-bubble {
	position: absolute;
	bottom: 78px;
	width: 270px;
	max-width: 85vw;
	box-sizing: border-box;
	background: #fff;
	color: #2b2b2b;
	border: 1px solid #e3ecf7;
	border-radius: 16px;
	padding: 16px 36px 16px 18px;
	font-size: 14px;
	line-height: 1.9;
	word-break: normal;
	overflow-wrap: break-word;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
	cursor: pointer;
	animation: goftaman-teaser-in 0.35s ease-out;
}

#goftaman-teaser-bubble::after {
	content: '';
	position: absolute;
	bottom: -8px;
	width: 16px;
	height: 16px;
	background: #fff;
	border-bottom: 1px solid #e3ecf7;
	transform: rotate(45deg);
}

#goftaman-widget-root.goftaman-position-bottom-right #goftaman-teaser-bubble::after,
#goftaman-widget-root.goftaman-position-top-right #goftaman-teaser-bubble::after {
	right: 22px;
	border-left: none;
	border-top: none;
	border-right: 1px solid #e3ecf7;
}

#goftaman-widget-root.goftaman-position-bottom-left #goftaman-teaser-bubble::after,
#goftaman-widget-root.goftaman-position-top-left #goftaman-teaser-bubble::after {
	left: 22px;
}

#goftaman-widget-root.goftaman-position-top-right #goftaman-teaser-bubble::after,
#goftaman-widget-root.goftaman-position-top-left #goftaman-teaser-bubble::after {
	top: -8px;
	bottom: auto;
	border-bottom: none;
	border-top: 1px solid #e3ecf7;
}

@keyframes goftaman-teaser-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

#goftaman-widget-root.goftaman-position-bottom-right #goftaman-teaser-bubble,
#goftaman-widget-root.goftaman-position-top-right #goftaman-teaser-bubble {
	right: 0;
}

#goftaman-widget-root.goftaman-position-bottom-left #goftaman-teaser-bubble,
#goftaman-widget-root.goftaman-position-top-left #goftaman-teaser-bubble {
	left: 0;
}

#goftaman-widget-root.goftaman-position-top-right #goftaman-teaser-bubble,
#goftaman-widget-root.goftaman-position-top-left #goftaman-teaser-bubble {
	top: 78px;
	bottom: auto;
}

#goftaman-teaser-close {
	position: absolute;
	top: 8px;
	left: 12px;
	width: 18px;
	height: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 15px;
	line-height: 1;
	color: #aaa;
	border-radius: 50%;
	cursor: pointer;
}

#goftaman-teaser-close:hover {
	background: #f2f2f2;
	color: #666;
}

.goftaman-widget-credit {
	text-align: center;
	font-size: 10px;
	color: var(--goftaman-accent-dark, #1565C0);
	padding: 6px 8px;
	background: rgba(var(--goftaman-accent-rgb, 30, 136, 229), 0.07);
	border-top: 1px solid rgba(var(--goftaman-accent-rgb, 30, 136, 229), 0.15);
}

.goftaman-widget-credit a {
	color: var(--goftaman-accent-dark, #1565C0);
	text-decoration: none;
	font-weight: bold;
}

.goftaman-blocked-notice {
	padding: 12px;
	background: #e3f0fd;
	color: var(--goftaman-accent-dark, #1565C0);
	font-size: 13px;
	text-align: center;
}

/* ===================== فایل (سمت کاربر) ===================== */

.goftaman-w-file {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	background: rgba(0, 0, 0, 0.04);
	border-radius: 10px;
	text-decoration: none;
	max-width: 200px;
	color: inherit;
}

.goftaman-w-msg-user .goftaman-w-file {
	background: rgba(255, 255, 255, 0.2);
}

.goftaman-w-file-icon {
	font-size: 24px;
	flex-shrink: 0;
}

.goftaman-w-file-name {
	font-size: 12px;
	word-break: break-word;
}
