/* Simple FAQ Chat - Frontend Widget Styles */

#sfchat-widget {
	--sfchat-accent: #0073aa;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	position: fixed;
	z-index: 999999;
}

/* ===========================
   Position classes
   =========================== */

.sfchat-pos-bottom-right {
	bottom: 20px;
	right: 20px;
}

.sfchat-pos-bottom-right #sfchat-toggle {
	position: absolute;
	bottom: 0;
	right: 0;
}

.sfchat-pos-bottom-right #sfchat-window {
	position: absolute;
	bottom: 72px;
	right: 0;
}

.sfchat-pos-bottom-left {
	bottom: 20px;
	left: 20px;
}

.sfchat-pos-bottom-left #sfchat-toggle {
	position: absolute;
	bottom: 0;
	left: 0;
}

.sfchat-pos-bottom-left #sfchat-window {
	position: absolute;
	bottom: 72px;
	left: 0;
}

.sfchat-pos-top-right {
	top: 20px;
	right: 20px;
}

.sfchat-pos-top-right #sfchat-toggle {
	position: absolute;
	top: 0;
	right: 0;
}

.sfchat-pos-top-right #sfchat-window {
	position: absolute;
	top: 72px;
	right: 0;
}

.sfchat-pos-top-left {
	top: 20px;
	left: 20px;
}

.sfchat-pos-top-left #sfchat-toggle {
	position: absolute;
	top: 0;
	left: 0;
}

.sfchat-pos-top-left #sfchat-window {
	position: absolute;
	top: 72px;
	left: 0;
}

/* ===========================
   Toggle bubble (base)
   =========================== */

#sfchat-toggle {
	width: 60px !important;
	height: 60px !important;
	min-width: 60px !important;
	min-height: 60px !important;
	max-width: 60px !important;
	max-height: 60px !important;
	padding: 0 !important;
	margin: 0 !important;
	line-height: 0 !important;
	font-size: 0 !important;
	box-sizing: border-box !important;
	border-radius: 50% !important;
	background: var(--sfchat-accent) !important;
	color: #fff !important;
	border: none !important;
	cursor: pointer;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	overflow: hidden !important;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
	transition: transform 0.2s, box-shadow 0.2s;
	-webkit-appearance: none !important;
	appearance: none !important;
	text-indent: 0 !important;
	text-transform: none !important;
	letter-spacing: 0 !important;
	text-decoration: none !important;
}

#sfchat-toggle:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

#sfchat-toggle:focus,
#sfchat-toggle:focus-visible {
	outline: none !important;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}

#sfchat-icon-open {
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 0;
}

/* ===========================
   Chat window (base)
   =========================== */

#sfchat-window {
	width: 370px;
	max-height: 520px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Header */
#sfchat-header {
	background: var(--sfchat-accent);
	color: #fff;
	padding: 10px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

#sfchat-title {
	font-size: 14px;
	font-weight: 600;
}

#sfchat-close {
	background: none;
	border: none;
	color: #fff;
	font-size: 20px;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	opacity: 0.8;
}

#sfchat-close:hover {
	opacity: 1;
}

/* Messages area */
#sfchat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* Bot bubble */
.sfchat-msg-bot {
	background: #f0f0f0;
	color: #333;
	padding: 10px 14px;
	border-radius: 12px 12px 12px 2px;
	max-width: 85%;
	align-self: flex-start;
	word-wrap: break-word;
}

.sfchat-msg-bot p {
	margin: 0 0 0.5em;
}

.sfchat-msg-bot p:last-child {
	margin-bottom: 0;
}

/* User bubble */
.sfchat-msg-user {
	background: var(--sfchat-accent);
	color: #fff;
	padding: 10px 14px;
	border-radius: 12px 12px 2px 12px;
	max-width: 85%;
	align-self: flex-end;
	word-wrap: break-word;
}

/* FAQ question buttons */
.sfchat-faq-buttons {
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-self: flex-start;
	width: 100%;
}

.sfchat-faq-btn {
	background: #fff;
	color: var(--sfchat-accent);
	border: 1.5px solid var(--sfchat-accent);
	padding: 10px 14px;
	border-radius: 8px;
	cursor: pointer;
	text-align: left;
	font-size: 13px;
	transition: background 0.15s, color 0.15s;
	font-family: inherit;
	line-height: 1.4;
}

