.rayli-chat {
	--rayli-primary: #0066cc;
	--rayli-font: 'Vazirmatn', Tahoma, sans-serif;
	--rayli-bg: #fff;
	--rayli-text: #1a1a1a;
	--rayli-muted: #888;
	--rayli-border: #e8e8e8;
	--rayli-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
	font-family: var(--rayli-font);
	position: fixed;
	z-index: 999999;
	bottom: 24px;
}

.rayli-chat--bottom-right { right: 24px; left: auto; }
.rayli-chat--bottom-left  { left: 24px; right: auto; }

.rayli-chat__toggle {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: var(--rayli-primary);
	color: #fff;
	cursor: pointer;
	box-shadow: var(--rayli-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s, box-shadow 0.2s;
	position: relative;
}

.rayli-chat__toggle:hover {
	transform: scale(1.05);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.rayli-chat__panel {
	position: absolute;
	bottom: 72px;
	width: 360px;
	max-width: calc(100vw - 48px);
	height: 480px;
	max-height: calc(100vh - 120px);
	background: var(--rayli-bg);
	border-radius: 16px;
	box-shadow: var(--rayli-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(0.96);
	transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
}

.rayli-chat--bottom-right .rayli-chat__panel { right: 0; }
.rayli-chat--bottom-left  .rayli-chat__panel { left: 0; }

.rayli-chat__panel.is-open {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

.rayli-chat__header {
	background: var(--rayli-primary);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.rayli-chat__title {
	font-weight: 600;
	font-size: 15px;
}

.rayli-chat__close {
	background: none;
	border: none;
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.85;
	padding: 0 4px;
}

.rayli-chat__close:hover { opacity: 1; }

.rayli-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f7f8fa;
}

.rayli-chat__msg {
	display: flex;
	flex-direction: column;
	max-width: 85%;
}

.rayli-chat__msg--visitor {
	align-self: flex-end;
	align-items: flex-end;
}

.rayli-chat__msg--operator,
.rayli-chat__msg--system {
	align-self: flex-start;
	align-items: flex-start;
}

.rayli-chat__bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
}

.rayli-chat__msg--visitor .rayli-chat__bubble {
	background: var(--rayli-primary);
	color: #fff;
	border-bottom-left-radius: 4px;
}

.rayli-chat__msg--operator .rayli-chat__bubble {
	background: #fff;
	color: var(--rayli-text);
	border: 1px solid var(--rayli-border);
	border-bottom-right-radius: 4px;
}

.rayli-chat__msg--system .rayli-chat__bubble {
	background: #e8f0fe;
	color: #333;
	font-size: 13px;
	border-radius: 10px;
}

.rayli-chat__time {
	font-size: 11px;
	color: var(--rayli-muted);
	margin-top: 3px;
	padding: 0 4px;
}

.rayli-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--rayli-border);
	background: #fff;
	flex-shrink: 0;
}

.rayli-chat__input {
	flex: 1;
	border: 1px solid var(--rayli-border);
	border-radius: 12px;
	padding: 10px 12px;
	font-family: inherit;
	font-size: 14px;
	resize: none;
	max-height: 100px;
	line-height: 1.4;
	outline: none;
	transition: border-color 0.2s;
}

.rayli-chat__input:focus {
	border-color: var(--rayli-primary);
}

.rayli-chat__send {
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: var(--rayli-primary);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity 0.2s;
}

.rayli-chat__send:hover { opacity: 0.9; }
.rayli-chat__send:disabled { opacity: 0.5; cursor: not-allowed; }

.rayli-chat__attach {
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: var(--rayli-muted);
	border-radius: 8px;
	flex-shrink: 0;
	transition: color 0.2s, background 0.2s;
}

.rayli-chat__attach:hover {
	color: var(--rayli-primary);
	background: #f0f4ff;
}

.rayli-chat__img {
	max-width: 100%;
	border-radius: 8px;
	display: block;
	margin-bottom: 4px;
}

.rayli-chat__caption {
	margin-top: 6px;
	font-size: 13px;
}

.rayli-chat__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 18px;
	height: 18px;
	background: #e53935;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	border-radius: 9px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 4px;
}

@media (max-width: 480px) {
	.rayli-chat { bottom: 16px; }
	.rayli-chat--bottom-right { right: 16px; }
	.rayli-chat--bottom-left  { left: 16px; }
	.rayli-chat__panel {
		width: calc(100vw - 32px);
		height: calc(100vh - 100px);
	}
}
