/* =========================================================
   Simple FAQ ChatBot - Frontend Styles
   Modern blue theme, rounded corners, smooth animation, RTL aware.
   ========================================================= */

:root {
	--sfc-primary: #2563eb;
	--sfc-primary-dark: #1d4ed8;
	--sfc-primary-light: #60a5fa;
	--sfc-bg: #ffffff;
	--sfc-bg-soft: #f4f7fe;
	--sfc-bot-bubble: #eef2fb;
	--sfc-user-bubble: linear-gradient(135deg, #2563eb, #3b82f6);
	--sfc-text: #1f2937;
	--sfc-text-muted: #6b7280;
	--sfc-border: #e5e9f5;
	--sfc-shadow: 0 12px 34px rgba(37, 99, 235, 0.22);
	--sfc-radius-lg: 20px;
	--sfc-radius-md: 14px;
	--sfc-radius-sm: 10px;
	--sfc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Tahoma", "Cairo", "Helvetica Neue", Arial, sans-serif;
}

#sfc-chatbot-root,
#sfc-chatbot-root * {
	box-sizing: border-box;
	font-family: var(--sfc-font);
}

.sfc-chatbot-root {
	position: fixed;
	inset-block-end: 24px;
	inset-inline-end: 24px;
	z-index: 999999;
	direction: rtl;
}

/* ---------- Floating toggle button ---------- */

.sfc-chat-toggle {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--sfc-primary), var(--sfc-primary-light));
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--sfc-shadow);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
	position: relative;
}

.sfc-chat-toggle:hover {
	transform: translateY(-3px) scale(1.04);
	box-shadow: 0 16px 40px rgba(37, 99, 235, 0.3);
}

.sfc-chat-toggle:active {
	transform: scale(0.96);
}

.sfc-toggle-icon {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.sfc-icon-close {
	opacity: 0;
	transform: rotate(-90deg) scale(0.6);
}

.sfc-icon-chat {
	opacity: 1;
	transform: rotate(0) scale(1);
}

.sfc-chatbot-root.sfc-open .sfc-icon-chat {
	opacity: 0;
	transform: rotate(90deg) scale(0.6);
}

.sfc-chatbot-root.sfc-open .sfc-icon-close {
	opacity: 1;
	transform: rotate(0) scale(1);
}

/* Pulse ring to draw attention */
.sfc-chat-toggle::after {
	content: "";
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 2px solid var(--sfc-primary-light);
	opacity: 0;
	animation: sfc-pulse 2.6s ease-out infinite;
}

@keyframes sfc-pulse {
	0% {
		opacity: 0.55;
		transform: scale(0.9);
	}
	80% {
		opacity: 0;
		transform: scale(1.25);
	}
	100% {
		opacity: 0;
		transform: scale(1.25);
	}
}

/* ---------- Chat window ---------- */

.sfc-chat-window {
	position: absolute;
	inset-block-end: 78px;
	inset-inline-end: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 140px);
	background: var(--sfc-bg);
	border-radius: var(--sfc-radius-lg);
	box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom left;
	transform: translateY(16px) scale(0.94);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: transform 0.28s cubic-bezier(0.34, 1.35, 0.64, 1), opacity 0.22s ease, visibility 0.28s;
	border: 1px solid var(--sfc-border);
}

.sfc-chatbot-root.sfc-open .sfc-chat-window {
	transform: translateY(0) scale(1);
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* ---------- Header ---------- */

.sfc-chat-header {
	background: linear-gradient(135deg, var(--sfc-primary), var(--sfc-primary-dark));
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.sfc-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.sfc-header-avatar {
	width: 38px;
	height: 38px;
	background: rgba(255, 255, 255, 0.18);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	flex-shrink: 0;
}

.sfc-header-text {
	display: flex;
	flex-direction: column;
	line-height: 1.3;
}

.sfc-header-title {
	font-weight: 700;
	font-size: 15px;
}

.sfc-header-status {
	font-size: 12px;
	opacity: 0.85;
	display: flex;
	align-items: center;
	gap: 5px;
}

.sfc-header-status::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #4ade80;
	display: inline-block;
}

.sfc-chat-close {
	background: rgba(255, 255, 255, 0.16);
	border: none;
	color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
	flex-shrink: 0;
}

.sfc-chat-close:hover {
	background: rgba(255, 255, 255, 0.3);
	transform: rotate(90deg);
}

/* ---------- Messages area ---------- */

.sfc-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: var(--sfc-bg-soft);
	scroll-behavior: smooth;
}