.sfchat-faq-btn:hover {
	background: var(--sfchat-accent);
	color: #fff;
}

/* Back button */
.sfchat-back-btn {
	background: none;
	color: var(--sfchat-accent);
	border: 1.5px solid var(--sfchat-accent);
	padding: 8px 14px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 13px;
	align-self: flex-start;
	margin-top: 4px;
	font-family: inherit;
	transition: background 0.15s, color 0.15s;
}

.sfchat-back-btn:hover {
	background: var(--sfchat-accent);
	color: #fff;
}

/* ===========================
   Theme: Rounded (default)
   No overrides needed — base styles are the rounded theme
   =========================== */

/* ===========================
   Theme: Classic
   =========================== */

.sfchat-theme-classic #sfchat-toggle {
	border-radius: 16px !important;
}

.sfchat-theme-classic #sfchat-window {
	border-radius: 8px !important;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.sfchat-theme-classic #sfchat-header {
	border-radius: 0;
}

.sfchat-theme-classic .sfchat-faq-btn {
	border-radius: 4px;
}

.sfchat-theme-classic .sfchat-back-btn {
	border-radius: 4px;
}

.sfchat-theme-classic .sfchat-msg-bot {
	border-radius: 8px 8px 8px 2px;
}

.sfchat-theme-classic .sfchat-msg-user {
	border-radius: 8px 8px 2px 8px;
}

/* ===========================
   Theme: Soft
   =========================== */

.sfchat-theme-soft #sfchat-toggle {
	border-radius: 50% !important;
}

.sfchat-theme-soft #sfchat-window {
	border-radius: 20px !important;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12) !important;
}

.sfchat-theme-soft #sfchat-header {
	border-radius: 20px 20px 0 0;
}

.sfchat-theme-soft .sfchat-faq-btn {
	border-radius: 50px;
}

.sfchat-theme-soft .sfchat-back-btn {
	border-radius: 50px;
}

.sfchat-theme-soft .sfchat-msg-bot {
	border-radius: 18px 18px 18px 4px;
}

.sfchat-theme-soft .sfchat-msg-user {
	border-radius: 18px 18px 4px 18px;
}

/* ===========================
   Theme: Sharp
   =========================== */

.sfchat-theme-sharp #sfchat-toggle {
	border-radius: 4px !important;
	box-shadow: none !important;
	border: 1px solid #ccc !important;
}

.sfchat-theme-sharp #sfchat-toggle:hover {
	box-shadow: none !important;
}

.sfchat-theme-sharp #sfchat-window {
	border-radius: 0 !important;
	box-shadow: none !important;
	border: 1px solid #ccc !important;
}

.sfchat-theme-sharp #sfchat-header {
	border-radius: 0;
}

.sfchat-theme-sharp .sfchat-faq-btn {
	border-radius: 0;
	border-width: 2px;
}

.sfchat-theme-sharp .sfchat-back-btn {
	border-radius: 0;
	border-width: 2px;
}

.sfchat-theme-sharp .sfchat-msg-bot {
	border-radius: 0;
}

.sfchat-theme-sharp .sfchat-msg-user {
	border-radius: 0;
}

/* ===========================
   Admin bar offset for top positions
   =========================== */

body.admin-bar .sfchat-pos-top-right {
	top: 52px;
}

body.admin-bar .sfchat-pos-top-left {
	top: 52px;
}

/* ===========================
   Responsive: Tablet (601px – 782px)
   Slightly narrower window, adjusted spacing
   =========================== */

@media (max-width: 782px) {
	#sfchat-window {
		width: 340px;
		max-height: 480px;
	}

	/* WP admin bar is 46px on mobile (<= 782px) */
	body.admin-bar .sfchat-pos-top-right,
	body.admin-bar .sfchat-pos-top-left {
		top: 66px;
	}
}

/* ===========================
   Responsive: Large phone / small tablet (481px – 600px)
   Fluid-width window, bigger touch targets
   =========================== */

@media (max-width: 600px) {
	#sfchat-window {
		width: calc(100vw - 32px);
		max-width: 370px;
		max-height: 70vh;
		max-height: calc(var(--sfchat-vh, 1vh) * 70);
	}

	.sfchat-faq-btn {
		padding: 12px 14px;
		font-size: 14px;
	}

	.sfchat-back-btn {
		padding: 10px 16px;
		font-size: 14px;
	}

	#sfchat-close {
		font-size: 24px;
		padding: 4px;
		min-width: 44px;
		min-height: 44px;
		display: flex;
		align-items: center;
		justify-content: center;
	}
}

