:root {
	--ki-beige: #EFE3CC;
	--ki-red: #A6321C;
	--ki-white: #FFFFFF;
}

#ki-chat-widget {
	position: fixed;
	bottom: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
	direction: rtl;
}
#ki-chat-widget.ki-pos-right { right: 24px; }
/* Left side is where this site's WhatsApp floating button lives, so the chat bubble
   is pushed up (bottom: 96px instead of 24px) to stack neatly above it instead of
   overlapping. Adjust this value if the WhatsApp button's own size/position changes. */
#ki-chat-widget.ki-pos-left  { left: 24px; bottom: 96px; }

#ki-chat-bubble {
	width: 62px;
	height: 62px;
	border-radius: 50%;
	background: var(--ki-red);
	color: var(--ki-white);
	border: none;
	box-shadow: 0 4px 16px rgba(0,0,0,0.25);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 26px;
	transition: transform 0.15s ease;
}
#ki-chat-bubble:hover { transform: scale(1.06); }

#ki-chat-window {
	position: absolute;
	bottom: 78px;
	width: 400px;
	max-width: 90vw;
	height: 620px;
	max-height: 82vh;
	background: var(--ki-beige);
	border-radius: 16px;
	box-shadow: 0 8px 30px rgba(0,0,0,0.3);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid rgba(0,0,0,0.08);
}
#ki-chat-widget.ki-pos-right #ki-chat-window { right: 0; }
#ki-chat-widget.ki-pos-left  #ki-chat-window { left: 0; }

#ki-chat-window.ki-hidden { display: none; }

.ki-chat-header {
	background: var(--ki-red);
	color: var(--ki-white);
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 600;
	font-size: 15px;
}
.ki-chat-header-title { display: flex; align-items: center; gap: 8px; }
.ki-crown { font-size: 16px; }

#ki-chat-close {
	background: transparent;
	border: none;
	color: var(--ki-white);
	font-size: 16px;
	cursor: pointer;
	line-height: 1;
	padding: 4px;
}

.ki-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--ki-beige);
}

.ki-msg {
	max-width: 80%;
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 13.5px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.ki-msg a { color: inherit; text-decoration: underline; }

.ki-mode-buttons {
	display: flex;
	gap: 8px;
	align-self: stretch;
	margin-top: 2px;
}
.ki-mode-buttons button {
	flex: 1;
	background: var(--ki-red);
	color: var(--ki-white);
	border: none;
	border-radius: 14px;
	padding: 9px 8px;
	font-size: 12.5px;
	font-weight: 700;
	cursor: pointer;
	font-family: inherit;
}
.ki-mode-buttons button.secondary {
	background: var(--ki-white);
	color: var(--ki-red);
	border: 1.5px solid var(--ki-red);
}
.ki-mode-buttons button:hover { opacity: 0.9; }

.ki-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-self: flex-start;
	max-width: 90%;
	margin-top: 2px;
}
.ki-quick-replies button {
	background: var(--ki-white);
	color: var(--ki-red);
	border: 1.5px solid var(--ki-red);
	border-radius: 14px;
	padding: 7px 12px;
	font-size: 12.5px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
}
.ki-quick-replies button:hover { background: var(--ki-beige); }

.ki-msg-bot {
	background: var(--ki-white);
	color: #2c2c2c;
	align-self: flex-start;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ki-msg-user {
	background: var(--ki-red);
	color: var(--ki-white);
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}
.ki-msg-typing {
	background: var(--ki-white);
	color: #999;
	align-self: flex-start;
	font-style: italic;
}

.ki-chat-input-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px;
	background: var(--ki-white);
	border-top: 1px solid rgba(0,0,0,0.08);
}
#ki-chat-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 9px 14px;
	font-size: 16px; /* 16px prevents iOS Safari from auto-zooming/jumping the page on focus */
	outline: none;
	background: var(--ki-beige);
	color: #2c2c2c;
}
#ki-chat-input:focus { border-color: var(--ki-red); }

#ki-chat-attach {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--ki-beige);
	color: var(--ki-red);
	border: 1px solid #ddd;
	cursor: pointer;
	font-size: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
#ki-chat-attach:hover { background: #e6d7b5; }
#ki-chat-attach:disabled { opacity: 0.5; cursor: default; }

.ki-msg-image {
	max-width: 60%;
	border-radius: 12px;
	display: block;
}

#ki-chat-send {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--ki-red);
	color: var(--ki-white);
	border: none;
	cursor: pointer;
	font-size: 15px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
#ki-chat-send:disabled { opacity: 0.5; cursor: default; }

#ki-chat-widget .ki-chat-footer {
	background: var(--ki-white);
	text-align: center;
	padding: 8px 10px 12px;
}
/* !important + a high-specificity selector: WordPress themes often style "a" tags
   globally (e.g. force link color to black), which would otherwise override this. */
#ki-chat-widget .ki-chat-footer a,
#ki-chat-widget .ki-chat-footer a:visited,
#ki-chat-widget .ki-chat-footer a:link {
	display: inline-block !important;
	background: var(--ki-red) !important;
	color: var(--ki-white) !important;
	font-size: 12.5px !important;
	font-weight: 700 !important;
	text-decoration: none !important;
	padding: 7px 16px !important;
	border-radius: 16px !important;
	border: none !important;
}
#ki-chat-widget .ki-chat-footer a:hover { opacity: 0.9; }

/* On mobile the widget stays a compact floating card (not a full-screen takeover) so
   it reads as a polished widget rather than hijacking the whole page. This is the
   RESTING state (keyboard closed): anchored to the same corner as the bubble, sized to
   leave the page visible around it. Once the input is focused, chat-widget.js takes over
   positioning via the visualViewport API (setting top/height/bottom inline) and pins the
   card to the browser's actual visible viewport rectangle - this is what prevents the
   iOS Safari "jump" when the keyboard opens, since a plain CSS fixed+dvh element gets
   miscalculated by Safari relative to the keyboard-shrunk visual viewport. Do not remove
   the JS listeners in chat-widget.js without also re-testing on an iPhone Safari. */
@media (max-width: 480px) {
	#ki-chat-window {
		position: fixed;
		left: 12px;
		right: 12px;
		bottom: 88px;
		width: auto;
		max-width: none;
		height: min(72dvh, 620px);
		max-height: 78dvh;
		border-radius: 16px;
	}
}

body.ki-chat-open {
	position: fixed;
	width: 100%;
	overflow: hidden;
}