.sfc-chat-messages::-webkit-scrollbar {
	width: 6px;
}

.sfc-chat-messages::-webkit-scrollbar-thumb {
	background: rgba(37, 99, 235, 0.25);
	border-radius: 10px;
}

.sfc-msg-row {
	display: flex;
	max-width: 100%;
	animation: sfc-msg-in 0.28s ease both;
}

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

.sfc-msg-row.sfc-bot {
	justify-content: flex-start;
}

.sfc-msg-row.sfc-user {
	justify-content: flex-end;
}

.sfc-bubble {
	max-width: 80%;
	padding: 11px 15px;
	border-radius: var(--sfc-radius-md);
	font-size: 14px;
	line-height: 1.7;
	white-space: pre-line;
	word-wrap: break-word;
}

.sfc-msg-row.sfc-bot .sfc-bubble {
	background: var(--sfc-bot-bubble);
	color: var(--sfc-text);
	border-start-start-radius: 4px;
}

.sfc-msg-row.sfc-user .sfc-bubble {
	background: var(--sfc-user-bubble);
	color: #fff;
	border-start-end-radius: 4px;
}

/* Quick reply question buttons */
.sfc-options {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-inline-start: 2px;
	max-width: 92%;
}

.sfc-option-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	text-align: start;
	background: #fff;
	border: 1.5px solid var(--sfc-primary-light);
	color: var(--sfc-primary-dark);
	padding: 9px 14px;
	border-radius: var(--sfc-radius-sm);
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.18s ease, transform 0.15s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.sfc-option-btn .sfc-option-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--sfc-primary);
	color: #fff;
	font-size: 11.5px;
	flex-shrink: 0;
}

.sfc-option-btn:hover {
	background: var(--sfc-primary);
	color: #fff;
	transform: translateX(-2px);
	box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

[dir="rtl"] .sfc-option-btn:hover {
	transform: translateX(2px);
}

.sfc-option-btn:hover .sfc-option-num {
	background: #fff;
	color: var(--sfc-primary);
}

/* Typing indicator */
.sfc-typing .sfc-bubble {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 13px 16px;
}

.sfc-typing-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--sfc-text-muted);
	animation: sfc-typing 1.2s infinite ease-in-out;
}

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

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

@keyframes sfc-typing {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	30% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

/* ---------- Input area ---------- */

.sfc-chat-input-area {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	background: var(--sfc-bg);
	border-top: 1px solid var(--sfc-border);
	flex-shrink: 0;
}

.sfc-chat-input {
	flex: 1;
	border: 1.5px solid var(--sfc-border);
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 14px;
	outline: none;
	background: var(--sfc-bg-soft);
	color: var(--sfc-text);
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.sfc-chat-input:focus {
	border-color: var(--sfc-primary);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.sfc-chat-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: linear-gradient(135deg, var(--sfc-primary), var(--sfc-primary-dark));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sfc-chat-send svg {
	transform: scaleX(-1);
}

[dir="rtl"] .sfc-chat-send svg {
	transform: scaleX(1);
}

.sfc-chat-send:hover {
	transform: scale(1.07);
	box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.sfc-chat-send:active {
	transform: scale(0.95);
}

/* ---------- Responsive (mobile) ---------- */

@media (max-width: 480px) {
	.sfc-chatbot-root {
		inset-block-end: 16px;
		inset-inline-end: 16px;
	}

	.sfc-chat-window {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-width: 100%;
		max-height: 100%;
		border-radius: 0;
	}

	.sfc-chat-toggle {
		width: 56px;
		height: 56px;
	}
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	.sfc-chat-toggle,
	.sfc-chat-window,
	.sfc-msg-row,
	.sfc-option-btn,
	.sfc-chat-send,
	.sfc-chat-close {
		animation: none !important;
		transition: none !important;
	}
}
