/* ============================================================
   Face520 Customer Service Chat
   Hidden by default, toggle via header button
   ============================================================ */

/* --- Panel --- */
.cs-panel {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 380px;
	height: 600px;
	max-height: calc(100vh - 40px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
	display: none;
	flex-direction: column;
	overflow: hidden;
	z-index: 9999;
}

.cs-panel.is-open {
	display: flex;
}

/* --- Header --- */
.cs-header {
	display: flex;
	align-items: center;
	padding: 14px 16px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: #fff;
	flex-shrink: 0;
}

.cs-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	margin-right: 12px;
	flex-shrink: 0;
}

.cs-agent-info {
	flex: 1;
	min-width: 0;
}

.cs-agent-name {
	font-size: 15px;
	font-weight: 600;
}

.cs-agent-status {
	font-size: 12px;
	opacity: 0.9;
	display: flex;
	align-items: center;
	gap: 4px;
	margin-top: 2px;
}

.cs-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #4ade80;
	animation: csPulse 2s infinite;
}

@keyframes csPulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.5; }
}

.cs-header-actions {
	display: flex;
	gap: 8px;
}

.cs-header-btn {
	width: 32px !important;
	height: 32px !important;
	min-height: 0 !important;
	padding: 0 !important;
	border-radius: 8px;
	background: rgba(255,255,255,0.15) !important;
	border: none !important;
	color: #fff !important;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	transition: background 0.2s;
}

.cs-header-btn:hover {
	background: rgba(255,255,255,0.25) !important;
}

/* --- Messages body --- */
.cs-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #f8f9fc;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.cs-body::-webkit-scrollbar {
	width: 4px;
}

.cs-body::-webkit-scrollbar-thumb {
	background: #d1d5db;
	border-radius: 2px;
}

/* System message */
.cs-system-msg {
	text-align: center;
	font-size: 12px;
	color: #9ca3af;
	padding: 8px 16px;
}

/* Time divider */
.cs-time-divider {
	text-align: center;
	font-size: 12px;
	color: #9ca3af;
	margin: 8px 0;
}

/* Message */
.cs-msg {
	display: flex;
	gap: 8px;
	max-width: 85%;
	animation: csMsgIn 0.3s ease;
}

@keyframes csMsgIn {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: translateY(0); }
}

.cs-msg.left {
	align-self: flex-start;
}

.cs-msg.right {
	align-self: flex-end;
	flex-direction: row-reverse;
}

.cs-msg-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	color: #fff;
	flex-shrink: 0;
}

.cs-msg.left .cs-msg-avatar {
	background: linear-gradient(135deg, #667eea, #764ba2);
}

.cs-msg.right .cs-msg-avatar {
	background: linear-gradient(135deg, #f093fb, #f5576c);
}

.cs-msg-content {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.cs-msg-bubble {
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-break: break-word;
}

.cs-msg.left .cs-msg-bubble {
	background: #fff;
	color: #374151;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.cs-msg.right .cs-msg-bubble {
	background: linear-gradient(135deg, #667eea, #764ba2);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.cs-msg-time {
	font-size: 11px;
	color: #9ca3af;
	padding: 0 4px;
}

.cs-msg.right .cs-msg-time {
	text-align: right;
}

/* Image message */
.cs-msg-image {
	max-width: 200px;
	border-radius: 12px;
	overflow: hidden;
	cursor: pointer;
}

.cs-msg-image img {
	width: 100%;
	display: block;
}

/* Typing */
.cs-typing {
	display: none;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
	background: #fff;
	border-radius: 16px;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(0,0,0,0.05);
	width: fit-content;
}

.cs-msg.left .cs-typing {
	display: flex;
}

.cs-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #9ca3af;
	animation: csTypingBounce 1.4s infinite ease-in-out both;
}

.cs-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.cs-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes csTypingBounce {
	0%, 80%, 100% { transform: scale(0); }
	40% { transform: scale(1); }
}

/* --- Quick replies --- */
.cs-quick-replies {
	display: flex;
	gap: 8px;
	padding: 8px 16px;
	overflow-x: auto;
	flex-shrink: 0;
	background: #fff;
	border-top: 1px solid #f0f0f0;
}

.cs-quick-replies::-webkit-scrollbar {
	display: none;
}

.cs-quick-btn {
	padding: 6px 14px !important;
	min-height: 0 !important;
	border-radius: 16px;
	border: 1px solid #e5e7eb !important;
	background: #fff !important;
	color: #667eea !important;
	font-size: 13px;
	cursor: pointer;
	white-space: nowrap;
	transition: all 0.2s;
}

.cs-quick-btn:hover {
	background: #667eea !important;
	color: #fff !important;
	border-color: #667eea !important;
}

/* --- Footer / input --- */
.cs-footer {
	padding: 12px 16px;
	background: #fff;
	border-top: 1px solid #f0f0f0;
	flex-shrink: 0;
}

.cs-toolbar {
	display: flex;
	gap: 12px;
	padding: 0 4px 8px;
	position: relative;
}

.cs-tool-btn {
	background: none !important;
	border: none !important;
	color: #9ca3af !important;
	cursor: pointer;
	font-size: 18px;
	padding: 4px !important;
	min-height: 0 !important;
	transition: color 0.2s;
	line-height: 1;
}

.cs-tool-btn:hover {
	color: #667eea !important;
}

.cs-input-wrapper {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	background: #f3f4f6;
	border-radius: 20px;
	padding: 6px 6px 6px 14px;
}

.cs-textarea {
	flex: 1;
	border: none;
	background: transparent;
	resize: none !important;
	font-size: 14px;
	line-height: 1.5;
	height: auto !important;
	min-height: 0 !important;
	max-height: 100px;
	overflow-y: auto;
	padding: 6px 0;
	outline: none;
	font-family: inherit;
}

.cs-textarea::placeholder {
	color: #9ca3af;
}

.cs-send-btn {
	width: 36px !important;
	height: 36px !important;
	min-height: 0 !important;
	padding: 0 !important;
	border-radius: 50% !important;
	background: linear-gradient(135deg, #667eea, #764ba2) !important;
	border: none !important;
	color: #fff !important;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	transition: transform 0.2s, opacity 0.2s;
	flex-shrink: 0;
}

.cs-send-btn:hover {
	transform: scale(1.05);
}

.cs-send-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

/* --- Emoji picker --- */
.cs-emoji-picker {
	display: none;
	position: absolute;
	bottom: 100%;
	left: 0;
	margin-bottom: 6px;
	width: 280px;
	max-height: 200px;
	overflow-y: auto;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 4px 20px rgba(0,0,0,0.15);
	padding: 10px;
	z-index: 10001;
	grid-template-columns: repeat(8, 1fr);
	gap: 4px;
}

.cs-emoji-picker.open {
	display: grid;
}

.cs-emoji-item {
	width: 30px;
	height: 30px;
	min-height: 0 !important;
	padding: 0 !important;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	cursor: pointer;
	border-radius: 6px;
	transition: background 0.15s;
	border: none !important;
	background: none !important;
}

.cs-emoji-item:hover {
	background: #f3f4f6 !important;
}

.cs-image-input {
	display: none;
}

.cs-chat-trigger {
	cursor: pointer;
	display: inline-flex;
}

@media (max-width: 480px) {
	.cs-panel {
		width: 100%;
		height: 100%;
		max-height: 100vh;
		bottom: 0;
		right: 0;
		border-radius: 0;
	}
}