/* ===========================
   Responsive: Phone (≤ 480px)
   Fullscreen chat window takeover
   =========================== */

@media (max-width: 480px) {
	/* Override position classes — always bottom-right bubble on mobile */
	#sfchat-widget {
		bottom: 0 !important;
		right: 0 !important;
		left: auto !important;
		top: auto !important;
	}

	#sfchat-toggle {
		bottom: 16px !important;
		right: 16px !important;
		left: auto !important;
		top: auto !important;
		position: fixed !important;
		/* Safe area inset for notched phones */
		bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
		right: calc(16px + env(safe-area-inset-right, 0px)) !important;
	}

	#sfchat-window {
		position: fixed !important;
		top: 0 !important;
		left: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		width: 100% !important;
		max-width: 100% !important;
		max-height: 100% !important;
		height: 100%;
		height: calc(var(--sfchat-vh, 1vh) * 100);
		border-radius: 0 !important;
		box-shadow: none !important;
	}

	#sfchat-window.sfchat-open {
		display: flex !important;
	}

	/* Safe area padding for notched phones */
	#sfchat-header {
		padding-top: calc(10px + env(safe-area-inset-top, 0px));
		padding-left: calc(16px + env(safe-area-inset-left, 0px));
		padding-right: calc(16px + env(safe-area-inset-right, 0px));
	}

	#sfchat-messages {
		padding-left: calc(16px + env(safe-area-inset-left, 0px));
		padding-right: calc(16px + env(safe-area-inset-right, 0px));
		padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	}

	/* Larger touch targets */
	.sfchat-faq-btn {
		padding: 14px 16px;
		font-size: 15px;
		min-height: 44px;
	}

	.sfchat-back-btn {
		padding: 12px 18px;
		font-size: 15px;
		min-height: 44px;
	}

	#sfchat-close {
		font-size: 28px;
		min-width: 44px;
		min-height: 44px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	/* Admin bar on mobile fullscreen */
	body.admin-bar #sfchat-window {
		top: 46px !important;
		height: calc(100% - 46px);
		height: calc(var(--sfchat-vh, 1vh) * 100 - 46px);
	}
}

/* ===========================
   Responsive: Very small phones (≤ 360px)
   Tighter spacing
   =========================== */

@media (max-width: 360px) {
	#sfchat-messages {
		padding: 12px;
		padding-left: calc(12px + env(safe-area-inset-left, 0px));
		padding-right: calc(12px + env(safe-area-inset-right, 0px));
		padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
		gap: 8px;
	}

	.sfchat-msg-bot,
	.sfchat-msg-user {
		max-width: 90%;
		padding: 8px 12px;
	}

	.sfchat-faq-btn {
		padding: 12px 12px;
	}

	#sfchat-header {
		padding: 8px 12px;
		padding-top: calc(8px + env(safe-area-inset-top, 0px));
		padding-left: calc(12px + env(safe-area-inset-left, 0px));
		padding-right: calc(12px + env(safe-area-inset-right, 0px));
	}

	#sfchat-title {
		font-size: 13px;
	}
}

/* ===========================
   Touch device: remove hover effects
   (prevents sticky :hover on touch)
   =========================== */

@media (hover: none) {
	#sfchat-toggle:hover {
		transform: none;
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
	}

	.sfchat-theme-sharp #sfchat-toggle:hover {
		box-shadow: none;
	}
}

/* ===========================
   Reduced motion: disable animations
   =========================== */

@media (prefers-reduced-motion: reduce) {
	#sfchat-toggle {
		transition: none;
	}

	.sfchat-faq-btn,
	.sfchat-back-btn {
		transition: none;
	}
}

/* ===========================
   Landscape phone: limit window height
   =========================== */

@media (max-height: 500px) and (max-width: 900px) {
	#sfchat-window {
		max-height: calc(var(--sfchat-vh, 1vh) * 100 - 90px);
	}

	/* Compact header in landscape */
	#sfchat-header {
		padding: 10px 16px;
	}

	#sfchat-messages {
		padding: 10px;
		gap: 6px;
	}

	.sfchat-faq-btn {
		padding: 8px 12px;
	}
}
