#sah-chatbot-root {
	--sah-primary: #C9A227;
	--sah-primary-dark: #A6831C;
	--sah-secondary: #FBFE8E;
	--sah-secondary-dark: #EEF17A;
	--sah-on-primary: #241B00;
	--sah-ivory: #FFFDF4;
	--sah-bubble-bot: #F5F0DD;
	--sah-text: #2A2210;
	--sah-muted: #8C7C4A;
	--sah-whatsapp: #25D366;
	--sah-radius: 20px;
	--sah-shadow: 0 14px 36px rgba(36, 27, 0, 0.24);
	position: fixed;
	z-index: 999999;
	bottom: 22px;
	right: 22px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#sah-chatbot-toggle {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: var(--sah-primary);
	color: var(--sah-on-primary);
	border: none;
	cursor: pointer;
	box-shadow: var(--sah-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, background 0.2s ease;
}
#sah-chatbot-toggle:hover { background: var(--sah-primary-dark); transform: translateY(-1px); }
#sah-chatbot-toggle svg { width: 27px; height: 27px; }
#sah-chatbot-toggle #sah-icon-close { display: none; }
#sah-chatbot-root.is-open #sah-chatbot-toggle #sah-icon-chat { display: none; }
#sah-chatbot-root.is-open #sah-chatbot-toggle #sah-icon-close { display: block; }

#sah-chatbot-panel {
	position: absolute;
	bottom: 78px;
	right: 0;
	width: 400px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 140px);
	background: var(--sah-ivory);
	border-radius: var(--sah-radius);
	box-shadow: var(--sah-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(12px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
}
#sah-chatbot-root.is-open #sah-chatbot-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

#sah-chatbot-header {
	background: var(--sah-primary);
	color: var(--sah-on-primary);
	padding: 18px 20px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
}
#sah-chatbot-avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: var(--sah-secondary);
	color: var(--sah-on-primary);
	flex-shrink: 0;
}
#sah-chatbot-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
#sah-chatbot-status { font-size: 12.5px; opacity: 0.85; margin-top: 3px; display: flex; align-items: center; gap: 6px; }
#sah-chatbot-status-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: rgba(36, 27, 0, 0.35);
	flex-shrink: 0;
}
#sah-chatbot-status-dot.is-online { background: var(--sah-whatsapp); box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.3); }
#sah-chatbot-status-dot.is-offline { background: rgba(36, 27, 0, 0.35); }

#sah-chatbot-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.sah-msg {
	max-width: 86%;
	padding: 12px 16px;
	border-radius: 16px;
	font-size: 14.5px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.sah-msg-bot {
	background: var(--sah-bubble-bot);
	color: var(--sah-text);
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}
.sah-msg-user {
	background: var(--sah-primary);
	color: var(--sah-on-primary);
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}

#sah-chatbot-quickreplies {
	padding: 0 16px 12px;
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	flex-shrink: 0;
}
.sah-chip {
	border: 1.5px solid rgba(201, 162, 39, 0.4);
	background: transparent;
	color: var(--sah-primary-dark);
	font-size: 13px;
	padding: 7px 14px;
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.15s ease;
}
.sah-chip:hover { background: rgba(201, 162, 39, 0.1); }

.sah-chip-whatsapp { border-color: transparent; background: var(--sah-whatsapp); color: #fff; }
.sah-chip-contact { border-color: transparent; background: var(--sah-secondary); color: var(--sah-on-primary); }

#sah-chatbot-form {
	display: flex;
	gap: 9px;
	padding: 14px 16px;
	border-top: 1px solid rgba(201, 162, 39, 0.22);
	flex-shrink: 0;
}
#sah-chatbot-input {
	flex: 1;
	border: 1px solid rgba(201, 162, 39, 0.35);
	border-radius: 11px;
	padding: 11px 14px;
	font-size: 14.5px;
	outline: none;
	color: var(--sah-text);
	background: #fff;
}
#sah-chatbot-input:focus { border-color: var(--sah-primary); }
#sah-chatbot-form button {
	width: 42px;
	height: 42px;
	border-radius: 11px;
	border: none;
	background: var(--sah-primary);
	color: var(--sah-on-primary);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
#sah-chatbot-form button svg { width: 18px; height: 18px; display: block; }
#sah-chatbot-form button:hover { background: var(--sah-primary-dark); }

.sah-contact-form {
	display: flex;
	flex-direction: column;
	gap: 9px;
	background: #fff;
	border: 1px solid rgba(201, 162, 39, 0.3);
	border-radius: 16px;
	padding: 14px;
	max-width: 90%;
	align-self: flex-start;
}
.sah-form-row { display: flex; flex-direction: column; gap: 4px; }
.sah-form-row label { font-size: 12px; color: var(--sah-muted); font-weight: 600; }
.sah-form-row input {
	border: 1px solid rgba(201, 162, 39, 0.35);
	border-radius: 9px;
	padding: 9px 11px;
	font-size: 13.5px;
	color: var(--sah-text);
	outline: none;
	background: var(--sah-ivory);
}
.sah-form-row input:focus { border-color: var(--sah-primary); }
.sah-form-error { color: #b3261e; font-size: 12px; min-height: 14px; }
.sah-form-submit {
	border: none;
	background: var(--sah-primary);
	color: var(--sah-on-primary);
	border-radius: 9px;
	padding: 10px 12px;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
}
.sah-form-submit:hover { background: var(--sah-primary-dark); }
.sah-form-submit:disabled { opacity: 0.6; cursor: default; }

@media (max-width: 480px) {
	#sah-chatbot-root { right: 14px; bottom: 14px; }
	#sah-chatbot-panel { width: calc(100vw - 28px); height: calc(100vh - 120px); bottom: 74px; }
}

/*
 * RTL (Arabic) support.
 * The launcher stays fixed at the bottom-right corner regardless of language —
 * that's standard convention for floating chat widgets (WhatsApp, Intercom, etc.
 * all keep their launcher in a fixed screen corner even on RTL sites).
 * What DOES need to flip is the message-bubble "tail" corner and the font stack,
 * since Arabic script needs its own typeface rather than the Latin system font stack.
 */
#sah-chatbot-root[dir="rtl"] {
	font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
}
#sah-chatbot-root[dir="rtl"] .sah-msg-bot {
	border-bottom-left-radius: 16px;
	border-bottom-right-radius: 4px;
}
#sah-chatbot-root[dir="rtl"] .sah-msg-user {
	border-bottom-right-radius: 16px;
	border-bottom-left-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
	#sah-chatbot-toggle, #sah-chatbot-panel { transition: none; }
}
